File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5794,6 +5794,10 @@ namespace ts {
57945794 if (type.flags & TypeFlags.Union) {
57955795 const props = createMap<Symbol>();
57965796 for (const memberType of (type as UnionType).types) {
5797+ if (memberType.flags & TypeFlags.Primitive) {
5798+ continue;
5799+ }
5800+
57975801 for (const { name } of getPropertiesOfType(memberType)) {
57985802 if (!props.has(name)) {
57995803 props.set(name, createUnionOrIntersectionProperty(type as UnionType, name));
Original file line number Diff line number Diff line change @@ -2587,6 +2587,7 @@ namespace ts {
25872587 /**
25882588 * For a union, will include a property if it's defined in *any* of the member types.
25892589 * So for `{ a } | { b }`, this will include both `a` and `b`.
2590+ * Does not include properties of primitive types.
25902591 */
25912592 /* @internal */ getAllPossiblePropertiesOfType ( type : Type ) : Symbol [ ] ;
25922593 }
Original file line number Diff line number Diff line change 22
33// @strictNullChecks : true
44
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*/ };
77
88////interface I { a: number; }
99////function f(...args: Array<I | I[]>) {}
1010////f({ /*f*/ });
1111
1212goTo . marker ( "x" ) ;
13+ verify . completionListCount ( 3 ) ;
1314verify . completionListContains ( "a" , "(property) a: string | number" ) ;
1415verify . completionListContains ( "b" , "(property) b: number | boolean" ) ;
1516verify . completionListContains ( "c" , "(property) c: string" ) ;
1617
1718goTo . marker ( "f" ) ;
1819verify . completionListContains ( "a" , "(property) a: number" ) ;
20+ // Also contains array members
You can’t perform that action at this time.
0 commit comments