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

Template literal type params and returns break method autocompletions #48215

Closed
ChiriVulpes opened this issue Mar 11, 2022 · 0 comments · Fixed by #48793
Closed

Template literal type params and returns break method autocompletions #48215

ChiriVulpes opened this issue Mar 11, 2022 · 0 comments · Fixed by #48793
Assignees
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Fix Available A PR has been opened for this issue

Comments

@ChiriVulpes
Copy link

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.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor labels Mar 11, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 11, 2022
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Mar 11, 2022
@andrewbranch andrewbranch removed the Help Wanted You can do this label Apr 20, 2022
@andrewbranch andrewbranch self-assigned this Apr 20, 2022
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants