-
Notifications
You must be signed in to change notification settings - Fork 129
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
Fix ts extract support #187
Conversation
Since version 2.3.7 ts extract support is broken, reason beeing the ecmaFeatures jsx set to true also in case of ts extension. Added an if case to set this to false for ts, and leave it to true for jsx.
Do you have an example of a file that breaks? We have unit tests that verify a plain |
For example: https://github.com/rubenv/angular-gettext-tools/blob/master/test/fixtures/ts.ts Tested here: angular-gettext-tools/test/extract_extensions.js Lines 111 to 125 in ff2337e
|
This fixes the following reported error #181 Can you please try with the following file? angular.module("myApp").controller("helloController", (gettext) => {
const castedVar: any = <any> gettext("Hello");
gettext(); // Should be ignored.
}); |
Yes, that seems to be the problem. Could you please add that to the test fixture and unit test? That way we're sure it never breaks again. Also, instead of adding an extra if/else case, you could just write this: if (extension === 'ts' || extension === 'tsx') {
syntax = tsParser.parse(src, {
sourceType: 'module',
comment: true,
ecmaFeatures: {
jsx: extension === 'tsx'
}
});
} else { Thanks for submitting this! |
Sure sounds good, fixes are coming :) |
d5b2388
to
bbd43a3
Compare
In addition, refactor a bit in order to remove an if/else construct
bbd43a3
to
0ab52fb
Compare
Excellent fix, can go in now that we've got a test case. |
Thanks for being very quick about this! :) |
Released to NPM as |
Since version 2.3.7 ts extract support is broken, reason beeing the ecmaFeatures jsx set to true also in case of ts extension.
Added an if case to set this to false for ts, and leave it to true for jsx.