-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(60312): Add missing properties for satisfies (#60314)
- Loading branch information
1 parent
55f1248
commit ef802b1
Showing
14 changed files
with
375 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////interface Foo { | ||
//// a: number; | ||
//// b: string; | ||
//// c: 1; | ||
//// d: "d"; | ||
//// e: "e1" | "e2"; | ||
//// f(x: number, y: number): void; | ||
//// g: (x: number, y: number) => void; | ||
//// h: number[]; | ||
//// i: bigint; | ||
//// j: undefined | "special-string"; | ||
//// k: `--${string}`; | ||
////} | ||
////[|const b = {} satisfies Foo;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const b = { | ||
a: 0, | ||
b: "", | ||
c: 1, | ||
d: "d", | ||
e: "e1", | ||
f: function(x: number, y: number): void { | ||
throw new Error("Function not implemented."); | ||
}, | ||
g: function(x: number, y: number): void { | ||
throw new Error("Function not implemented."); | ||
}, | ||
h: [], | ||
i: 0n, | ||
j: "special-string", | ||
k: "" | ||
} satisfies Foo;`, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////interface Foo { | ||
//// a: number; | ||
//// b: string; | ||
//// c: any; | ||
////} | ||
////[|class C { | ||
//// public c = {} satisfies Foo; | ||
////}|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`class C { | ||
public c = { | ||
a: 0, | ||
b: "", | ||
c: undefined | ||
} satisfies Foo; | ||
}` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////interface Foo { | ||
//// a: number; | ||
//// b: string; | ||
////} | ||
////[|const foo = { a: 10 } satisfies Foo;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const foo = { | ||
a: 10, | ||
b: "" | ||
} satisfies Foo;` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////type T = { | ||
//// a: null; | ||
////} | ||
//// | ||
////[|const foo = {} satisfies T;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const foo = { | ||
a: null | ||
} satisfies T;` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////interface I { | ||
//// x: number; | ||
//// y: number; | ||
////} | ||
////class C { | ||
//// public p: number; | ||
//// m(x: number, y: I) {} | ||
////} | ||
////[|const foo = {} satisfies C;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const foo = { | ||
p: 0, | ||
m: function(x: number, y: I): void { | ||
throw new Error("Function not implemented."); | ||
} | ||
} satisfies C;` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////enum E1 { | ||
//// A, B | ||
////} | ||
////enum E2 { | ||
//// A | ||
////} | ||
////enum E3 { | ||
////} | ||
////interface I { | ||
//// x: E1; | ||
//// y: E2; | ||
//// z: E3; | ||
////} | ||
////[|const foo = {} satisfies I;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const foo = { | ||
x: E1.A, | ||
y: E2.A, | ||
z: 0 | ||
} satisfies I;` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////class A { | ||
//// constructor() {} | ||
////} | ||
//// | ||
////abstract class B {} | ||
//// | ||
////class C { | ||
//// constructor(a: string, b: number, c: A) {} | ||
////} | ||
//// | ||
////interface I { | ||
//// a: A; | ||
//// b: B; | ||
//// c: C; | ||
////} | ||
////[|const foo = {} satisfies I;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const foo = { | ||
a: new A, | ||
b: undefined, | ||
c: undefined | ||
} satisfies I;` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////interface I { | ||
//// a: { | ||
//// x: number; | ||
//// y: { z: string; }; | ||
//// } | ||
////} | ||
////[|const foo = {} satisfies I;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const foo = { | ||
a: { | ||
x: 0, | ||
y: { | ||
z: "" | ||
} | ||
} | ||
} satisfies I;` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////interface Bar { | ||
//// a: number; | ||
////} | ||
//// | ||
////interface Foo<T, U> { | ||
//// foo(a: T): U; | ||
////} | ||
////[|const x = {} satisfies Foo<string, Bar>;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const x = { | ||
foo: function(a: string): Bar { | ||
throw new Error("Function not implemented."); | ||
} | ||
} satisfies Foo<string, Bar>;`, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////type A = { a: string }; | ||
////type B = { b: string }; | ||
//// | ||
////[|const c = { } satisfies A satisfies B;|] | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`const c = { | ||
a: "" | ||
} satisfies A satisfies B;`, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
////interface Foo { | ||
//// a: number; | ||
//// b: string; | ||
//// c: 1; | ||
//// d: "d"; | ||
//// e: "e1" | "e2"; | ||
//// f(x: number, y: number): void; | ||
//// g: (x: number, y: number) => void; | ||
//// h: number[]; | ||
//// i: bigint; | ||
//// j: undefined | "special-string"; | ||
//// k: `--${string}`; | ||
////} | ||
////const f = (): Foo => { | ||
//// [|return { };|] | ||
////}; | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`return { | ||
a: 0, | ||
b: "", | ||
c: 1, | ||
d: "d", | ||
e: "e1", | ||
f: function(x: number, y: number): void { | ||
throw new Error("Function not implemented."); | ||
}, | ||
g: function(x: number, y: number): void { | ||
throw new Error("Function not implemented."); | ||
}, | ||
h: [], | ||
i: 0n, | ||
j: "special-string", | ||
k: "" | ||
};`, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/// <reference path='fourslash.ts' /> | ||
// @lib: es2020 | ||
// @target: es2020 | ||
|
||
////interface Foo { | ||
//// a: number; | ||
//// b: string; | ||
//// c: 1; | ||
//// d: "d"; | ||
//// e: "e1" | "e2"; | ||
//// f(x: number, y: number): void; | ||
//// g: (x: number, y: number) => void; | ||
//// h: number[]; | ||
//// i: bigint; | ||
//// j: undefined | "special-string"; | ||
//// k: `--${string}`; | ||
////} | ||
////const f = function* (): Generator<Foo, void, any> { | ||
//// [|yield {};|] | ||
////}; | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: ts.Diagnostics.Add_missing_properties.message, | ||
newRangeContent: | ||
`yield { | ||
a: 0, | ||
b: "", | ||
c: 1, | ||
d: "d", | ||
e: "e1", | ||
f: function(x: number, y: number): void { | ||
throw new Error("Function not implemented."); | ||
}, | ||
g: function(x: number, y: number): void { | ||
throw new Error("Function not implemented."); | ||
}, | ||
h: [], | ||
i: 0n, | ||
j: "special-string", | ||
k: "" | ||
};`, | ||
}); |
Oops, something went wrong.