diff --git a/lib/extract.js b/lib/extract.js index d66efec..944eceb 100644 --- a/lib/extract.js +++ b/lib/extract.js @@ -198,20 +198,12 @@ var Extractor = (function () { var syntax; var extension = filename.split('.').pop(); try { - if (extension === 'ts') { + if (extension === 'ts' || extension === 'tsx') { syntax = tsParser.parse(src, { sourceType: 'module', comment: true, ecmaFeatures: { - jsx: false - } - }); - } else if (extension === 'tsx') { - syntax = tsParser.parse(src, { - sourceType: 'module', - comment: true, - ecmaFeatures: { - jsx: true + jsx: extension === 'tsx' } }); } else { diff --git a/test/extract_extensions.js b/test/extract_extensions.js index e112572..5745d3c 100644 --- a/test/extract_extensions.js +++ b/test/extract_extensions.js @@ -114,7 +114,7 @@ describe('Extracting files with different extensions', function () { ]; var catalog = testExtract(files); - assert.equal(catalog.items.length, 2); + assert.equal(catalog.items.length, 3); assert.equal(catalog.items[0].msgid, 'Hello'); assert.equal(catalog.items[0].msgstr, ''); assert.deepEqual(catalog.items[0].references, ['test/fixtures/ts.ts:2']); @@ -122,6 +122,10 @@ describe('Extracting files with different extensions', function () { assert.equal(catalog.items[1].msgid, 'One\nTwo\nThree'); assert.equal(catalog.items[1].msgstr, ''); assert.deepEqual(catalog.items[1].references, ['test/fixtures/ts.ts:3']); + + assert.equal(catalog.items[2].msgid, 'Casted'); + assert.equal(catalog.items[2].msgstr, ''); + assert.deepEqual(catalog.items[2].references, ['test/fixtures/ts.ts:6']); }); it('supports TypeScript .tsx files', function () { diff --git a/test/fixtures/ts.ts b/test/fixtures/ts.ts index 1a6d10a..ef46689 100644 --- a/test/fixtures/ts.ts +++ b/test/fixtures/ts.ts @@ -3,5 +3,6 @@ angular.module("myApp").controller("helloController", (gettext) => { var longString: string = gettext(`One Two Three`); + var castedVar: any = gettext("Casted"); gettext(); // Should be ignored. });