Skip to content

Commit

Permalink
resolve #2140, update bit-javascript to support "import { x as y }" s…
Browse files Browse the repository at this point in the history
…yntax (#2142)
  • Loading branch information
davidfirst authored Nov 18, 2019
1 parent ef485ee commit e6c6367
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 82 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]

- [#2140](https://github.com/teambit/bit/issues/2140) update bit-javascript to support `import { x as y }` syntax

## [14.4.4-dev.4] - 2019-11-18

- [#2132](https://github.com/teambit/bit/issues/2132) fix compiler import to install peer dependencies
Expand Down
26 changes: 26 additions & 0 deletions e2e/typescript/typescript.e2e.3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,32 @@ describe('typescript', function() {
expect(result.trim()).to.equal('got is-type and got is-string and got foo');
});
});
// tests https://github.com/teambit/bit/issues/2140
describe('using syntax of "import { x as y }', () => {
let tscResult;
before(() => {
helper.scopeHelper.setNewLocalAndRemoteScopes();
helper.scopeHelper.getClonedLocalScope(scopeWithTypescriptCompiler);
helper.scopeHelper.addRemoteScope();
helper.fs.outputFile('foo.ts', 'export function foo(){}');
helper.fs.outputFile('bar.ts', 'import { foo as foo1 } from "./foo"; console.log(foo1);');
helper.command.addComponent('foo.ts');
helper.command.addComponent('bar.ts');
helper.command.tagAllComponents();
helper.command.exportAllComponents();
helper.scopeHelper.reInitLocalScope();
helper.scopeHelper.addRemoteScope();
helper.scopeHelper.addGlobalRemoteScope();
helper.command.importComponent('bar');
const tscPath = helper.general.installAndGetTypeScriptCompilerDir();
const barFile = path.join(helper.scopes.localPath, 'components/bar/bar.ts');
tscResult = helper.general.runWithTryCatch(`tsc ${barFile}`, tscPath);
});
it('should not throw an error when running tsc on the imported files with the generated links', () => {
// in case of compilation error it throws an exception
expect(tscResult.trim()).to.equal('');
});
});
});
describe('react style => .tsx extension', () => {
if (process.env.APPVEYOR === 'True') {
Expand Down
Loading

0 comments on commit e6c6367

Please sign in to comment.