Skip to content

Commit d2b32b4

Browse files
authored
Ensure type/namespaceish statics are included in the list of namespace merge members (#38920)
* Ensure type/namespaceish statics are included in the list of namespace merge members * Simplit into two lines * Update baseline post-merge
1 parent 2d6d5db commit d2b32b4

5 files changed

+75
-1
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6510,7 +6510,8 @@ namespace ts {
65106510
}
65116511

65126512
function isNamespaceMember(p: Symbol) {
6513-
return !(p.flags & SymbolFlags.Prototype || p.escapedName === "prototype" || p.valueDeclaration && isClassLike(p.valueDeclaration.parent));
6513+
return !!(p.flags & (SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias)) ||
6514+
!(p.flags & SymbolFlags.Prototype || p.escapedName === "prototype" || p.valueDeclaration && isClassLike(p.valueDeclaration.parent));
65146515
}
65156516

65166517
function serializeAsClass(symbol: Symbol, localName: string, modifierFlags: ModifierFlags) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//// [source.js]
2+
export class Clazz {
3+
static method() { }
4+
}
5+
6+
Clazz.method.prop = 5;
7+
8+
//// [source.js]
9+
"use strict";
10+
Object.defineProperty(exports, "__esModule", { value: true });
11+
exports.Clazz = void 0;
12+
var Clazz = /** @class */ (function () {
13+
function Clazz() {
14+
}
15+
Clazz.method = function () { };
16+
return Clazz;
17+
}());
18+
exports.Clazz = Clazz;
19+
Clazz.method.prop = 5;
20+
21+
22+
//// [source.d.ts]
23+
export class Clazz {
24+
}
25+
export namespace Clazz {
26+
function method(): void;
27+
namespace method {
28+
const prop: number;
29+
}
30+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/conformance/jsdoc/declarations/source.js ===
2+
export class Clazz {
3+
>Clazz : Symbol(Clazz, Decl(source.js, 0, 0), Decl(source.js, 2, 1))
4+
5+
static method() { }
6+
>method : Symbol(Clazz.method, Decl(source.js, 0, 20), Decl(source.js, 4, 6))
7+
}
8+
9+
Clazz.method.prop = 5;
10+
>Clazz.method.prop : Symbol(Clazz.method.prop, Decl(source.js, 2, 1))
11+
>Clazz.method : Symbol(Clazz.method, Decl(source.js, 0, 20), Decl(source.js, 4, 6))
12+
>Clazz : Symbol(Clazz, Decl(source.js, 0, 0), Decl(source.js, 2, 1))
13+
>method : Symbol(Clazz.method, Decl(source.js, 0, 20), Decl(source.js, 4, 6))
14+
>prop : Symbol(Clazz.method.prop, Decl(source.js, 2, 1))
15+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/conformance/jsdoc/declarations/source.js ===
2+
export class Clazz {
3+
>Clazz : Clazz
4+
5+
static method() { }
6+
>method : typeof Clazz.method
7+
}
8+
9+
Clazz.method.prop = 5;
10+
>Clazz.method.prop = 5 : 5
11+
>Clazz.method.prop : number
12+
>Clazz.method : typeof Clazz.method
13+
>Clazz : typeof Clazz
14+
>method : typeof Clazz.method
15+
>prop : number
16+
>5 : 5
17+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @target: es5
4+
// @outDir: ./out
5+
// @declaration: true
6+
// @filename: source.js
7+
export class Clazz {
8+
static method() { }
9+
}
10+
11+
Clazz.method.prop = 5;

0 commit comments

Comments
 (0)