Bilingo VSCode Extension
Find function and type references between Go and TypeScript in bilingual projects (Bilingo = Bilingual + Go).
Features
- Cross-Language Reference Finding: Seamlessly find references between Go and TypeScript functions,
interfaces, type alias, enum constants, and struct fields ↔ interface properties.
- Cross-Language Implementation Finding: Find corresponding implementations across languages
- Go functions ↔ TypeScript functions
- Go interfaces / structs ↔ TypeScript interfaces / classes
- Type Matching: Go structs ↔ TypeScript interfaces and enum constants (perfect for
tygo-generated code)
- Native Integration: Works directly with VSCode's built-in "Find All References" (
Shift+F12) and "Find All Implementations" (Ctrl+F12) features
- Smart Name Matching: Automatically handles case conversion (PascalCase ↔ camelCase)
Rules
- Same-Directory Scope: Go and TypeScript symbols must be declared in the same directory
- Top-Level Functions Only: Only match top-level functions, excludes nested functions
- Exported Types Only: Only match exported Go structs/interfaces (capitalized) and exported TypeScript interfaces
Usage
Find All References
Simply use the native "Find All References" feature (right-click → "Find All References" or press
Shift+F12) on any function or type name in Go or TypeScript files. The extension will automatically find
references in both languages.
Find All Implementations
Use the native "Find All Implementations" feature (right-click → "Go to Implementations" or press
Ctrl+F12 / Cmd+F12) on functions, structs, or interfaces in Go or TypeScript files. The extension will
automatically find corresponding declarations and implementations in both languages.
Example: Function Matching
When you trigger "Find All References" on a Go function:
// api/article.go
func GetArticle(id string) Article {
// ...
}
The extension will find the corresponding TypeScript function in the same directory:
// api/article.ts
export function getArticle(id: string) {
// ...
}
Along with all locations where the function is used.
Example: Type Matching
When you trigger "Find All References" on a Go struct:
// types/article.go
type Article struct {
ID string
Title string
}
The extension will find the corresponding TypeScript interface in the same directory:
// types/article.ts
export interface Article {
ID: string
Title: string
}
Along with all locations where the interface or it's properties are used.
This is especially useful for projects using tygo to generate TypeScript types from Go structs.
Example: Enum Constant Matching
When you trigger "Find All References" on a Go constant:
// config/status.go
type Status = string
const (
StatusActive Status = "active"
StatusInactive Status = "inactive"
)
The extension will find the corresponding TypeScript constant in the same directory:
// config/status.ts
export const StatusActive = "active"
export const StatusInactive = "inactive"
export type Status = typeof StatusActive | typeof StatusInactive
Along with all locations where these constants are used in both languages.
Example: Go Struct → TypeScript Interface → Implementations
When you trigger "Find All Implementations" on a Go struct:
// types/user.go
type User struct { // ← Trigger here
ID string
Name string
}
// types/user.ts
export interface User { // ← Found: TS interface
id: string
name: string
}
// somewhere-else.ts
export const user: User = { // ← Found: TS implementations
id: "johndoe",
name: "John Doe",
}
Example: Function Implementations
When you trigger "Find All Implementations" on a function:
// api/article.ts
export function getArticle(id: string): Article { // ← Trigger here
// ...
}
// api/article.go
func GetArticle(id string) Article { // ← Found
// ...
}
And many more.
Configuration
bilingo-vscode.enable
Type: boolean
Default: true
Enable or disable the extension in the current workspace.
{
"bilingo-vscode.enable": true
}
bilingo-vscode.strictExport
Type: boolean
Default: false
If enabled, when matching functions, only match exported functions:
- Go capitalized functions ↔ TypeScript exported functions
When disabled, both exported and non-exported functions are matched.
{
"bilingo-vscode.strictExport": true
}
Example with Strict Export
With strictExport: false (default) - Matches:
func GetArticle (Go) ↔ export function getArticle (TS) ✅
func GetArticle (Go) ↔ function getArticle (TS) ✅
func getArticle (Go) ↔ export function getArticle (TS) ✅
func getArticle (Go) ↔ function getArticle (TS) ✅
With strictExport: true - Matches:
func GetArticle (Go) ↔ export function getArticle (TS) ✅
With strictExport: true - Does NOT match:
func GetArticle (Go) ✗ function getArticle (TS) (TS not exported)
func getArticle (Go) ✗ export function getArticle (TS) (Go not exported)
func getArticle (Go) ✗ function getArticle (TS) (both not exported)
Requirements
- VSCode version 1.97.0 or higher
- Go VSCode extension
- TypeScript VSCode language support
Supported Languages
- Go (
.go)
- TypeScript (
.ts)
- TypeScript React (
.tsx)
License
MIT
Repository
https://github.com/ayonli/bilingo-vscode
Issues
Report issues at: https://github.com/ayonli/bilingo-vscode/issues