Reputation: 7736
While compiling typescript I get an error:
src\app\foo.ts (129,25): Index signature of object type implicitly has an 'any' type. (7017)
on the following line:
const tmode = google.maps['DirectionsTravelMode'].DRIVING;
google.maps.DirectionsTravelMode doesn't exist in my typings file which I installed using typings install google.maps --save --ambient
I could add it but it would be lost when I checkout my project and reinstall the typings.
This is just one item in the file which is preventing my build from succeeding. What is the easiest way to get typescript to ignore this line? I have tested the code already and it runs correctly.
Upvotes: 0
Views: 227
Reputation: 2750
You could extend the module yourself:
declare module google.maps {
export enum DirectionsTravelMode {
DRIVING
}
}
NOTE: this would have to go in a declaration file such as mygoogle.d.ts.
Upvotes: 2
Reputation: 275927
Index signature of object type implicitly has an 'any' type.
Instead of indexing just assert the any yourself:
const tmode = (google.maps as any).DirectionsTravelMode.DRIVING;
Upvotes: 1