mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Fix mistakenly disallowed default export under erasableSyntaxOnly (#61210)
This commit is contained in:
@@ -47974,7 +47974,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return;
|
||||
}
|
||||
|
||||
if (compilerOptions.erasableSyntaxOnly && !(node.flags & NodeFlags.Ambient)) {
|
||||
if (compilerOptions.erasableSyntaxOnly && node.isExportEquals && !(node.flags & NodeFlags.Ambient)) {
|
||||
error(node, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled);
|
||||
}
|
||||
const container = node.parent.kind === SyntaxKind.SourceFile ? node.parent : node.parent.parent as ModuleDeclaration;
|
||||
|
||||
@@ -104,4 +104,9 @@ index.ts(28,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOn
|
||||
==== other.d.cts (0 errors) ====
|
||||
declare function foo(): void;
|
||||
export = foo;
|
||||
|
||||
|
||||
==== esm.mts (0 errors) ====
|
||||
const foo = 1234;
|
||||
export default foo;
|
||||
|
||||
@@ -74,6 +74,11 @@ export = foo;
|
||||
//// [other.d.cts]
|
||||
declare function foo(): void;
|
||||
export = foo;
|
||||
|
||||
|
||||
//// [esm.mts]
|
||||
const foo = 1234;
|
||||
export default foo;
|
||||
|
||||
|
||||
//// [index.js]
|
||||
@@ -119,3 +124,6 @@ var MyClassOk = /** @class */ (function () {
|
||||
"use strict";
|
||||
var foo = require("./other.cjs");
|
||||
module.exports = foo;
|
||||
//// [esm.mjs]
|
||||
var foo = 1234;
|
||||
export default foo;
|
||||
|
||||
@@ -133,3 +133,11 @@ declare function foo(): void;
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(other.d.cts, 0, 0))
|
||||
|
||||
|
||||
=== esm.mts ===
|
||||
const foo = 1234;
|
||||
>foo : Symbol(foo, Decl(esm.mts, 0, 5))
|
||||
|
||||
export default foo;
|
||||
>foo : Symbol(foo, Decl(esm.mts, 0, 5))
|
||||
|
||||
|
||||
@@ -179,3 +179,15 @@ export = foo;
|
||||
>foo : () => void
|
||||
> : ^^^^^^
|
||||
|
||||
|
||||
=== esm.mts ===
|
||||
const foo = 1234;
|
||||
>foo : 1234
|
||||
> : ^^^^
|
||||
>1234 : 1234
|
||||
> : ^^^^
|
||||
|
||||
export default foo;
|
||||
>foo : 1234
|
||||
> : ^^^^
|
||||
|
||||
|
||||
@@ -65,4 +65,9 @@ index.d.ts(1,1): error TS1046: Top-level declarations in .d.ts files must start
|
||||
==== other.d.cts (0 errors) ====
|
||||
declare function foo(): void;
|
||||
export = foo;
|
||||
|
||||
|
||||
==== esm.d.mts (0 errors) ====
|
||||
declare const foo = 1234;
|
||||
export default foo;
|
||||
|
||||
@@ -112,3 +112,11 @@ declare function foo(): void;
|
||||
export = foo;
|
||||
>foo : Symbol(foo, Decl(other.d.cts, 0, 0))
|
||||
|
||||
|
||||
=== esm.d.mts ===
|
||||
declare const foo = 1234;
|
||||
>foo : Symbol(foo, Decl(esm.d.mts, 0, 13))
|
||||
|
||||
export default foo;
|
||||
>foo : Symbol(foo, Decl(esm.d.mts, 0, 13))
|
||||
|
||||
|
||||
@@ -154,3 +154,15 @@ export = foo;
|
||||
>foo : () => void
|
||||
> : ^^^^^^
|
||||
|
||||
|
||||
=== esm.d.mts ===
|
||||
declare const foo = 1234;
|
||||
>foo : 1234
|
||||
> : ^^^^
|
||||
>1234 : 1234
|
||||
> : ^^^^
|
||||
|
||||
export default foo;
|
||||
>foo : 1234
|
||||
> : ^^^^
|
||||
|
||||
|
||||
@@ -74,3 +74,8 @@ export = foo;
|
||||
// @filename: other.d.cts
|
||||
declare function foo(): void;
|
||||
export = foo;
|
||||
|
||||
|
||||
// @filename: esm.mts
|
||||
const foo = 1234;
|
||||
export default foo;
|
||||
|
||||
@@ -66,3 +66,8 @@ export = foo;
|
||||
// @filename: other.d.cts
|
||||
declare function foo(): void;
|
||||
export = foo;
|
||||
|
||||
|
||||
// @filename: esm.d.mts
|
||||
declare const foo = 1234;
|
||||
export default foo;
|
||||
|
||||
Reference in New Issue
Block a user