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

Use @babel/parser in TypeScript parser #291

Merged
merged 2 commits into from
Dec 5, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion bin/__tests__/jscodeshift-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,27 @@ describe('jscodeshift CLI', () => {
}
);
});
})
});

describe('--parser=ts', () => {
it('parses TypeScript sources', () => {
const source = createTempFileWith('type Foo = string | string[];');
const transform = createTransformWith(
'api.jscodeshift(fileInfo.source)\nreturn "changed";'
);
return run([
'-t', transform,
'--parser', 'ts',
'--run-in-band',
source,
]).then(
out => {
expect(out[0]).not.toContain('Transformation error');
expect(readFile(source)).toEqual('changed');
}
);
});
});

describe('--parser-config', () => {
it('allows custom parser settings to be passed', () => {
Expand Down
2 changes: 1 addition & 1 deletion parser/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const babylon = require('babylon');
const babylon = require('@babel/parser');
const options = require('./tsOptions');

/**
Expand Down
2 changes: 1 addition & 1 deletion parser/tsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

const _ = require('lodash');
const babylon = require('babylon');
const babylon = require('@babel/parser');
const baseOptions = require('./tsOptions');

const options = _.merge(baseOptions, { plugins: ['jsx'] });
Expand Down