Plugin does not recognize custom typings
Issue
There are some packages that don't have types, so I created an index.d.ts file then I declared them there. It works fine when the source is compiled locally but when I'm trying to run any serverless command, it stucks with the following error:
Could not find a declaration file for module ... implicitly has an 'any' type. Try npm install ... if it exists or add a new declaration (.d.ts) file containing declare module ...;
TS Config
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"lib": [
"es2016",
"dom"
],
"outDir": ".build",
"rootDir": "./",
"removeComments": true,
"preserveConstEnums": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": false,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"inlineSourceMap": true,
"inlineSources": true
},
"exclude": [
"node_modules",
"src/types"
],
"typeRoots": [
"node_modules/@types",
"src/types"
]
}
@slnz00 were you been able to fix this? I'm running into the same issue.
Oh nevermind! I just fixed my issue following this comment: https://github.com/prisma/serverless-plugin-typescript/issues/92#issuecomment-400984161
@andreyvital Does this issue need more attention or can I close this in favour of #92?
same to you
I resolved this with typeRoots. The typeRoots all paths are relative to the tsconfig.json. My tsconfig.json is below
{
"compilerOptions": {
"typeRoots": ["./src/typings/", "./node_modules/@types/"],
"module": "commonjs",
.....
}
}
project directory struct
project
-- src/typings/global/index.d.ts
....