我在TypeScript 2.1.4中得到了一个红色的智能感知错误,VisualStudio2015Update 3说找不到名称“承诺”,例如,下面的代码显示了两种承诺用法的错误:
/// <reference path="../typings/index.d.ts" />
import 'fetch';
import {HttpClient, json} from 'aurelia-fetch-client';
import {inject} from 'aurelia-framework';
import {BearerToken} from './common/bearer-token';
export class ApiToken
{
....
public getTokenSimplified(): Promise<BearerToken>
{
let tokenResult: BearerToken;
let p = new Promise<BearerToken>(function (resolve, reject)
{
// my code ommited
});
return p;
}
....
}TypeScript没有错误地编译,所以我可以用它来完成,但是我想找到一个解决方案。有人知道怎么解决这个问题吗?在研究了StackOverflow和Github之后,我尝试了以下几种方法:
tscconfig.json如下:
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"sourceMap": true,
"target": "es5",
"module": "amd",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"lib": ["es2015", "dom"],
"baseUrl": "./",
"paths": {
"src/*": ["src/*"]
}
},
"filesGlob": [
"./src/**/*.ts",
"./test/**/*.ts",
"./typings/index.d.ts",
"./custom_typings/**/*.d.ts",
"./jspm_packages/**/*.d.ts"
],
"exclude": [
"node_modules",
"jspm_packages",
"dist",
"build",
"test"
],
"atom": {
"rewriteTsconfig": false
}
}也许我没有正确引用所需的库,所以如果有人能指出错误,我会很感激的。
发布于 2017-01-18 00:12:45
为lib尝试此配置
"lib": ["es2015", "dom", "es6"]如果缺少其他类型(Request、Response、BufferSource URLSearchParams、.)请发送您的typings.json文件。
https://stackoverflow.com/questions/41678311
复制相似问题