Skip to content

Commit

Permalink
add an extra test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Feb 26, 2024
1 parent 6732851 commit 78fd6d9
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 1 deletion.
Expand Up @@ -4,9 +4,10 @@ elementWiseErrorInUnionTarget3.ts(44,5): error TS2322: Type 'number' is not assi
elementWiseErrorInUnionTarget3.ts(61,5): error TS2322: Type 'number' is not assignable to type 'string'.
elementWiseErrorInUnionTarget3.ts(73,5): error TS2322: Type 'number' is not assignable to type 'string'.
elementWiseErrorInUnionTarget3.ts(90,5): error TS2322: Type 'boolean' is not assignable to type 'string'.
elementWiseErrorInUnionTarget3.ts(107,5): error TS2322: Type 'number' is not assignable to type 'string'.


==== elementWiseErrorInUnionTarget3.ts (6 errors) ====
==== elementWiseErrorInUnionTarget3.ts (7 errors) ====
const obj1: {
prop:
| string
Expand Down Expand Up @@ -116,4 +117,24 @@ elementWiseErrorInUnionTarget3.ts(90,5): error TS2322: Type 'boolean' is not ass
!!! related TS6500 elementWiseErrorInUnionTarget3.ts:81:9: The expected type comes from property 'prop' which is declared here on type '{ type: "foo"; prop: string; } | { type: "bar"; prop: number; }'
},
};

const obj7: {
prop:
| {
type: "foo";
prop: string;
}
| {
type: "bar";
prop: number;
};
} = {
prop: {
type: "foo",
prop: 42,
~~~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
!!! related TS6500 elementWiseErrorInUnionTarget3.ts:98:9: The expected type comes from property 'prop' which is declared here on type '{ type: "foo"; prop: string; } | { type: "bar"; prop: number; }'
},
};

34 changes: 34 additions & 0 deletions tests/baselines/reference/elementWiseErrorInUnionTarget3.symbols
Expand Up @@ -182,3 +182,37 @@ const obj6: {
},
};

const obj7: {
>obj7 : Symbol(obj7, Decl(elementWiseErrorInUnionTarget3.ts, 93, 5))

prop:
>prop : Symbol(prop, Decl(elementWiseErrorInUnionTarget3.ts, 93, 13))

| {
type: "foo";
>type : Symbol(type, Decl(elementWiseErrorInUnionTarget3.ts, 95, 7))

prop: string;
>prop : Symbol(prop, Decl(elementWiseErrorInUnionTarget3.ts, 96, 20))
}
| {
type: "bar";
>type : Symbol(type, Decl(elementWiseErrorInUnionTarget3.ts, 99, 7))

prop: number;
>prop : Symbol(prop, Decl(elementWiseErrorInUnionTarget3.ts, 100, 20))

};
} = {
prop: {
>prop : Symbol(prop, Decl(elementWiseErrorInUnionTarget3.ts, 103, 5))

type: "foo",
>type : Symbol(type, Decl(elementWiseErrorInUnionTarget3.ts, 104, 9))

prop: 42,
>prop : Symbol(prop, Decl(elementWiseErrorInUnionTarget3.ts, 105, 16))

},
};

39 changes: 39 additions & 0 deletions tests/baselines/reference/elementWiseErrorInUnionTarget3.types
Expand Up @@ -204,3 +204,42 @@ const obj6: {
},
};

const obj7: {
>obj7 : { prop: { type: "foo"; prop: string;} | { type: "bar"; prop: number;}; }

prop:
>prop : { type: "foo"; prop: string; } | { type: "bar"; prop: number; }

| {
type: "foo";
>type : "foo"

prop: string;
>prop : string
}
| {
type: "bar";
>type : "bar"

prop: number;
>prop : number

};
} = {
>{ prop: { type: "foo", prop: 42, },} : { prop: { type: "foo"; prop: number; }; }

prop: {
>prop : { type: "foo"; prop: number; }
>{ type: "foo", prop: 42, } : { type: "foo"; prop: number; }

type: "foo",
>type : "foo"
>"foo" : "foo"

prop: 42,
>prop : number
>42 : 42

},
};

17 changes: 17 additions & 0 deletions tests/cases/compiler/elementWiseErrorInUnionTarget3.ts
Expand Up @@ -94,3 +94,20 @@ const obj6: {
prop: true,
},
};

const obj7: {
prop:
| {
type: "foo";
prop: string;
}
| {
type: "bar";
prop: number;
};
} = {
prop: {
type: "foo",
prop: 42,
},
};
15 changes: 15 additions & 0 deletions tests/cases/fourslash/completionsDotDotDotInObjectLiteral1.ts
@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />

//// // https://github.com/microsoft/TypeScript/issues/57540
////
//// const foo = { b: 100 };
////
//// const bar: {
//// a: number;
//// b: number;
//// } = {
//// a: 42,
//// .../*1*/
//// };

verify.completions({ marker: "1", includes: ["foo"], excludes: ["b"] });

0 comments on commit 78fd6d9

Please sign in to comment.