打字稿:找不到名称要求

时间:2018-02-02 16:45:41

标签: typescript

我在vscode上收到此错误:

enter image description here

这是我的package.json文件:

{
  "name": "font-awesome-test",
  "version": "1.0.0",
  "description": "Test font-awesome with webpack",
  "main": "index.js",
  "repository": "git@github.com:jeusdi/fontawesome-webpack.git",
  "author": "Jordi Cabré",
  "license": "MIT",
  "dependencies": {
    "font-awesome": "^4.7.0",
    "typescript": "^2.7.1"
  },
  "devDependencies": {
    "webpack": "^3.10.0",
    "webpack-dev-server": "^2.11.1"
  }
}

有什么想法吗?

3 个答案:

答案 0 :(得分:4)

在添加节点类型定义后,TypeScript可以理解dim parm_array() as String dim col_num as Integer dim i as Integer function hide_column (ByVal col_num as Integer) as Boolean parm_array = Split(Join(Report.Parameters!show.Value,","), ",") for i in LBound(parm_array) To UBound(parm_array) if col_num = CInt(parm_array(i)) then hide_column = 0 exit for else hide_column = 1 end if next end function

require

简写:

npm install --save-dev @types/node

npm i -D @types/node

yarn

此外,您可能想要使用

yarn add -D @types/node
"moduleResolution": "Node", 中的

以避免不同的错误,例如

tsconfig.json

答案 1 :(得分:3)

我遇到相同的错误,当检查tsconfig.app.json文件时,它具有:

"types": []

仅更改为

"types": ["node"]

现在一切正常!

答案 2 :(得分:0)

TypeScript支持两种不同的模块解析策略:ClassicNode。默认为Classic。

要使用require('package')方法,您需要在Node的{​​{1}}中将模块解析策略更改为compileOptions

tsconfig.json