Skip to content

Go to Definition following alias redirections.

License

Notifications You must be signed in to change notification settings

jack-allocate/vscode-goto-alias

 
 

Repository files navigation

vscode-goto-alias

Go to Definition following alias redirections.

Visual Studio Marketplace Version


Motivation

For example, in Nuxt 3 or Vitesse projects, we provide auto import for APIs and components. To provide types for these auto imports, the tools will generate a .d.ts file to declare those APIs as "global" type.

// generated.d.ts
declare global {
  const autoImported: typeof import('foobar')['autoImported'] // alias to provide type from package 'foobar'
  // ...
}

With this declaration file, we could have type safety using autoImported in our code without importing it.

// no need to import
const foo = autoImported()

The only small downside is that when you use "Go to definition" in the code, the IDE will redirect you the the definition file we generated instead of the real definition source.

So, this extension is built to solve this. With this extension installed, when the "Go to definition" command hits the definition file, it will then redirect again to the definition source.

Working with Vue Components

If you find trouble redirecting auto-registed components by Nuxt 3 or unplugin-vue-components, you might want to enable the Takeover mode of Volar.

Sponsors

License

MIT License © 2022 Anthony Fu

About

Go to Definition following alias redirections.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.7%
  • JavaScript 2.3%