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

A new generic type can be used for file path completion(intellisense) #60105

Open
6 tasks done
xushengfeng opened this issue Sep 30, 2024 · 2 comments
Open
6 tasks done
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@xushengfeng
Copy link

πŸ” Search Terms

"path intellisense","path completion","asset path completion"

βœ… Viability Checklist

⭐ Suggestion

Add a tool generics so that some function parameters can enable file path type hints

some assets in ../assets

function getImageUrl(name:T<"../assets">) {
...
return ...
}

getImageUrl("// intellisense

πŸ“ƒ Motivating Example

Enable custom file path completion through generics

πŸ’» Use Cases

  1. What do you want to use this for?

When I used vite static resource introduction, I used a function to wrap it, but the function parameters could not achieve type hints like import.

the function like:

function getImageUrl(name:string) { // lost file intellisense
  return new URL(`./dir/${name}.png`, import.meta.url).href
}
  1. What shortcomings exist with current approaches?

Only import statements support path completion and cannot be customized

  1. What workarounds are you using in the meantime?

i make a vscode extension

@MartinJohns
Copy link
Contributor

Essentially a duplicate of #42054.

@xushengfeng
Copy link
Author

This seems to be different from other proposals. In addition to path hints, path mapping is also a functional requirement.
Using generics allows you to better handle path mappings, which is particularly useful when working with resources.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants