Skip to content
プロジェクト

antfu/vscode-goto-alias

GitHubで見る

概要

Go to Definition following alias redirections.

開発ツール

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
+1
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

vscode-goto-alias

Go to Definition following alias redirections.

Visual Studio Marketplace Version


Usages

Install this extension from the VS Code Marketplace.

Set editor.gotoLocation.multipleDefinitions to goto in your VS Code settings for the best experience.

{
  "editor.gotoLocation.multipleDefinitions": "goto"
}

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

関連プロジェクトを探す

読み込み中…