fix(50048): remove token name from id (#50051)

This commit is contained in:
Oleksandr T
2022-07-26 11:13:04 +03:00
committed by GitHub
parent b5b02eefc8
commit bcd22b47d2
2 changed files with 41 additions and 3 deletions

View File

@@ -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);
}
}

View 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;
}`
})