angular – Visual Studio代码:node_modules/@types/googlemaps
我按照本教程:
Integrating Google Maps in Angular 5使用Visual Studio Code(Mac上的版本1.24.1)在我的Angular 5应用程序中开始使用Google Maps.直到最近一切都工作正常,但几天前(我的猜测是VS代码的更新发生在后台)我在Visual Studio代码中导入谷歌地图时出错,以前从未给我错误: import { } from '@types/googlemaps'; 我收到以下错误: File 'full_path/node_modules/@types/googlemaps/index.d.ts' is not a module. (注意full_path是完整的父路径,为简洁起见,此处未显示) 我可以看到该库位于node_modules目录中的正确位置.此外,我的package.json中正确引用了库(它的版本为3.30.10).我没有运行npm update或其间的任何其他更新,当它工作时和它开始给出错误时. 当我运行“npm start”或“npm run build”时,它运行得很好,应用程序就像之前一样(并且Google Map渲染完美),因此它似乎是Visual Studio Code问题. 从这个意义上来说,它并没有真正阻止我,但是从我的IDE中获取错误会很好.有没有人有任何关于如何摆脱错误的指针?谢谢! 编辑 /// <reference path="<relevant path>/node_modules/@types/googlemaps/index.d.ts" /> 仍然会对我可以导入Google地图类型的真正修复感兴趣. 解决方法
仅在.component.ts文件顶部的行下方使用,它对我有用.
/// <reference types="@types/googlemaps" /> 我的tsconfig.json { "compileOnSave": false,"compilerOptions": { "baseUrl": "./","outDir": "./dist/out-tsc","sourceMap": true,"declaration": false,"moduleResolution": "node","emitDecoratorMetadata": true,"experimentalDecorators": true,"target": "es5","typeRoots": [ "node_modules/@types" ],"lib": [ "es2017","dom" ] } } MY @ types / googlemaps版本 – “@ types / googlemaps”:“^ 3.30.11”, 我的@ angular / core版本 – “@ angular / core”:“^ 6.1.0”, 不要使用下面的行(一些答案推荐任何一个)早些时候我使用角度6.0.0它与这些工作,但当我升级它没有: – import { } from 'googlemaps'; import { } from '@types/googlemaps'; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |