Reputation: 5487
Problem:
I'm using a scoped package (i.e. @ews/ntlm-client
) that doesn't have built-in type definitions. I created custom type definitions locally in a main tsconfig.json
, and then used an extended tsconfig.json
. But VSCode complains the extended tsconfig.json
cannot find the definitions for the scoped package.
What I've Tried:
I created a type definition and placed it in <baseurl>\typedefs\@types\@ews\ntlm-client\index.d.ts
:
declare module '@ewsjs/ntlm-client' {
function createType1Message(workstation?: string, domain?: string): string;
function decodeType2Message(wwwAuthenticate?: string | null): any;
function createType3Message(type2msg: any, username?: string, password?: string, workstation?: string, domain?: string): string;
}
I added the type definitions folder to my <baseurl>\tsconfig.json
. Do note I'm not running the tsc
transpiler as I'm coding in JS, not TS:
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"lib": ["ES2019"],
"module": "CommonJS",
"target": "ES2019",
"noEmit": true,
"typeRoots": ["./node_modules/@types", "./typedefs/@types"]
}
}
And then extended the tsconfig using <baseurl>\a\b\tsconfig.json
:
{
"extends": "../../tsconfig.json"
}
But I'm getting the following Visual Studio Code error in my <baseurl>\a\b\tsconfig.json
:
Why is this happening? I also have type definitions for other modules in my custom @types folder, but they don't seem to throw the same error.
I also note that my main <baseurl>\tsconfig.json
does not seem to have this error.
Upvotes: 1
Views: 1172
Reputation: 5487
The definitions for Scoped Packages have a different file name convention:
remove the prefix @, and change the forward slash to a double-underscore
E.g. The types for @types/@babel/traverse
should be found in @types/babel__traverse/index.d.ts
.
Upvotes: 2