mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Expand constraint suggestion related span and add quick fix (#49481)
* Expand constraint suggestion related span and add quick fix * Remove circular constraint suggestions * Add error code * Style feedback and new error code in quickfix
This commit is contained in:
17
tests/cases/fourslash/quickfixAddMissingConstraint.ts
Normal file
17
tests/cases/fourslash/quickfixAddMissingConstraint.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: file.ts
|
||||
////function f<T>(x: T) {
|
||||
//// const y: `${number}` = x/**/;
|
||||
////}
|
||||
goTo.marker("");
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: "Add `extends` constraint.",
|
||||
newFileContent: {
|
||||
"/tests/cases/fourslash/file.ts":
|
||||
`function f<T extends \`$\{number}\`>(x: T) {
|
||||
const y: \`$\{number}\` = x;
|
||||
}`
|
||||
}
|
||||
});
|
||||
21
tests/cases/fourslash/quickfixAddMissingConstraint2.ts
Normal file
21
tests/cases/fourslash/quickfixAddMissingConstraint2.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: file.ts
|
||||
////interface Fn<T extends string> {
|
||||
////}
|
||||
////
|
||||
////function m<T>(x: Fn<T/**/>) {
|
||||
////}
|
||||
goTo.marker("");
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: "Add `extends` constraint.",
|
||||
newFileContent: {
|
||||
"/tests/cases/fourslash/file.ts":
|
||||
`interface Fn<T extends string> {
|
||||
}
|
||||
|
||||
function m<T extends string>(x: Fn<T>) {
|
||||
}`
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user