mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fix export of enum with same-named member (#55070)
This commit is contained in:
parent
8f96638692
commit
97ef321fa0
@ -3040,8 +3040,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// (it refers to the constant type of the expression instead)
|
||||
return undefined;
|
||||
}
|
||||
if (isModuleDeclaration(location) && lastLocation && location.name === lastLocation) {
|
||||
// If this is the name of a namespace, skip the parent since it will have is own locals that could
|
||||
if (isModuleOrEnumDeclaration(location) && lastLocation && location.name === lastLocation) {
|
||||
// If lastLocation is the name of a namespace or enum, skip the parent since it will have is own locals that could
|
||||
// conflict.
|
||||
lastLocation = location;
|
||||
location = location.parent;
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
//// [tests/cases/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName.ts] ////
|
||||
|
||||
//// [exportDeclarationForModuleOrEnumWithMemberOfSameName.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/55038
|
||||
|
||||
namespace A {
|
||||
export const A = 0;
|
||||
}
|
||||
|
||||
export { A }
|
||||
|
||||
enum B {
|
||||
B
|
||||
}
|
||||
|
||||
export { B }
|
||||
|
||||
|
||||
//// [exportDeclarationForModuleOrEnumWithMemberOfSameName.js]
|
||||
"use strict";
|
||||
// https://github.com/microsoft/TypeScript/issues/55038
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.B = exports.A = void 0;
|
||||
var A;
|
||||
(function (A_1) {
|
||||
A_1.A = 0;
|
||||
})(A || (exports.A = A = {}));
|
||||
var B;
|
||||
(function (B) {
|
||||
B[B["B"] = 0] = "B";
|
||||
})(B || (exports.B = B = {}));
|
||||
@ -0,0 +1,36 @@
|
||||
//// [tests/cases/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName.ts] ////
|
||||
|
||||
//// [exportDeclarationForModuleOrEnumWithMemberOfSameName.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/55038
|
||||
|
||||
namespace A {
|
||||
export const A = 0;
|
||||
}
|
||||
|
||||
export { A }
|
||||
|
||||
enum B {
|
||||
B
|
||||
}
|
||||
|
||||
export { B }
|
||||
|
||||
|
||||
//// [exportDeclarationForModuleOrEnumWithMemberOfSameName.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/55038
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var A, B;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {// https://github.com/microsoft/TypeScript/issues/55038
|
||||
(function (A_1) {
|
||||
A_1.A = 0;
|
||||
})(A || (exports_1("A", A = {})));
|
||||
(function (B) {
|
||||
B[B["B"] = 0] = "B";
|
||||
})(B || (exports_1("B", B = {})));
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -0,0 +1,16 @@
|
||||
// @target: esnext
|
||||
// @module: commonjs,system
|
||||
// @noTypesAndSymbols: true
|
||||
// https://github.com/microsoft/TypeScript/issues/55038
|
||||
|
||||
namespace A {
|
||||
export const A = 0;
|
||||
}
|
||||
|
||||
export { A }
|
||||
|
||||
enum B {
|
||||
B
|
||||
}
|
||||
|
||||
export { B }
|
||||
Loading…
x
Reference in New Issue
Block a user