rhythmic-finland-36256
09/30/2019, 3:34 PMnoImplicitAny
?) I’m using some third-party javascript library which doesn’t provide good type definitions and as I’m only using two methods, I went with a custom thelib.d.ts
file containing declare module 'thelib';
This works with noImplicitAny
in my IDE and on the command line but fails when it is handed over to the pulumi runtime. Not sure if this a Pulumi issue as I would somehow also expect it to fail locally. (i added my d.ts file to the files array and the typeRoots in tsconfig)white-balloon-205
tsconfig.json
.
We just load ts-node
into the Node process to compile-on-module-load .ts
files. It should be reading the tsconfig.json
to decide what TypeScript compilation flags to pass.rhythmic-finland-36256
09/30/2019, 3:45 PMnpx tsc -p tsconfig.json
mssql.d.ts
file and issue the same tsc
command.{
"compileOnSave": true,
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true,
"typeRoots": [
"node_modules/@types/",
"./typings/mssql.d.ts"
]
},
"files": [
"index.ts",
"dummy.ts",
"typings/mssql.d.ts",
"mssql-tasks.ts",
"mssql-serviceuser.ts"
]
}
declare module 'mssql';
should work if I’m using noImplicitAny
as I’m somehow not defining the types explicitly.noImplicitAny
and those simple declarations. https://github.com/Microsoft/TypeScript/issues/15031TSError: ⨯ Unable to compile TypeScript:
mssql-tasks.ts(1,22): error TS7016: Could not find a declaration file for module 'mssql'. '/Users/ajaegle/dev/evals/pulumi-tests/testing-dynamic-provider/node_modules/mssql/index.js' implicitly has an 'any' type.
Try `npm install @types/mssql` if it exists or add a new declaration (.d.ts) file containing `declare module 'mssql';
typeRoots
which must point to a directory similar to node_modules/@types
.typings/<module-name>/<jsfilename>.d.ts
and the following typeRoots
it works:
"typeRoots": [
"node_modules/@types/",
"./typings/"
]