I've read this answer about how to extend built-in types, but it only tells half the story. How do we tell TypeScript where to find our global definitions?
I've created a file,
src/cssom.d.ts
interface HTMLElement {
computedStyleMap(): any
}
And then tried including it with include
(not sure if this is the best option or not):
tsconfig.json
{
"compilerOptions": {
...
},
"files": [
"src/index"
],
"include": [
"src/**/*.d.ts"
],
"exclude": [
"node_modules"
]
}
But my VS Code still complains:
Even though it compiles without error or warnings via awesome-typescript-loader.
So what do I have to do to get the language service to behave? What's the best way to configure tsconfig to read all my *.d.ts
files?
Adding
///<reference path="cssom.d.ts"/>
To the top of the file satisfies both the compiler and the language service, but I really don't want to add these <reference>
s everywhere since I'm extending a built-in/global type.