Throw a better error when transforming imported bindings in types (#13739)
* Throw a better error when transforming imported bindings in types * Also type casts * Update error message
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import A from "x";
|
||||
|
||||
export function fn(x: A.b[2]) {
|
||||
return A.method(x);
|
||||
}
|
||||
@@ -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."
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { A } from "x";
|
||||
|
||||
var x = ({} : A.b[0]);
|
||||
@@ -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."
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import A from "x";
|
||||
|
||||
export function fn(x: A) {
|
||||
return A.method(x);
|
||||
}
|
||||
@@ -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."
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import A from "x";
|
||||
|
||||
export function fn(x: A.b[2]) {
|
||||
return A.method(x);
|
||||
}
|
||||
@@ -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."
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { A } from "x";
|
||||
|
||||
var x = {} as A.b[0];
|
||||
@@ -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."
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { A } from "x";
|
||||
|
||||
var x = <A.b[0]> {};
|
||||
@@ -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."
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import A from "x";
|
||||
|
||||
export function fn(x: A) {
|
||||
return A.method(x);
|
||||
}
|
||||
@@ -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."
|
||||
}
|
||||
Reference in New Issue
Block a user