[英]How to resolve the issue “unused expression, expected an assignment or function call”?
I have tried to import the json file in my react application(App.tsx). 我试图在我的反应应用程序(App.tsx)中导入json文件。
App.tsx
import * as currencies from './currencies.json';
My Json file will look like below structure: 我的Json文件看起来像下面的结构:
{
"main": {
"numbers": {
"currencies": {
}
}
}
}
While running the application, it throws the below error 在运行应用程序时,它会抛出以下错误
(1,1): unused expression, expected an assignment or function call (1,1):未使用的表达式,期望赋值或函数调用
After further analysis, i have added the typings.d.ts file within src folder 经过进一步分析,我在src文件夹中添加了typings.d.ts文件
declare module "*.json" {
const value: any;
export default value;
}
But still we are facing the same issue. 但我们仍面临同样的问题。 Can anyone please suggest how to resolve this?
任何人都可以建议如何解决这个问题?
I have resolved the same issue by include the below code block in tslint.json file 我通过在tslint.json文件中包含以下代码块解决了同样的问题
"linterOptions": {
"exclude": [
"*.json",
"**/*.json"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.