1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts(12,20): error TS1360: Type '{ a: number; b: number; }' does not satisfy the expected type 'I1'.
Object literal may only specify known properties, and 'b' does not exist in type 'I1'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts(13,26): error TS1360: Type '{}' does not satisfy the expected type 'I1'.
Property 'a' is missing in type '{}' but required in type 'I1'.
tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts(24,23): error TS1360: Type '{ a: string; b: string; }' does not satisfy the expected type 'A'.
Object literal may only specify known properties, and 'b' does not exist in type 'A'.
==== tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts (3 errors) ====
interface I1 {
a: number;
}
type T1 = {
a: "a" | "b";
}
type T2 = (x: string) => void;
const t1 = { a: 1 } satisfies I1; // Ok
const t2 = { a: 1, b: 1 } satisfies I1; // Error
~~~~
!!! error TS1360: Type '{ a: number; b: number; }' does not satisfy the expected type 'I1'.
!!! error TS1360: Object literal may only specify known properties, and 'b' does not exist in type 'I1'.
const t3 = { } satisfies I1; // Error
~~
!!! error TS1360: Type '{}' does not satisfy the expected type 'I1'.
!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'I1'.
!!! related TS2728 tests/cases/conformance/expressions/typeSatisfaction/typeSatisfaction.ts:2:5: 'a' is declared here.
const t4: T1 = { a: "a" } satisfies T1; // Ok
const t5 = (m => m.substring(0)) satisfies T2; // Ok
const t6 = [1, 2] satisfies [number, number];
interface A {
a: string
}
let t7 = { a: 'test' } satisfies A;
let t8 = { a: 'test', b: 'test' } satisfies A;
~~~~~~~~~
!!! error TS1360: Type '{ a: string; b: string; }' does not satisfy the expected type 'A'.
!!! error TS1360: Object literal may only specify known properties, and 'b' does not exist in type 'A'.
|