找不到命名空间 "Microsoft

问题描述 投票:-1回答:1

我正在使用Angular 9,我试图整合BingMaps。

所以我得到了这个编译错误。

src/app/dashboard/pages/infos-generale/infos/infos.component.ts:33:8 

- error TS2503: Cannot find namespace 'Microsoft'.

33   map: Microsoft.Maps.Map;
angular bing-maps angular9
1个回答
0
投票

你只需要在 tsconfig.app.json 中把 bingmaps 添加到识别的类型中。

tsconfig.app.json中添加bmaps到识别类型中。

   "compilerOptions": {
     "outDir": "./out-tsc/app",
     "types": [
+      "bingmaps"
     ]

如果指定了类型,只有列出的包才会被包含。

所以在我们的例子中,这个 tsconfig.json 文件将只包含 .node_modules@typesbingmaps。node_modules@types*下的其他包将不会被包含。types包是一个文件夹,其中有一个名为index.d.ts的文件,或者是一个有type字段的package.json的文件夹。

© www.soinside.com 2019 - 2024. All rights reserved.