Encountering a similar issue while attempting to utilize @types/dom-inputevent in unit tests for an Angular 6 application, I discovered the root of the problem. It turned out that my tsconfig.spec.js file had a specific 'types' declaration, causing conflicts with the typeRoots setting in the parent tsconfig.json file.
tsconfig.json (irrelevant details excluded)
{
"compilerOptions": {
"typeRoots": [
"node_modules/@types"
]
}
}
tsconfig.spec.js (irrelevant details omitted)
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": [
"jasmine",
"node"
]
}
The explicit 'types' entry in tsconfig.spec.js took precedence over the 'typeRoots' setting, restricting access to only @types/jasmine and @types/node during compilation of my unit tests. More information can be found here: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types.
To resolve this issue, I needed to include dom-inputevent
in the 'types' list as shown below:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": [
"jasmine",
"node",
"dom-inputevent"
]
}
Alternatively, removing the 'types' entry entirely would prompt the 'typeRoots' to search for all types under node_modules/@types, thereby encompassing @types/dom-inputevent as well.