小编oli*_*ost的帖子

如何在没有<reference>的情况下在TypeScript中使用'Typings'导入模块?

我真的试图写有测试量角器茉莉花打字稿.TSD现已弃用,所以我必须使用'Typings'来操作TypeScript定义.所以我安装了它:

npm install typings -g
Run Code Online (Sandbox Code Playgroud)

然后我用它来安装像这样的Jasmine和Chance定义:

typings install jasmine --source dt --save –-global
typings install chance--source dt --save –-global
Run Code Online (Sandbox Code Playgroud)

我还添加了"files"部分并排除了'node_modules':

// tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "declaration": false,
    "noImplicitAny": false,
    "outDir": "tmp",
    "types": ["node", "jasmine", "chance"]
  },
  "files": [
    "typings/index.d.ts"
  ],
  "include": [
    "lib",
    "specs"
  ],
  "exclude": [
    "node_modules"
  ]
}
Run Code Online (Sandbox Code Playgroud)

问题是WebStorm和Visual Code studio都找不到所有Jasmine方法和'机会'模块的定义.错误是:

**“TS2304: Cannot find name 'describe'”** 
**“TS2307: Cannot find module 'chance'”**
Run Code Online (Sandbox Code Playgroud)

分别.这是我的spec文件: …

jasmine typescript protractor typescript-typings

5
推荐指数
1
解决办法
7739
查看次数