Better error messages when Babel fails to parse import = and export =… (#7079)

* Better error messages when Babel fails to parse import = and export = syntax from typescript when using babel-plugin-transform-typescript

* Fixing Test cases

* Ran make fix and broken looong sentence into smaller

* Slight changes to Messages after review with Nicolo & existentialism

* Removed trailing space
This commit is contained in:
Azharuddin
2017-12-21 05:30:36 +05:30
committed by Artem Yavorsky
parent ae3f5b9149
commit 2190e10e9a
3 changed files with 12 additions and 4 deletions

View File

@@ -205,11 +205,19 @@ export default function() {
},
TSImportEqualsDeclaration(path) {
throw path.buildCodeFrameError("`import =` is not supported.");
throw path.buildCodeFrameError(
"`import =` is not supported by @babel/plugin-transform-typescript\n" +
"Please consider using " +
"`import <moduleName> from '<moduleName>';` alongside " +
"Typescript's --allowSyntheticDefaultImports option.",
);
},
TSExportAssignment(path) {
throw path.buildCodeFrameError("`export =` is not supported.");
throw path.buildCodeFrameError(
"`export =` is not supported by @babel/plugin-transform-typescript\n" +
"Please consider using `export <value>;`.",
);
},
TSTypeAssertion(path) {

View File

@@ -1,3 +1,3 @@
{
"throws": "`export =` is not supported."
"throws": "`export =` is not supported by @babel/plugin-transform-typescript\nPlease consider using `export <value>;`."
}

View File

@@ -1,3 +1,3 @@
{
"throws": "`import =` is not supported."
"throws": "`import =` is not supported by @babel/plugin-transform-typescript\nPlease consider using `import <moduleName> from '<moduleName>';` alongside Typescript's --allowSyntheticDefaultImports option."
}