Skip to content

Commit df6b9e5

Browse files
fix property completion in unions of object types and template literal types (#52196)
1 parent 48e812a commit df6b9e5

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6053,7 +6053,7 @@ export const enum TypeFlags {
60536053
/** @internal */
60546054
Intrinsic = Any | Unknown | String | Number | BigInt | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
60556055
/** @internal */
6056-
Primitive = String | Number | BigInt | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol,
6056+
Primitive = String | Number | BigInt | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol | TemplateLiteral,
60576057
StringLike = String | StringLiteral | TemplateLiteral | StringMapping,
60586058
NumberLike = Number | NumberLiteral | Enum,
60596059
BigIntLike = BigInt | BigIntLiteral,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////type UnionType = {
4+
//// key1: string;
5+
////} | {
6+
//// key2: number;
7+
////} | `string literal ${string}`;
8+
////
9+
////const obj1: UnionType = {
10+
//// /*1*/
11+
////};
12+
////
13+
////const obj2: UnionType = {
14+
//// key1: "abc",
15+
//// /*2*/
16+
////};
17+
18+
verify.completions({
19+
marker: '1',
20+
exact: [{ name: 'key1' }, { name: 'key2' }]
21+
})
22+
23+
verify.completions({
24+
marker: '2',
25+
exact: [{ name: 'key2' }]
26+
})

0 commit comments

Comments
 (0)