Skip to content

Commit

Permalink
feat: enable parsing TypeScript sources
Browse files Browse the repository at this point in the history
  • Loading branch information
JC Estibariz committed Apr 26, 2024
1 parent ca4d68a commit 07b16e6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/cli/__tests__/main-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('main', () => {
scanDir.mockResolvedValue();

return main(true, undefined, []).then(() => {
expect(scanDir.mock.calls).toEqual([[empty, '/foo', /\.jsx?$/]]);
expect(scanDir.mock.calls).toEqual([[empty, '/foo', /\.[jt]sx?$/]]);
expect(updateLocale.mock.calls).toEqual([
['en', '/foo/{locale}', empty, anyFunction, true, true],
['fr', '/foo/{locale}', empty, anyFunction, true, true],
Expand All @@ -62,7 +62,7 @@ describe('main', () => {
scanDir.mockResolvedValue();

return main(false, undefined, []).then(() => {
expect(scanDir.mock.calls).toEqual([[empty, '/foo', /\.jsx?$/]]);
expect(scanDir.mock.calls).toEqual([[empty, '/foo', /\.[jt]sx?$/]]);
expect(updateLocale.mock.calls).toEqual([['en', '/foo/{locale}', empty, anyFunction, false, true]]);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/__tests__/parseJS-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('parseJS', () => {
{
sourceFilename: 'test.js',
sourceType: 'module',
plugins: ['jsx', 'classProperties', 'doExpressions', 'throwExpressions'],
plugins: ['jsx', 'typescript', 'classProperties', 'doExpressions', 'throwExpressions'],
},
],
]);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import parseJS from './parseJS';
import scanDir from './scanDir';
import updateLocale from './updateLocale';

const extensions = /\.jsx?$/;
const extensions = /\.[jt]sx?$/;

export default (clean, locale, sources) => {
const {hashLength, sourcePath, catalogPath, locales, buildKey} = loadConfig();
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/parseJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default (strings, path) =>
const ast = parser.parse(text, {
sourceFilename: path,
sourceType: 'module',
plugins: ['jsx', 'classProperties', 'doExpressions', 'throwExpressions'],
plugins: ['jsx', 'typescript', 'classProperties', 'doExpressions', 'throwExpressions'],
});

const localNames = {};
Expand Down

0 comments on commit 07b16e6

Please sign in to comment.