From a033a32f09fbe242b86fbcceb7166a0d73b15c04 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 24 Oct 2022 08:18:43 -0700 Subject: [PATCH] Add placeholder types for fixing issues with `TestInstantiationService` (#164295) --- .../editor/test/common/modes/textToHtmlTokenizer.test.ts | 2 +- src/vs/platform/instantiation/common/instantiation.ts | 2 +- .../platform/instantiation/common/instantiationService.ts | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/vs/editor/test/common/modes/textToHtmlTokenizer.test.ts b/src/vs/editor/test/common/modes/textToHtmlTokenizer.test.ts index cd58acf7148..dc6f59461d2 100644 --- a/src/vs/editor/test/common/modes/textToHtmlTokenizer.test.ts +++ b/src/vs/editor/test/common/modes/textToHtmlTokenizer.test.ts @@ -293,7 +293,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => { class Mode extends Disposable { - private readonly languageId = 'textToHtmlTokenizerMode'; + public readonly languageId = 'textToHtmlTokenizerMode'; constructor( @ILanguageService languageService: ILanguageService diff --git a/src/vs/platform/instantiation/common/instantiation.ts b/src/vs/platform/instantiation/common/instantiation.ts index 695f8a31985..3199a4dba68 100644 --- a/src/vs/platform/instantiation/common/instantiation.ts +++ b/src/vs/platform/instantiation/common/instantiation.ts @@ -38,7 +38,7 @@ export const IInstantiationService = createDecorator('ins * Given a list of arguments as a tuple, attempt to extract the leading, non-service arguments * to their own tuple. */ -type GetLeadingNonServiceArgs = +export type GetLeadingNonServiceArgs = Args extends [...BrandedService[]] ? [] : Args extends [infer A, ...BrandedService[]] ? [A] : Args extends [infer A, ...infer R] ? [A, ...GetLeadingNonServiceArgs] diff --git a/src/vs/platform/instantiation/common/instantiationService.ts b/src/vs/platform/instantiation/common/instantiationService.ts index bf9deb002c5..78c34bc64f2 100644 --- a/src/vs/platform/instantiation/common/instantiationService.ts +++ b/src/vs/platform/instantiation/common/instantiationService.ts @@ -7,9 +7,9 @@ import { IdleValue } from 'vs/base/common/async'; import { Event } from 'vs/base/common/event'; import { illegalState } from 'vs/base/common/errors'; import { toDisposable } from 'vs/base/common/lifecycle'; -import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; +import { SyncDescriptor, SyncDescriptor0 } from 'vs/platform/instantiation/common/descriptors'; import { Graph } from 'vs/platform/instantiation/common/graph'; -import { IInstantiationService, ServiceIdentifier, ServicesAccessor, _util } from 'vs/platform/instantiation/common/instantiation'; +import { GetLeadingNonServiceArgs, IInstantiationService, ServiceIdentifier, ServicesAccessor, _util } from 'vs/platform/instantiation/common/instantiation'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { LinkedList } from 'vs/base/common/linkedList'; @@ -72,6 +72,9 @@ export class InstantiationService implements IInstantiationService { } } + createInstance(ctorOrDescriptor: any | SyncDescriptor, ...rest: any[]): any; // Comment out this line to fix type issues + createInstance(descriptor: SyncDescriptor0): T; + createInstance any, R extends InstanceType>(ctor: Ctor, ...args: GetLeadingNonServiceArgs>): R; createInstance(ctorOrDescriptor: any | SyncDescriptor, ...rest: any[]): any { let _trace: Trace; let result: any;