I have created a simple Angular 4/Typescript v2.1.6 application. I am trying to use the googlemaps typescript definition (.d.ts file) as specified at https://www.npmjs.com/package/@types/googlemaps
I ran the command
npm install --save @types/googlemaps
Then in my app.component.ts
import * as googlemaps from "googlemaps";
When I execute
npm start
I get the following error
error TS2306: File '/home/dev/project/node_modules/@types/googlemaps/index.d.ts' is not a module.
my tsconfig.json file is in the src folder and the node_modules folder is at the same level as src i.e:
/home/dev/project
|_src
|_app/
|_tsconfig.json
|_node_modules/
|_@types/
|_googlemaps/
The contents of tsconfig.json are as follows. (I have also tried without the types/typeRoots properties)
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2015",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../node_modules/@types"
],
"types": [
"googlemaps"
]
}
}
I can confirm that the file index.d.ts also exists at the location node_modules/@types/googlemaps/index.d.ts
I can't work out what I am missing?