Skip to content

Commit e809c04

Browse files
TypeScript BotAndarist
TypeScript Bot
andauthored
🤖 Pick PR #59110 (Fixed a regression in declaration e...) into release-5.5 (#59206)
Co-authored-by: Mateusz BurzyÅ„ski <[email protected]>
1 parent fea13dd commit e809c04

File tree

5 files changed

+232
-1
lines changed

5 files changed

+232
-1
lines changed

‎src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8824,7 +8824,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
88248824
);
88258825
}
88268826
if (isNamedDeclaration(node) && node.name.kind === SyntaxKind.ComputedPropertyName && !isLateBindableName(node.name)) {
8827-
if (!(context.flags & NodeBuilderFlags.AllowUnresolvedNames && hasDynamicName(node) && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & TypeFlags.Any)) {
8827+
if (!hasDynamicName(node)) {
8828+
return visitEachChild(node, visitExistingNodeTreeSymbols);
8829+
}
8830+
if (!(context.flags & NodeBuilderFlags.AllowUnresolvedNames && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & TypeFlags.Any)) {
88288831
return undefined;
88298832
}
88308833
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//// [tests/cases/compiler/declarationEmitComputedPropertyName1.ts] ////
2+
3+
//// [declarationEmitComputedPropertyName1.ts]
4+
// https://github.com/microsoft/TypeScript/issues/59107
5+
6+
declare function create<T extends {}>(): T;
7+
8+
export const c = create<{
9+
data: {
10+
["a_b_c"]: string;
11+
["sss"]: string;
12+
s_d: string;
13+
queryData?: string;
14+
["foo bar"]: string;
15+
};
16+
["a_b_c"]: string;
17+
}>();
18+
19+
export interface IData {
20+
["a_b_c"]: string;
21+
nested: {
22+
["d_e_f"]: string;
23+
value: string;
24+
["qwe rty"]: string;
25+
};
26+
}
27+
28+
29+
30+
31+
//// [declarationEmitComputedPropertyName1.d.ts]
32+
export declare const c: {
33+
data: {
34+
["a_b_c"]: string;
35+
["sss"]: string;
36+
s_d: string;
37+
queryData?: string;
38+
["foo bar"]: string;
39+
};
40+
a_b_c: string;
41+
};
42+
export interface IData {
43+
["a_b_c"]: string;
44+
nested: {
45+
["d_e_f"]: string;
46+
value: string;
47+
["qwe rty"]: string;
48+
};
49+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//// [tests/cases/compiler/declarationEmitComputedPropertyName1.ts] ////
2+
3+
=== declarationEmitComputedPropertyName1.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/59107
5+
6+
declare function create<T extends {}>(): T;
7+
>create : Symbol(create, Decl(declarationEmitComputedPropertyName1.ts, 0, 0))
8+
>T : Symbol(T, Decl(declarationEmitComputedPropertyName1.ts, 2, 24))
9+
>T : Symbol(T, Decl(declarationEmitComputedPropertyName1.ts, 2, 24))
10+
11+
export const c = create<{
12+
>c : Symbol(c, Decl(declarationEmitComputedPropertyName1.ts, 4, 12))
13+
>create : Symbol(create, Decl(declarationEmitComputedPropertyName1.ts, 0, 0))
14+
15+
data: {
16+
>data : Symbol(data, Decl(declarationEmitComputedPropertyName1.ts, 4, 25))
17+
18+
["a_b_c"]: string;
19+
>["a_b_c"] : Symbol(["a_b_c"], Decl(declarationEmitComputedPropertyName1.ts, 5, 9))
20+
>"a_b_c" : Symbol(["a_b_c"], Decl(declarationEmitComputedPropertyName1.ts, 5, 9))
21+
22+
["sss"]: string;
23+
>["sss"] : Symbol(["sss"], Decl(declarationEmitComputedPropertyName1.ts, 6, 22))
24+
>"sss" : Symbol(["sss"], Decl(declarationEmitComputedPropertyName1.ts, 6, 22))
25+
26+
s_d: string;
27+
>s_d : Symbol(s_d, Decl(declarationEmitComputedPropertyName1.ts, 7, 20))
28+
29+
queryData?: string;
30+
>queryData : Symbol(queryData, Decl(declarationEmitComputedPropertyName1.ts, 8, 16))
31+
32+
["foo bar"]: string;
33+
>["foo bar"] : Symbol(["foo bar"], Decl(declarationEmitComputedPropertyName1.ts, 9, 23))
34+
>"foo bar" : Symbol(["foo bar"], Decl(declarationEmitComputedPropertyName1.ts, 9, 23))
35+
36+
};
37+
["a_b_c"]: string;
38+
>["a_b_c"] : Symbol(["a_b_c"], Decl(declarationEmitComputedPropertyName1.ts, 11, 4))
39+
>"a_b_c" : Symbol(["a_b_c"], Decl(declarationEmitComputedPropertyName1.ts, 11, 4))
40+
41+
}>();
42+
43+
export interface IData {
44+
>IData : Symbol(IData, Decl(declarationEmitComputedPropertyName1.ts, 13, 5))
45+
46+
["a_b_c"]: string;
47+
>["a_b_c"] : Symbol(IData["a_b_c"], Decl(declarationEmitComputedPropertyName1.ts, 15, 24))
48+
>"a_b_c" : Symbol(IData["a_b_c"], Decl(declarationEmitComputedPropertyName1.ts, 15, 24))
49+
50+
nested: {
51+
>nested : Symbol(IData.nested, Decl(declarationEmitComputedPropertyName1.ts, 16, 20))
52+
53+
["d_e_f"]: string;
54+
>["d_e_f"] : Symbol(["d_e_f"], Decl(declarationEmitComputedPropertyName1.ts, 17, 11))
55+
>"d_e_f" : Symbol(["d_e_f"], Decl(declarationEmitComputedPropertyName1.ts, 17, 11))
56+
57+
value: string;
58+
>value : Symbol(value, Decl(declarationEmitComputedPropertyName1.ts, 18, 22))
59+
60+
["qwe rty"]: string;
61+
>["qwe rty"] : Symbol(["qwe rty"], Decl(declarationEmitComputedPropertyName1.ts, 19, 18))
62+
>"qwe rty" : Symbol(["qwe rty"], Decl(declarationEmitComputedPropertyName1.ts, 19, 18))
63+
64+
};
65+
}
66+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
//// [tests/cases/compiler/declarationEmitComputedPropertyName1.ts] ////
2+
3+
=== declarationEmitComputedPropertyName1.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/59107
5+
6+
declare function create<T extends {}>(): T;
7+
>create : <T extends {}>() => T
8+
> : ^ ^^^^^^^^^ ^^^^^^^
9+
10+
export const c = create<{
11+
>c : { data: { ["a_b_c"]: string; ["sss"]: string; s_d: string; queryData?: string; ["foo bar"]: string; }; a_b_c: string; }
12+
> : ^^^^^^^^ ^^^^^^^^^ ^^^
13+
>create<{ data: { ["a_b_c"]: string; ["sss"]: string; s_d: string; queryData?: string; ["foo bar"]: string; }; ["a_b_c"]: string;}>() : { data: { ["a_b_c"]: string; ["sss"]: string; s_d: string; queryData?: string; ["foo bar"]: string; }; a_b_c: string; }
14+
> : ^^^^^^^^ ^^^^^^^^^ ^^^
15+
>create : <T extends {}>() => T
16+
> : ^ ^^^^^^^^^ ^^^^^^^
17+
18+
data: {
19+
>data : { a_b_c: string; sss: string; s_d: string; queryData?: string; "foo bar": string; }
20+
> : ^^^^^^^^^ ^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^
21+
22+
["a_b_c"]: string;
23+
>["a_b_c"] : string
24+
> : ^^^^^^
25+
>"a_b_c" : "a_b_c"
26+
> : ^^^^^^^
27+
28+
["sss"]: string;
29+
>["sss"] : string
30+
> : ^^^^^^
31+
>"sss" : "sss"
32+
> : ^^^^^
33+
34+
s_d: string;
35+
>s_d : string
36+
> : ^^^^^^
37+
38+
queryData?: string;
39+
>queryData : string | undefined
40+
> : ^^^^^^^^^^^^^^^^^^
41+
42+
["foo bar"]: string;
43+
>["foo bar"] : string
44+
> : ^^^^^^
45+
>"foo bar" : "foo bar"
46+
> : ^^^^^^^^^
47+
48+
};
49+
["a_b_c"]: string;
50+
>["a_b_c"] : string
51+
> : ^^^^^^
52+
>"a_b_c" : "a_b_c"
53+
> : ^^^^^^^
54+
55+
}>();
56+
57+
export interface IData {
58+
["a_b_c"]: string;
59+
>["a_b_c"] : string
60+
> : ^^^^^^
61+
>"a_b_c" : "a_b_c"
62+
> : ^^^^^^^
63+
64+
nested: {
65+
>nested : { d_e_f: string; value: string; "qwe rty": string; }
66+
> : ^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^^^^^ ^^^
67+
68+
["d_e_f"]: string;
69+
>["d_e_f"] : string
70+
> : ^^^^^^
71+
>"d_e_f" : "d_e_f"
72+
> : ^^^^^^^
73+
74+
value: string;
75+
>value : string
76+
> : ^^^^^^
77+
78+
["qwe rty"]: string;
79+
>["qwe rty"] : string
80+
> : ^^^^^^
81+
>"qwe rty" : "qwe rty"
82+
> : ^^^^^^^^^
83+
84+
};
85+
}
86+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @strict: true
2+
// @declaration: true
3+
// @emitDeclarationOnly: true
4+
5+
// https://github.com/microsoft/TypeScript/issues/59107
6+
7+
declare function create<T extends {}>(): T;
8+
9+
export const c = create<{
10+
data: {
11+
["a_b_c"]: string;
12+
["sss"]: string;
13+
s_d: string;
14+
queryData?: string;
15+
["foo bar"]: string;
16+
};
17+
["a_b_c"]: string;
18+
}>();
19+
20+
export interface IData {
21+
["a_b_c"]: string;
22+
nested: {
23+
["d_e_f"]: string;
24+
value: string;
25+
["qwe rty"]: string;
26+
};
27+
}

0 commit comments

Comments
 (0)