Description
Bug Report
🔎 Search Terms
method autocomplete template literal type
🕗 Version & Regression Information
This behaviour exists in both 4.6.2 and 4.7.0-dev.20220310. I did not test earlier versions since method autocompletions are still fairly new.
⏯ Playground Link
Method autocompletions don't work in the playground, so you'll have to copy this over to VSCode to test:
Playground link with relevant code
💻 Code
This is four different examples of things that work/don't work with comments so it's a bit longer than 30 lines. I wanted to be thorough
abstract class AbstractClass1 {
abstract firstThing (): string;
abstract secondThing (): string;
}
class Subclass1 extends AbstractClass1 {
// try typing firstThing/secondThing and pressing tab
// the methods are filled out as normal
}
abstract class AbstractClass2 {
abstract firstThing (): string;
abstract secondThing (): `test${string}`;
}
class Subclass2 extends AbstractClass2 {
// try typing firstThing/secondThing and pressing tab
// no suggestions at all
}
abstract class AbstractClass3 {
abstract firstThing (): string;
abstract secondThing (param: `test${string}`): string;
}
class Subclass3 extends AbstractClass3 {
// try typing firstThing/secondThing and pressing tab
// no suggestions at all
}
abstract class AbstractClass4 {
abstract firstThing (): string;
abstract secondThing (param: `test${string}`): string;
abstract thirdThing (): `test${string}`;
}
class Subclass4 extends AbstractClass4 {
thirdThing () { return `test me` as const }
secondThing (param: `test${string}`) { return "" }
// try typing firstThing and pressing tab
// suggestions are back, bcuz the method autocompletions that include template literal types are already part of the class
}
🙁 Actual/🙂 Expected behavior
See code above. Method autocompletions don't work when their types contain template literals.
Note
I'm not sure whether the issue is due to VSCode failing to render autocompletions that contain literal types, or TypeScript failing to provide autocompletions for them. I apologise if I'm reporting this to the wrong tracker — hopefully I guessed right.