Typescript can see my class that I declared in .d.ts file, but not when it's doing a compile
I declared a class in .d.ts
declare class Handlebars {
static compile(s: string): (a: object) => string;
}
And added that file to configurations, so main file can see the class
{
"compilerOptions": {
"allowJs": false
},
"files": [
".d.ts",
"index.ts"
]
}
CodePudding user response:
Try this. You don't import Handlebars
so it can't use it.
.d.ts
declare class Handlebars {
static compile(s: string): (a: object) => string;
}
export { Handlebars };
index.ts
import { Handlebars } from "./.d";
let template = Handlebars.compile("text");
console.log(template({ doesWhat: "rocks" }));