Skip to content

Commit

Permalink
fix: improve compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 11, 2024
1 parent 30ae7b6 commit 565a271
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ export function convertLegacyReturn(result: TwoSlashReturn): TwoSlashReturnLegac
targetString: i.target,
})),

tags: result.tags,
tags: result.tags
.map((t): TwoSlashReturnLegacy['tags'][0] => ({
name: t.name,
line: t.line,
annotation: t.text,
})),

highlights: result.highlights
.map((h): TwoSlashReturnLegacy['highlights'][0] => ({
Expand Down
6 changes: 4 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { CompilerOptions, CompletionEntry, CustomTransformers } from 'types

type TS = typeof import('typescript')

export type TwoSlashFunction = (code: string, extension?: string, options?: TwoSlashExecuteOptions) => TwoSlashReturn

/**
* Options for the `twoslasher` function
*/
Expand Down Expand Up @@ -164,9 +166,9 @@ export interface TokenQuery extends Omit<TokenHover, 'type'> {
export interface TokenCompletion extends TokenBase {
type: 'completion'
/** Results for completions at a particular point */
completions?: CompletionEntry[]
completions: CompletionEntry[]
/* Completion prefix e.g. the letters before the cursor in the word so you can filter */
completionsPrefix?: string
completionsPrefix: string
}

export interface TokenError extends TokenBase {
Expand Down

0 comments on commit 565a271

Please sign in to comment.