Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw a better error when transforming imported bindings in types (#1…
…3739) * Throw a better error when transforming imported bindings in types * Also type casts * Update error message
- Loading branch information
1 parent
2ffb198
commit 8fb5042
Showing
15 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...in-transform-modules-commonjs/test/fixtures/integration/missing-flow-plugin-deep/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import A from "x"; | ||
|
||
export function fn(x: A.b[2]) { | ||
return A.method(x); | ||
} |
6 changes: 6 additions & 0 deletions
6
...ransform-modules-commonjs/test/fixtures/integration/missing-flow-plugin-deep/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"externalHelpers": true, | ||
"sourceType": "module", | ||
"plugins": ["transform-modules-commonjs", "syntax-flow"], | ||
"throws": "Cannot transform the imported binding \"A\" since it's also used in a type annotation. Please strip type annotations using @babel/preset-typescript or @babel/preset-flow." | ||
} |
3 changes: 3 additions & 0 deletions
3
...ansform-modules-commonjs/test/fixtures/integration/missing-flow-plugin-type-cast/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { A } from "x"; | ||
|
||
var x = ({} : A.b[0]); |
6 changes: 6 additions & 0 deletions
6
...orm-modules-commonjs/test/fixtures/integration/missing-flow-plugin-type-cast/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"externalHelpers": true, | ||
"sourceType": "module", | ||
"plugins": ["transform-modules-commonjs", "syntax-flow"], | ||
"throws": "Cannot transform the imported binding \"A\" since it's also used in a type annotation. Please strip type annotations using @babel/preset-typescript or @babel/preset-flow." | ||
} |
5 changes: 5 additions & 0 deletions
5
...-plugin-transform-modules-commonjs/test/fixtures/integration/missing-flow-plugin/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import A from "x"; | ||
|
||
export function fn(x: A) { | ||
return A.method(x); | ||
} |
6 changes: 6 additions & 0 deletions
6
...gin-transform-modules-commonjs/test/fixtures/integration/missing-flow-plugin/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"externalHelpers": true, | ||
"sourceType": "module", | ||
"plugins": ["transform-modules-commonjs", "syntax-flow"], | ||
"throws": "Cannot transform the imported binding \"A\" since it's also used in a type annotation. Please strip type annotations using @babel/preset-typescript or @babel/preset-flow." | ||
} |
5 changes: 5 additions & 0 deletions
5
...ugin-transform-modules-commonjs/test/fixtures/integration/missing-ts-plugin-deep/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import A from "x"; | ||
|
||
export function fn(x: A.b[2]) { | ||
return A.method(x); | ||
} |
6 changes: 6 additions & 0 deletions
6
...-transform-modules-commonjs/test/fixtures/integration/missing-ts-plugin-deep/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"externalHelpers": true, | ||
"sourceType": "module", | ||
"plugins": ["transform-modules-commonjs", "syntax-typescript"], | ||
"throws": "Cannot transform the imported binding \"A\" since it's also used in a type annotation. Please strip type annotations using @babel/preset-typescript or @babel/preset-flow." | ||
} |
3 changes: 3 additions & 0 deletions
3
...dules-commonjs/test/fixtures/integration/missing-ts-plugin-type-assertion-legacy/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { A } from "x"; | ||
|
||
var x = {} as A.b[0]; |
6 changes: 6 additions & 0 deletions
6
...s-commonjs/test/fixtures/integration/missing-ts-plugin-type-assertion-legacy/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"externalHelpers": true, | ||
"sourceType": "module", | ||
"plugins": ["transform-modules-commonjs", "syntax-typescript"], | ||
"throws": "Cannot transform the imported binding \"A\" since it's also used in a type annotation. Please strip type annotations using @babel/preset-typescript or @babel/preset-flow." | ||
} |
3 changes: 3 additions & 0 deletions
3
...form-modules-commonjs/test/fixtures/integration/missing-ts-plugin-type-assertion/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { A } from "x"; | ||
|
||
var x = <A.b[0]> {}; |
6 changes: 6 additions & 0 deletions
6
...-modules-commonjs/test/fixtures/integration/missing-ts-plugin-type-assertion/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"externalHelpers": true, | ||
"sourceType": "module", | ||
"plugins": ["transform-modules-commonjs", "syntax-typescript"], | ||
"throws": "Cannot transform the imported binding \"A\" since it's also used in a type annotation. Please strip type annotations using @babel/preset-typescript or @babel/preset-flow." | ||
} |
5 changes: 5 additions & 0 deletions
5
...el-plugin-transform-modules-commonjs/test/fixtures/integration/missing-ts-plugin/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import A from "x"; | ||
|
||
export function fn(x: A) { | ||
return A.method(x); | ||
} |
6 changes: 6 additions & 0 deletions
6
...lugin-transform-modules-commonjs/test/fixtures/integration/missing-ts-plugin/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"externalHelpers": true, | ||
"sourceType": "module", | ||
"plugins": ["transform-modules-commonjs", "syntax-typescript"], | ||
"throws": "Cannot transform the imported binding \"A\" since it's also used in a type annotation. Please strip type annotations using @babel/preset-typescript or @babel/preset-flow." | ||
} |