I'm working on an Angular 9 project. I'd like to use a ResizeObserver, but since this type is currently missing from TypeScript's lib.dom.d.ts (issue), I tried to add Jason Strothmann's ResizeObserver.d.ts file to my project.
I followed the advice given by this page:
types directory under src.ResizeObserver.d.ts into src/types."./src/types" to the "typeRoots" array in tsconfig.json (it's in the app folder, just like src).ResizeObserver in src/components/foo/foo.component.ts, but TypeScript did not recognize the type, not even after stopping and restarting ng serve, or restarting VS Code.My tsconfig.json looks like this:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./out-tsc",
"sourceMap": true,
"declaration": false,
"importHelpers": true,
"experimentalDecorators": true,
"moduleResolution": "Node",
"module": "ES2015",
"target": "ES2015",
"typeRoots": ["./src/types", "./node_modules/@types"],
"lib": ["ES2015", "DOM", "DOM.Iterable"]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
},
"files": ["./src/main.ts"]
}
All other (JavaScript, DOM- or Angular-related) types are recognized by TypeScript, only the types defined in ResizeObserver.d.ts are ignored. What am I doing wrong?
I've found the problem. I had to add this line to tsconfig.json:
"include": ["./src/types/*.d.ts"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With