我有一个由export async function currentPosition() {
const fetchResult = fetch('http://api.open-notify.org/iss-now.json');
const response = await fetchResult;
const iss_position = await response.json();
}
export function initMap() {
let map = new google.maps.Map(document.getElementById('map'), {
center: iss_position,
zoom: 5,
});
let marker = new google.maps.Marker({
position: iss_position,
map: map,
});
}
currentPosition();
initMap();
生成的默认项目结构,其中有一个根angular-cli
,tsconfig.json
和src/tsconfig.app.json
。尽管我在根配置中启用了src/tsconfig.spec.json
和noImplicitAny
选项,但是当我未指定函数参数类型或未将strict
类型的变量分配给{{ 1}}。
如何配置WebStorm以使用我的根number
为我提供提示?
这是我的根null
:
tsconfig.json
我的TypeScript WebStorm设置:
即使我在tsconfig.json
中指定{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"target": "esnext",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom",
"esnext"
],
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}
和"files"
选项以指向我的"include"
文件,也不会出现错误,尽管在我以前的(非角度)应用程序中,工作良好。如果我在项目根目录中运行tsconfig.json
,则会收到一堆预期的错误消息,但仍未提供编辑器提示。
答案 0 :(得分:1)
由于设法在TypeScript控制台中不断收到错误消息,因此我选择了"Angular language service"
来解决了这个问题:
Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined