having this some.js file
export function myFunc(a, b) {
return a.asdf + b;
}
I want to be able to write something like this let’s say in some.d.ts file
export declare function myFunc(a: number, b: number): number;
then run ‘npx tsc’ command which will give me ‘asdf is not a member of type number’,
but right now i get errors saying “parameter a implicitly has any type”.
I have this tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"skipLibCheck": false,
},
"include": ["**/*.js", "**/*.d.ts"]
}
Is it that I miss some ts options or I should declare types in .d.ts differently? If it is impossible, what is the general way to program in js but having typings and not in one global.d.ts file?
I also tried
declare namespace some {
export function myFunc(a: number, b: number): number;
}
and
declare module "some" {
export function myFunc(a: number, b: number): number;
}
Valentine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.