Skip to content

Commit

Permalink
Merge pull request #187 from IvanoAlvino/fix-ts-parsing
Browse files Browse the repository at this point in the history
Fix ts extract support
  • Loading branch information
rubenv authored Aug 7, 2018
2 parents 7a03fac + 0ab52fb commit 3ce45d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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.
});

0 comments on commit 3ce45d3

Please sign in to comment.