diff --git a/packages/typescript/index.ts b/packages/typescript/index.ts index d021336b..cf18823a 100644 --- a/packages/typescript/index.ts +++ b/packages/typescript/index.ts @@ -111,7 +111,7 @@ export function create( }, }; - function createSemanticServicePlugin(context: ServiceContext, { sys, languageServiceHost }: NonNullable) { + function createSemanticServicePlugin(context: ServiceContext, { sys, languageServiceHost }: NonNullable): ServicePluginInstance { const created = tsWithImportCache.createLanguageService( ts, @@ -239,7 +239,7 @@ export function create( const getSelectionRanges = selectionRanges.register(ctx); const doValidation = diagnostics.register(ctx); const getDocumentSemanticTokens = semanticTokens.register(ctx); - const plugin: ServicePluginInstance = { + return { provide: { 'typescript/typescript': () => ts, @@ -547,8 +547,6 @@ export function create( }, }; - return plugin; - function isSemanticDocument(document: TextDocument, withJson = false) { const virtualScript = getVirtualScriptByUri(document.uri); if (virtualScript) { @@ -600,7 +598,7 @@ export function create( } } - function createSyntacticServicePlugin(context: ServiceContext) { + function createSyntacticServicePlugin(context: ServiceContext): ServicePluginInstance { let currentProjectVersion = -1; let currentDocument: TextDocument | undefined; let currentDocumentVersion: number | undefined; @@ -619,7 +617,8 @@ export function create( fileExists: fileName => fileName === currentFileName, }; const languageService = ts.createLanguageService(host, undefined, 2 satisfies ts.LanguageServiceMode.Syntactic); - const plugin: ServicePluginInstance = { + + return { provide: { 'typescript/typescript': () => ts, @@ -722,7 +721,6 @@ export function create( }); }, }; - return plugin; function worker(document: TextDocument, cb: () => T) { if (currentDocument !== document || currentDocumentVersion !== document.version) {