Reputation: 850
This is the same issue as How to allow modules that have missing .d.ts type definition?
VS Code stopped complaining after adding those files, but trying to compile using gulp
sadly throw an error in the console.
(In fact today I noticed VS code stopped displaying most of the errors)
In ./src/dts/
I have:
dyo.d.ts
declare module 'dyo';
tsconfig.json
{
"compilerOptions": {
"lib": ["dom", "es2016", "es2017.object"],
"rootDir": "src",
"target": "es5",
"outDir": "build",
"moduleResolution": "node",
//"noImplicitAny": false,
"removeComments": true,
"typeRoots": [
"src/dts",
"node_modules/@types"
]
},
"exclude": [
"node_modules"
],
"files": [
"./src/dts/dyo.d.ts",
"./src/dts/randomseed.d.ts"
]
}
The error:
error TS7016: Could not find a declaration file for module 'dyo'. '/mediatest/node_modules/dyo/dist/dyo.umd.js' implicitly has an 'any' type. Try
npm install @types/dyo
if it exists or add a new declaration (.d.ts) file containingdeclare module 'dyo';
I include the modules like so:
import { h, render } from 'dyo'
import * as _rng from 'random-seed'
The second module isn't working either.
The previous answer suggested to include files
property and another question somewhere said to include the typeRoots
property but both settings doesn't seem to be working.
Sorry for spamming SO about my typescript questions.
Upvotes: 1
Views: 8165
Reputation: 6063
I would suggest switching to types
from typeRoots
and using an include
pattern rather than files
.
{
"compilerOptions": {
"lib": ["dom", "es2016", "es2017.object"],
"rootDir": "src",
"target": "es5",
"outDir": "build",
"moduleResolution": "node",
"removeComments": true,
"types": [
"node"
]
},
"include": [
"**/*.ts"
]
}
I included the node
type as well since you are using node
module resolution, be sure to install @types/node
if you have not already.
Upvotes: 2