#How do I type the export of a dynamic import?
2 messages · Page 1 of 1 (latest)
@turbid gust You may just have to cast it - I don't think TS understands dynamic imports with string interpolation.
2 messages · Page 1 of 1 (latest)
// recipes.ys
class Recipe {
constructor(readonly name: string) { }
get recipe() {
return import(`./recipes/${this.name}.json`)
.then(module => module.default);
}
}
``` ```ts
//types.d.ts
declare module 'recipes/*.json' {
const x: string;
export = x;
}
@turbid gust You may just have to cast it - I don't think TS understands dynamic imports with string interpolation.