@prometx/trpc-navigation-plugin
Version:
TypeScript Language Service Plugin that fixes broken 'go to definition' for tRPC when using declaration emit
38 lines • 1.33 kB
TypeScript
import * as ts from 'typescript/lib/tsserverlibrary';
export interface ClickedWord {
word: string;
start: number;
end: number;
segmentIndex: number;
}
export interface NavigationPath {
variableName: string;
apiPath: string;
segments: string[];
clickedSegmentIndex: number;
targetPath: string[];
}
/**
* Finds the word at the given position in the text
*/
export declare function findWordAtPosition(text: string, position: number): ClickedWord;
/**
* Parses a navigation path and determines which segment was clicked
*/
export declare function parseNavigationPath(fullPath: string, clickedWord: string, variableName: string): NavigationPath | null;
/**
* Creates a TypeScript DefinitionInfo result
*/
export declare function createDefinitionResult(fileName: string, start: number, length: number, name: string, kind?: ts.ScriptElementKind): ts.DefinitionInfo;
/**
* Creates a DefinitionInfoAndBoundSpan result
*/
export declare function createNavigationResult(definition: ts.DefinitionInfo, clickedWord: ClickedWord): ts.DefinitionInfoAndBoundSpan;
/**
* Detects if a line contains a tRPC API call pattern
*/
export declare function detectTrpcApiCall(line: string, cursorPosition: number): {
variable: string;
path: string;
} | null;
//# sourceMappingURL=navigation-utils.d.ts.map