Skip to content

Commit 2e7e386

Browse files
committed
chore(typescript-plugin): create RequestContext type
1 parent dafc00d commit 2e7e386

File tree

7 files changed

+27
-34
lines changed

7 files changed

+27
-34
lines changed

packages/typescript-plugin/lib/requests/collectExtractProps.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import { Language, VueVirtualCode, isSemanticTokensEnabled } from '@vue/language-core';
1+
import { VueVirtualCode, isSemanticTokensEnabled } from '@vue/language-core';
22
import type * as ts from 'typescript';
3+
import type { RequestContext } from './types';
34

45
export function collectExtractProps(
5-
this: {
6-
typescript: typeof import('typescript');
7-
languageService: ts.LanguageService;
8-
language: Language;
9-
isTsPlugin: boolean,
10-
getFileId: (fileName: string) => string,
11-
},
6+
this: RequestContext,
127
fileName: string,
138
templateCodeRange: [number, number],
149
) {

packages/typescript-plugin/lib/requests/componentInfos.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import * as vue from '@vue/language-core';
22
import { camelize, capitalize } from '@vue/shared';
33
import type * as ts from 'typescript';
4+
import type { RequestContext } from './types';
45

56
export function getComponentProps(
6-
this: {
7-
typescript: typeof import('typescript');
8-
languageService: ts.LanguageService;
9-
language: vue.Language;
10-
getFileId: (fileName: string) => string,
11-
},
7+
this: RequestContext,
128
fileName: string,
139
tag: string,
1410
requiredOnly = false,

packages/typescript-plugin/lib/requests/getImportPathForFile.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import type * as ts from 'typescript';
2+
import type { RequestContext } from './types';
23

34
export function getImportPathForFile(
4-
this: {
5-
typescript: typeof import('typescript');
6-
languageService: ts.LanguageService;
7-
languageServiceHost: ts.LanguageServiceHost;
8-
},
5+
this: RequestContext,
96
fileName: string,
107
incomingFileName: string,
118
preferences: ts.UserPreferences,

packages/typescript-plugin/lib/requests/getPropertiesAtLocation.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import { Language, isCompletionEnabled } from '@vue/language-core';
1+
import { isCompletionEnabled } from '@vue/language-core';
22
import type * as ts from 'typescript';
3+
import type { RequestContext } from './types';
34

45
export function getPropertiesAtLocation(
5-
this: {
6-
typescript: typeof import('typescript');
7-
languageService: ts.LanguageService;
8-
language: Language;
9-
isTsPlugin: boolean,
10-
getFileId: (fileName: string) => string,
11-
},
6+
this: RequestContext,
127
fileName: string,
138
position: number,
149
) {

packages/typescript-plugin/lib/requests/getQuickInfoAtPosition.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type * as ts from 'typescript';
1+
import type { RequestContext } from './types';
2+
23
export function getQuickInfoAtPosition(
3-
this: {
4-
languageService: ts.LanguageService;
5-
},
4+
this: RequestContext,
65
fileName: string,
76
position: number,
87
) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Language } from '@vue/language-core';
2+
import type * as ts from 'typescript';
3+
4+
export interface RequestContext {
5+
typescript: typeof import('typescript');
6+
languageService: ts.LanguageService;
7+
languageServiceHost: ts.LanguageServiceHost;
8+
language: Language;
9+
isTsPlugin: boolean,
10+
getFileId: (fileName: string) => string,
11+
}

packages/typescript-plugin/lib/server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Language, VueCompilerOptions } from '@vue/language-core';
12
import * as fs from 'fs';
23
import * as net from 'net';
34
import type * as ts from 'typescript';
@@ -6,8 +7,8 @@ import { getComponentEvents, getComponentNames, getComponentProps, getElementAtt
67
import { getImportPathForFile } from './requests/getImportPathForFile';
78
import { getPropertiesAtLocation } from './requests/getPropertiesAtLocation';
89
import { getQuickInfoAtPosition } from './requests/getQuickInfoAtPosition';
10+
import type { RequestContext } from './requests/types';
911
import { NamedPipeServer, connect, readPipeTable, updatePipeTable } from './utils';
10-
import type { Language, VueCompilerOptions } from '@vue/language-core';
1112

1213
export interface Request {
1314
type: 'projectInfoForFile'
@@ -58,12 +59,11 @@ export function startNamedPipeServer(
5859
);
5960
}
6061
else if (project) {
61-
const requestContext = {
62+
const requestContext: RequestContext = {
6263
typescript: ts,
6364
languageService: project.info.languageService,
6465
languageServiceHost: project.info.languageServiceHost,
6566
language: project.language,
66-
vueOptions: project.vueOptions,
6767
isTsPlugin: true,
6868
getFileId: (fileName: string) => fileName,
6969
};

0 commit comments

Comments
 (0)