Skip to content
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

Merged
merged 3 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ var Extractor = (function () {
sourceType: 'module',
comment: true,
ecmaFeatures: {
jsx: true
jsx: extension === 'tsx'
}
});
} else {
Expand Down
14 changes: 9 additions & 5 deletions test/extract_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,18 @@ describe('Extracting files with different extensions', function () {
];
var catalog = testExtract(files);

assert.equal(catalog.items.length, 2);
assert.equal(catalog.items[0].msgid, 'Hello');
assert.equal(catalog.items.length, 3);
assert.equal(catalog.items[0].msgid, 'Casted');
assert.equal(catalog.items[0].msgstr, '');
assert.deepEqual(catalog.items[0].references, ['test/fixtures/ts.ts:2']);
assert.deepEqual(catalog.items[0].references, ['test/fixtures/ts.ts:6']);

assert.equal(catalog.items[1].msgid, 'One\nTwo\nThree');
assert.equal(catalog.items[1].msgid, 'Hello');
assert.equal(catalog.items[1].msgstr, '');
assert.deepEqual(catalog.items[1].references, ['test/fixtures/ts.ts:3']);
assert.deepEqual(catalog.items[1].references, ['test/fixtures/ts.ts:2']);

assert.equal(catalog.items[2].msgid, 'One\nTwo\nThree');
assert.equal(catalog.items[2].msgstr, '');
assert.deepEqual(catalog.items[2].references, ['test/fixtures/ts.ts:3']);
});

it('supports TypeScript .tsx files', function () {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ angular.module("myApp").controller("helloController", (gettext) => {
var longString: string = gettext(`One
Two
Three`);
var castedVar: any = <any> gettext("Casted");
gettext(); // Should be ignored.
});