为什么角度编译器找不到GeolocationPosition
and GeolocationPositionError
?VSC 不会出错,只有在编译时才会出错。
Error: src/app/modules/shared/services/position.service.ts:10:46 - error TS2304: Cannot find name 'GeolocationPosition'.
10 private positionSource = new ReplaySubject<GeolocationPosition>(1);
我通过放置any
类型来解决这个问题,但我只是好奇为什么 Angular 会给我错误以及如何解决这个问题。
我已经尝试过不同的编译器目标(es5
, es6
, es2018
),但没有运气。已经安装@types/core-js
但也没有任何运气。我可能缺少任何@types 模块吗?
这是我当前的 tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es5",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}