File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -5794,6 +5794,10 @@ namespace ts {
5794
5794
if (type.flags & TypeFlags.Union) {
5795
5795
const props = createMap<Symbol>();
5796
5796
for (const memberType of (type as UnionType).types) {
5797
+ if (memberType.flags & TypeFlags.Primitive) {
5798
+ continue;
5799
+ }
5800
+
5797
5801
for (const { name } of getPropertiesOfType(memberType)) {
5798
5802
if (!props.has(name)) {
5799
5803
props.set(name, createUnionOrIntersectionProperty(type as UnionType, name));
Original file line number Diff line number Diff line change @@ -2587,6 +2587,7 @@ namespace ts {
2587
2587
/**
2588
2588
* For a union, will include a property if it's defined in *any* of the member types.
2589
2589
* So for `{ a } | { b }`, this will include both `a` and `b`.
2590
+ * Does not include properties of primitive types.
2590
2591
*/
2591
2592
/* @internal */ getAllPossiblePropertiesOfType ( type : Type ) : Symbol [ ] ;
2592
2593
}
Original file line number Diff line number Diff line change 2
2
3
3
// @strictNullChecks : true
4
4
5
- // Non-objects should be skipped, so `| number | null` should have no effect on completions.
6
- ////const x: { a: number, b: number } | { a: string, c: string } | { b: boolean } | number | null = { /*x*/ };
5
+ // Primitives should be skipped, so `| number | null | undefined ` should have no effect on completions.
6
+ ////const x: { a: number, b: number } | { a: string, c: string } | { b: boolean } | number | null | undefined = { /*x*/ };
7
7
8
8
////interface I { a: number; }
9
9
////function f(...args: Array<I | I[]>) {}
10
10
////f({ /*f*/ });
11
11
12
12
goTo . marker ( "x" ) ;
13
+ verify . completionListCount ( 3 ) ;
13
14
verify . completionListContains ( "a" , "(property) a: string | number" ) ;
14
15
verify . completionListContains ( "b" , "(property) b: number | boolean" ) ;
15
16
verify . completionListContains ( "c" , "(property) c: string" ) ;
16
17
17
18
goTo . marker ( "f" ) ;
18
19
verify . completionListContains ( "a" , "(property) a: number" ) ;
20
+ // Also contains array members
You can’t perform that action at this time.
0 commit comments