🔎 Search Terms
implement interface codefix invalid type argument unresolved type symbol fixClassIncorrectlyImplementsInterface
🕗 Version & Regression Information
This is the behavior in the current repository state.
I found existing fourslash tests that appear to document this as undesirable behavior, but the tests currently still expect the codefix to be available:
tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateError.ts
tests/cases/fourslash/codeFixClassImplementInterfaceUndeclaredSymbol.ts
⏯ Playground Link
N/A: this is a language service codefix issue, reproduced through existing fourslash/codefix tests.
💻 Code
interface I<T extends string> {
x: T;
}
class C implements I<number> { }
A second repro:
interface I {
x: T;
}
class C implements I { }
🙁 Actual behavior
class C implements I {
x: T;
}
The resulting code still has semantic errors because the implemented interface reference or member type was already invalid.
🙂 Expected behavior
The `Implement interface` codefix should not be offered when the implemented interface reference or required member types contain semantic errors, such as an invalid type argument or an unresolved type symbol.
### Additional information about the issue
Nearby fourslash tests already contain comments indicating these cases should use `verify.codeFixAvailable([])`:
- `tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateError.ts`
- `tests/cases/fourslash/codeFixClassImplementInterfaceUndeclaredSymbol.ts`
The likely code path is:
- `src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts`
The fix appears to be created from `checker.getTypeAtLocation(implementedTypeNode)` without rejecting implemented type nodes that have related semantic errors.
Focused test commands used locally:
```sh
npx.cmd hereby runtests --tests=tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateError.ts --light=false
npx.cmd hereby runtests --tests=tests/cases/fourslash/codeFixClassImplementInterfaceUndeclaredSymbol.ts --light=false
🔎 Search Terms
implement interface codefix invalid type argument unresolved type symbol fixClassIncorrectlyImplementsInterface
🕗 Version & Regression Information
This is the behavior in the current repository state.
I found existing fourslash tests that appear to document this as undesirable behavior, but the tests currently still expect the codefix to be available:
tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateError.tstests/cases/fourslash/codeFixClassImplementInterfaceUndeclaredSymbol.ts⏯ Playground Link
N/A: this is a language service codefix issue, reproduced through existing fourslash/codefix tests.
💻 Code
A second repro:
🙁 Actual behavior
class C implements I {
x: T;
}
The resulting code still has semantic errors because the implemented interface reference or member type was already invalid.
🙂 Expected behavior