Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Interface Code Action is not available under certain circumstances #55765

Closed
lucasmaehn opened this issue Sep 17, 2023 · 0 comments · Fixed by #55767
Closed

Implement Interface Code Action is not available under certain circumstances #55765

lucasmaehn opened this issue Sep 17, 2023 · 0 comments · Fixed by #55767
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@lucasmaehn
Copy link

🔎 Search Terms

code action
implement interface

🕗 Version & Regression Information

Im facing an issue when trying to implement an interface thats automatically generated (therefore i cannot change the definition of the interfaces or its types to solve the problem).

It seems like, code actions are not available when trying to implement an interface that defines a function with a return certain recursively defined return type DeepPartial (definition can be found in linked typescript sandbox link) where T is a type with two attributes having the same interface as a type i.e. {a: Nested, b: Nested} where Nested is an interface.

Additionaly I've noticed that whenever I load the available code actions in my IDE, an error is thrown with the following stacktrace:

at consumeTokenAndAdvanceScanner (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171190:13)
    at processChildNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171099:9)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171038:9
    at visitNode2 (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30102:18)
    at forEachChildInPropertySignature (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30158:92)
    at forEachChild (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30619:35)
    at processNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171035:5)
    at processChildNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171114:7)
    at processChildNodes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171157:32)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171051:9
    at visitNodes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30107:14)
    at forEachChildInTypeLiteral (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30217:12)
    at forEachChild (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30619:35)
    at processNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171035:5)
    at processChildNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171114:7)
    at processChildNodes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171157:32)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171051:9
    at visitNodes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30107:14)
    at forEachChildInUnionOrIntersectionType (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30566:10)
    at forEachChild (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30619:35)
    at processNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171035:5)
    at processChildNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171114:7)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171038:9
    at visitNode2 (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30102:18)
    at forEachChildInPropertySignature (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30158:134)
    at forEachChild (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30619:35)
    at processNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171035:5)
    at processChildNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171114:7)
    at processChildNodes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171157:32)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171051:9
    at visitNodes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30107:14)
    at forEachChildInTypeLiteral (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30217:12)
    at forEachChild (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30619:35)
    at processNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171035:5)
    at processChildNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171114:7)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171038:9
    at visitNode2 (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30102:18)
    at forEachChildInMethodDeclaration (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30181:321)
    at forEachChild (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:30619:35)
    at processNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:171035:5)
    at formatSpanWorker (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:170837:5)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:170777:105
    at getFormattingScanner (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:169580:15)
    at Object.formatNodeGivenIndentation (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:170777:10)
    at getFormattedTextOfNode (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168977:43)
    at format (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168957:27)
    at computeNewText (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168958:217)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168919:25
    at mapDefined (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:2668:22)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168916:28
    at mapDefined (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:2668:22)
    at Object.getTextChangesFromChanges (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168910:12)
    at _ChangeTracker.getChanges (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168807:35)
    at _ChangeTracker.with (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:168286:20)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:150043:64
    at mapDefined (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:2668:22)
    at Object.getCodeActions (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:150042:12)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:147158:46
    at flatMap (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:2597:17)
    at Object.getFixes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:147158:10)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:144526:33
    at flatMap (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:2597:17)
    at Object.getCodeFixesAtPosition (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:144524:12)
    at IpcIOSession.getCodeFixes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:184683:50)
    at getCodeFixes (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:182794:43)
    at /Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:184987:69
    at IpcIOSession.executeWithRequestId (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:184979:14)
    at IpcIOSession.executeCommand (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:184987:29)
    at IpcIOSession.onMessage (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:185029:51)
    at process.<anonymous> (/Users/lucasmahn/.vscode/extensions/ms-vscode.vscode-typescript-next-5.3.20230914/node_modules/typescript/lib/tsserver.js:186607:14)
    at process.emit (node:events:513:28)
    at emit (node:internal/child_process:937:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21): Error: <semantic> TypeScript Server Error (5.3.0-dev.20230914)

When trying to debug this issue in TypeScript Playground, i noticed this problem only occurs in TypeScript versions > 4.3.5

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

https://www.typescriptlang.org/play?#code/PTAEBcEMGsFMDtQDMBOB7AthAzgWgA7rhqgDmCsKk4sAJsgJYA2s2AUOAJ76ygBCAV2bgGiALxtQoAD6gAItViSZoAGID4AYxFp4y2QFVR4ABwBBFFU77Q2cClGkb8ARgBGlG27RoWkPVKyGrSwSKJ0ANxsbLAAHvhoKOAQ3LxysLD4AAqQSQyQTAA8ACoAfKBioMWgcTTwtNj8QkwiAaAA-FXKAFxVNbF1DaAWVoWiSJSgBqXKnSOQnIXpmTl5BYXTM1K91bUIQwBKsJC0ukyc84vjk9OzoEcnZxeWC0sZ2bki65s9fXv1jQA3gBfO6A0AAbQA0qBRKA4Jw0EgqgBddq9ZYfNZFYrQlHlUHbUCrL440pRaIgCCsVqkUCaNAhUCQbQMXTIRKwjD4FgYBC02HwGgoJAs1gxeKJZLGSiizS8AByNLooEByjCsCYtF6dgc8FIUVBbBlIrFah8quUKFgAEcBDSABQASgx7xJ+SK4PgytoAEZekq7JFqXYAEwBn2gYHkthG41C2Vmvi5S1Sa12x0u+Ruz4ewpen0RoP0aOG6JxBJJQXCuWKyNqqQarU6+yOMtsKkMpksnSIeBoZKQABukGYkDcLAlleSmiYkGwjVUPgAktymFyebA+ULFxa1UbO4zeD22Yhh6O5xOlBWpfS5wv+LlVzyN7z+Y1kyhVcCgA

💻 Code

// taken from ts-proto generated files
type Builtin =
  | Date
  | Function
  | Uint8Array
  | string
  | number
  | boolean
  | undefined;

export type DeepPartial<T> = T extends Builtin
  ? T
  : T extends Array<infer U>
  ? Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U>
  ? ReadonlyArray<DeepPartial<U>>
  : T extends {}
  ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;


// testing code action for implementing interfaces
export interface Nested {
  field: string;
}

interface Foo {
  request(): DeepPartial<{ nested1: Nested; test2: Nested }>;
}


interface Bar {
  request(): DeepPartial<{ nested: Nested }>;
}

export interface Nested {
  field: string;
}

// code action not available
export class FooImpl implements Foo {
}

// code action available
export class BarImpl implements Bar {

🙁 Actual behavior

there is no code action available for FooImpl

🙂 Expected behavior

For both classes FooImpl, BarImp there should be code actions available to implement the missing methods of the interfaces

Additional information about the issue

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
2 participants