-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript typings #5
Comments
You can do it if you want, and submit a PR ;) |
Hi, for people like me who can't bear using an any-typed library : declare module 'handlebars-async-helpers' {
import * as hbs from 'handlebars';
type Handlebars = typeof hbs;
function asyncHelpers(handlebars: Handlebars): asyncHelpers.AsyncHandlebars;
namespace asyncHelpers {
// At least an empty namespace is necessary for allowing "import * as" when allowSyntheticDefaultImports is
// false. But we'll export our custom types too, so they can be imported too, they can be useful.
type AsyncTemplateDelegate<Context> = (context: Context, options?: hbs.RuntimeOptions) => Promise<string>;
type AsyncHandlebars = Omit<Handlebars, 'compile'> & {
// CompileOptions is not explicitly imported because it's transient in the scope due to how it's declared in
// Handlebars.
compile<Context = unknown>(input: any, options?: CompileOptions): AsyncTemplateDelegate<Context>;
}
}
export = asyncHelpers;
} Put this in a {
"include": ["./stubs/**.d.ts"] // That's where I place my .d.ts for untyped libraries
} If you have allowSyntheticDefaultImports enabled: Note to the author: I don't have time to make a PR but feel free to include this in your project if you want. Basically you'll just have to add a |
Handlebars contains TypeScript typings which totally get lost by using this module. Could you add typings that extend handlebars?
The text was updated successfully, but these errors were encountered: