mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
fix(50048): remove token name from id (#50051)
This commit is contained in:
@@ -26,14 +26,13 @@ namespace ts.codefix {
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
const { program, preferences, host } = context;
|
||||
const seen = new Map<string, true>();
|
||||
const seen = new Map<number, true>();
|
||||
|
||||
return createCombinedCodeActions(textChanges.ChangeTracker.with(context, changes => {
|
||||
eachDiagnostic(context, errorCodes, diag => {
|
||||
const info = getInfo(program, diag.file, createTextSpan(diag.start, diag.length));
|
||||
if (info) {
|
||||
const id = getNodeId(info.declaration) + "#" + info.token.getText();
|
||||
if (addToSeen(seen, id)) {
|
||||
if (addToSeen(seen, getNodeId(info.declaration))) {
|
||||
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
||||
}
|
||||
}
|
||||
|
||||
39
tests/cases/fourslash/quickfixAddMissingConstraint5.ts
Normal file
39
tests/cases/fourslash/quickfixAddMissingConstraint5.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @strict: true
|
||||
// @filename: /foo.ts
|
||||
////export interface RendererElement {
|
||||
//// [key: string]: any
|
||||
////}
|
||||
////
|
||||
////export interface VNode<HostElement extends RendererElement> {
|
||||
//// target: HostElement | null;
|
||||
////}
|
||||
////
|
||||
////export function cloneVNode<U>(vnode: VNode<U>): VNode<U> {
|
||||
//// const cloned: VNode<RendererElement> = {
|
||||
//// target: vnode.target,
|
||||
//// }
|
||||
//// return cloned;
|
||||
////}
|
||||
|
||||
goTo.file("/foo.ts");
|
||||
verify.codeFixAll({
|
||||
fixId: "addMissingConstraint",
|
||||
fixAllDescription: ts.Diagnostics.Add_extends_constraint_to_all_type_parameters.message,
|
||||
newFileContent:
|
||||
`export interface RendererElement {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface VNode<HostElement extends RendererElement> {
|
||||
target: HostElement | null;
|
||||
}
|
||||
|
||||
export function cloneVNode<U extends RendererElement>(vnode: VNode<U>): VNode<U> {
|
||||
const cloned: VNode<RendererElement> = {
|
||||
target: vnode.target,
|
||||
}
|
||||
return cloned;
|
||||
}`
|
||||
})
|
||||
Reference in New Issue
Block a user