简体   繁体   English

如何解决“未使用的表达式,预期的赋值或函数调用”问题?

[英]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.

相关问题 未使用的表达式,预期的赋值或函数调用 - unused expression, expected an assignment or function call 预期分配或 function 调用,而是看到一个表达式:没有未使用的表达式 - Expected an assignment or function call and instead saw an expression : no unused expression 如何解决错误:需要执行赋值或函数调用,而是看到一个表达式no-unused-expressions - How to fix error: Expected an assignment or function call and instead saw an expression no-unused-expressions 预期分配或 function 调用,而是看到一个表达式 no-unused-expressions - 如何修复此 CI 错误? - Expected an assignment or function call and instead saw an expression no-unused-expressions - how to fix this CI error? 错误:需要赋值或函数调用,但看到的是表达式 no-unused-expressions。 如何解决? - Error: Expected an assignment or function call and instead saw an expression no-unused-expressions. How to solve it? 如何解决这个 期望赋值或函数调用,而是看到一个表达式 no-unused-expressions - how to solve this Expected an assignment or function call and instead saw an expression no-unused-expressions 反应问题 - 预期分配或 function 调用,而是看到一个表达式 - React issue - Expected an assignment or function call and instead saw an expression 期望一个赋值或函数调用,而是看到一个表达式 no-unused-expressions-ReactJs - Expected an assignment or function call and instead saw an expression no-unused-expressions- ReactJs 在React中导入文件时,获得期望的赋值或函数调用,而是看到一个表达式no-unused-expressions - Getting Expected an assignment or function call and instead saw an expression no-unused-expressions, when import a file in React 反应:期望一个赋值或函数调用,而是看到一个表达式 no-unused-expressions - React: expected an assignment or function call and instead saw an expression no-unused-expressions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM