Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Import guarding now short circuits import searching after the first v…
Browse files Browse the repository at this point in the history
…alid tcomb import instance is resolved. This provides higher efficiency whilst also preventing strange bug cases that could occur
  • Loading branch information
gcanti committed May 15, 2016
1 parent 1cb8e91 commit 41a102d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -291,7 +291,7 @@ exports['default'] = function (_ref) {

ImportDeclaration: {
exit: function exit(node) {
if (tcombLibraries.hasOwnProperty(node.source.value)) {
if (!tcombLocalName && tcombLibraries.hasOwnProperty(node.source.value)) {
tcombLocalName = getTcombLocalNameFromImports(node);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -22,7 +22,7 @@
"babel-eslint": "4.1.8",
"eslint": "1.10.3",
"mocha": "^2.2.5",
"tcomb": "^2.5.0"
"tcomb": "^3.0.0"
},
"tags": [
"babel-plugin",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -312,7 +312,7 @@ export default function ({ Plugin, types: t }) {

ImportDeclaration: {
exit(node) {
if (tcombLibraries.hasOwnProperty(node.source.value)) {
if (!tcombLocalName && tcombLibraries.hasOwnProperty(node.source.value)) {
tcombLocalName = getTcombLocalNameFromImports(node);
}
}
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/import/actual.js
@@ -1,4 +1,5 @@
import tc from 'tcomb';
import { propTypes } from 'tcomb-react';

function foo(x: ?tc.String) {
return x || 'Empty';
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/import/expected.js
@@ -1,4 +1,5 @@
import tc from 'tcomb';
import { propTypes } from 'tcomb-react';

function foo(x: ?tc.String) {
tc.assert(tc.maybe(tc.String).is(x), 'Invalid argument x (expected a ' + tc.getTypeName(tc.maybe(tc.String)) + ')');
Expand Down

0 comments on commit 41a102d

Please sign in to comment.