mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
For missing constraint quickfix insert position, Use node name end rather than related span end (#49673)
This commit is contained in:
@@ -51,7 +51,7 @@ namespace ts.codefix {
|
||||
if (!newConstraint) return;
|
||||
const newConstraintText = newConstraint[1];
|
||||
|
||||
changes.insertText(related.file!, related.start! + related.length!, ` extends ${newConstraintText}`);
|
||||
changes.insertText(related.file!, decl.name.end, ` extends ${newConstraintText}`);
|
||||
}
|
||||
|
||||
function findAncestorMatchingSpan(sourceFile: SourceFile, span: TextSpan): Node {
|
||||
|
||||
17
tests/cases/fourslash/quickfixAddMissingConstraint3.ts
Normal file
17
tests/cases/fourslash/quickfixAddMissingConstraint3.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: file.ts
|
||||
////function f<T = `${number}`>(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}\` = \`$\{number}\`>(x: T) {
|
||||
const y: \`$\{number}\` = x;
|
||||
}`
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user