Skip to content

Commit

Permalink
chore: sync upstream types
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jan 21, 2024
1 parent 876051c commit 3e97f59
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/eslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function create(resolveConfig?: (program: ts.Program) => Linter.Config):
const eslint = getEslint(languageService.getProgram()!);
const lintResult = await eslint.lintText(
document.getText(),
{ filePath: context.env.typescript.uriToFileName(document.uri) },
{ filePath: context.env.typescript!.uriToFileName(document.uri) },
);
uriToLintResult.set(document.uri, lintResult);
const diagnostics: Diagnostic[] = [];
Expand Down
8 changes: 4 additions & 4 deletions packages/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ export function create(options: CreateOptions): ServicePlugin {

const sync = () => {

if (!context.typescript) {
if (!context.language.typescript) {

Check failure on line 149 in packages/markdown/index.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'ServiceContext'.
return;
}

const { languageServiceHost } = context.typescript;
const { languageServiceHost } = context.language.typescript;

Check failure on line 153 in packages/markdown/index.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'ServiceContext'.
const newProjectVersion = languageServiceHost.getProjectVersion?.();
const shouldUpdate = newProjectVersion === undefined || newProjectVersion !== lastProjectVersion;
if (!shouldUpdate) {
Expand All @@ -162,7 +162,7 @@ export function create(options: CreateOptions): ServicePlugin {
const newVersions = new Map<string, TextDocument>();

for (const fileName of languageServiceHost.getScriptFileNames()) {
const uri = context.env.typescript.fileNameToUri(fileName);
const uri = context.env.typescript!.fileNameToUri(fileName);
const [_, sourceFile] = context.documents.getVirtualCodeByUri(uri);
if (sourceFile?.generated) {
for (const virtualCode of forEachEmbeddedCode(sourceFile.generated.code)) {
Expand Down Expand Up @@ -335,7 +335,7 @@ export function create(options: CreateOptions): ServicePlugin {
return context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
}
}
const sourceFile = context.files.get(uri);
const sourceFile = context.language.files.get(uri);
if (sourceFile) {
return context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function create(rules: IRule[]): ServicePlugin {
provideSemanticDiagnostics(document, token) {

const languageService = context.inject<Provide, 'typescript/languageService'>('typescript/languageService');
const fileName = context.env.typescript.uriToFileName(document.uri);
const fileName = context.env.typescript!.uriToFileName(document.uri);
const sourceFile = languageService.getProgram()?.getSourceFile(fileName);
if (!sourceFile) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-twoslash-queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function create(): ServicePlugin {
character: pointerPosition.character,
});

const fileName = context.env.typescript.uriToFileName(document.uri);
const fileName = context.env.typescript!.uriToFileName(document.uri);
const quickInfo = languageService.getQuickInfoAtPosition(fileName, hoverOffset);
if (quickInfo) {
inlayHints.push({
Expand Down
20 changes: 10 additions & 10 deletions packages/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ export function create(ts: typeof import('typescript')): ServicePlugin {
snapshot: ts.ScriptSnapshot.fromString(''),
};

if (!context.typescript) {
if (!context.language.typescript) {

Check failure on line 221 in packages/typescript/index.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'ServiceContext'.
return syntacticService;
}

const { sys, languageServiceHost } = context.typescript;
const { sys, languageServiceHost } = context.language.typescript;

Check failure on line 225 in packages/typescript/index.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'ServiceContext'.
const created = tsFaster.createLanguageService(
ts,
sys,
Expand Down Expand Up @@ -259,7 +259,7 @@ export function create(ts: typeof import('typescript')): ServicePlugin {
updateSourceScriptFileNames();
}
for (const change of params.changes) {
const fileName = context.env.typescript.uriToFileName(change.uri);
const fileName = context.env.typescript!.uriToFileName(change.uri);
if (sourceScriptNames.has(normalizeFileName(fileName))) {
created.projectUpdated?.(languageServiceHost.getCurrentDirectory());
}
Expand All @@ -269,8 +269,8 @@ export function create(ts: typeof import('typescript')): ServicePlugin {
function updateSourceScriptFileNames() {
sourceScriptNames.clear();
for (const fileName of languageServiceHost.getScriptFileNames()) {
const uri = context.env.typescript.fileNameToUri(fileName);
const sourceFile = context.files.get(uri);
const uri = context.env.typescript!.fileNameToUri(fileName);
const sourceFile = context.language.files.get(uri);

Check failure on line 273 in packages/typescript/index.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'ServiceContext'.
if (sourceFile?.generated) {
const tsCode = sourceFile.generated.languagePlugin.typescript?.getScript(sourceFile.generated.code);
if (tsCode) {
Expand All @@ -292,15 +292,15 @@ export function create(ts: typeof import('typescript')): ServicePlugin {
uriToFileName: uri => {
const [_virtualCode, file] = context.documents.getVirtualCodeByUri(uri);
if (file) {
return context.env.typescript.uriToFileName(file.id);
return context.env.typescript!.uriToFileName(file.id);
}
else {
return context.env.typescript.uriToFileName(uri);
return context.env.typescript!.uriToFileName(uri);
}
},
fileNameToUri: fileName => {
const uri = context.env.typescript.fileNameToUri(fileName);
const file = context.files.get(uri);
const uri = context.env.typescript!.fileNameToUri(fileName);
const file = context.language.files.get(uri);

Check failure on line 303 in packages/typescript/index.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'ServiceContext'.
if (file?.generated) {
const script = file.generated.languagePlugin.typescript?.getScript(file.generated.code);
if (script) {
Expand All @@ -314,7 +314,7 @@ export function create(ts: typeof import('typescript')): ServicePlugin {
if (virtualCode) {
return context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
}
const sourceFile = context.files.get(uri);
const sourceFile = context.language.files.get(uri);

Check failure on line 317 in packages/typescript/index.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'ServiceContext'.
if (sourceFile) {
return context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/lib/features/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function register(ctx: SharedContext) {

const token: ts.CancellationToken = {
isCancellationRequested() {
return ctx.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested() ?? false;
return ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested() ?? false;

Check failure on line 30 in packages/typescript/lib/features/diagnostics.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'SharedContext'.
},
throwIfCancellationRequested() { },
};
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/lib/features/semanticTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export function register(ctx: SharedContext) {
const start = range ? document.offsetAt(range.start) : 0;
const length = range ? (document.offsetAt(range.end) - start) : document.getText().length;

if (ctx.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested()) return;
if (ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested()) return;

Check failure on line 18 in packages/typescript/lib/features/semanticTokens.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'SharedContext'.
const response2 = safeCall(() => ctx.languageService.getEncodedSyntacticClassifications(file, { start, length }));
if (!response2) return;

if (ctx.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested()) return;
if (ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested()) return;

Check failure on line 22 in packages/typescript/lib/features/semanticTokens.ts

View workflow job for this annotation

GitHub Actions / tsc

Property 'language' does not exist on type 'SharedContext'.
const response1 = safeCall(() => ctx.languageService.getEncodedSemanticClassifications(file, { start, length }, ts.SemanticClassificationFormat.TwentyTwenty));
if (!response1) return;

Expand Down
2 changes: 1 addition & 1 deletion packages/vetur/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function create(): ServicePlugin {

if (!packageJsonPath) {

let lastDirname = context.env.typescript.uriToFileName(document.uri);
let lastDirname = context.env.typescript!.uriToFileName(document.uri);

while (true) {

Expand Down

0 comments on commit 3e97f59

Please sign in to comment.