fix(typescript): look at source to determine export = statement (#1868)
This commit is contained in:
1 parent
faf2ac5f9e
commit
83c5253429
3 files changed
+40
-1
No files matched your search
+14
-1
@@ -3386,7 +3386,20 @@ function printExportDeclaration(path, options, print) {
|
||||
const parts = ["export "];
|
||||
|
||||
if (decl["default"] || decl.type === "ExportDefaultDeclaration") {
|
||||
parts.push("default ");
|
||||
// Temp fix, delete after https://github.com/eslint/typescript-eslint-parser/issues/304
|
||||
if (
|
||||
decl.declaration &&
|
||||
/=/.test(
|
||||
options.originalText.slice(
|
||||
util.locStart(decl),
|
||||
util.locStart(decl.declaration)
|
||||
)
|
||||
)
|
||||
) {
|
||||
parts.push("= ");
|
||||
} else {
|
||||
parts.push("default ");
|
||||
}
|
||||
}
|
||||
|
||||
parts.push(
|
||||
|
||||
@@ -8,3 +8,22 @@ export function match(): string /* the matching pattern */
|
||||
a;
|
||||
|
||||
`;
|
||||
|
||||
exports[`export.ts 1`] = `
|
||||
declare module "hello" {
|
||||
export default Hello;
|
||||
}
|
||||
|
||||
declare module "hello" {
|
||||
export = Hello;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
declare module "hello" {
|
||||
export default Hello;
|
||||
}
|
||||
|
||||
declare module "hello" {
|
||||
export = Hello;
|
||||
}
|
||||
|
||||
`;
|
||||
@@ -0,0 +1,7 @@
|
||||
declare module "hello" {
|
||||
export default Hello;
|
||||
}
|
||||
|
||||
declare module "hello" {
|
||||
export = Hello;
|
||||
}
|
||||
Reference in new issue
Block a user