-
Notifications
You must be signed in to change notification settings - Fork 2k
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
registerHelper breaks with Typescript 4.4 #1767
Comments
Can you provide an example reproducing the bug? I mean a minimal but complete js-file, including the import? Does it work when you do?
or
|
Both cases that you provided seem to work. The issue seems to only happen if you import it like so: Here's a minimal ts file that reproduces the problem: import { registerHelper } from 'handlebars';
registerHelper('myHelper', function (value, options) {}); And here's the transpiled version of it "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const handlebars_1 = require("handlebars");
(0, handlebars_1.registerHelper)('myHelper', function (value, options) { }); |
I have the same issue, with named import something breaks handlebars@4.7.7
|
As far as I can tell, the I will create a PR to fix those types. Workaround: always use |
I have similar issue when using typescript > 4.3.X /Users/carlosreta/git/code-generator/test/uxf-seed/node_modules/handlebars/dist/cjs/handlebars/base.js:66 TypeError: Cannot read properties of undefined (reading 'helpers') With typescript 4.3.5 works but with typescript 4.6.2 f.ex. gives this error. |
Fixed it for me. Thanks @jaylinski ! Is this in the docs? If it isn't it should be. Took me 10 mins of random googling to figure this one out. |
I opened a PR that adds an ESM example to the docs: Sadly I doesn't seem to be possible to write a TypeScript definition that forbids importing Handlebars like |
Typescript 4.4 as recently introduced this breaking change: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-4.html#more-compliant-indirect-calls-for-imported-functions
This change breaks the registerHelper function, and possibly other functions as well. Taking the following example code:
This gets transpiled into the following:
Which causes the following error:
This is using the current latest version of Handlebars (4.7.7) and Typescript 4.4.3
The text was updated successfully, but these errors were encountered: