Skip to content

Commit

Permalink
Merge pull request #4393 from Tyriar/createinstance
Browse files Browse the repository at this point in the history
Improve createInstance types
  • Loading branch information
Tyriar authored Feb 1, 2023
2 parents a9da61e + 046d4b8 commit bcfed71
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/common/services/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,9 @@ export interface IBrandedService {
serviceBrand: undefined;
}

type GetLeadingNonServiceArgs<Args> =
Args extends [...IBrandedService[]] ? []
: Args extends [infer A1, ...IBrandedService[]] ? [A1]
: Args extends [infer A1, infer A2, ...IBrandedService[]] ? [A1, A2]
: Args extends [infer A1, infer A2, infer A3, ...IBrandedService[]] ? [A1, A2, A3]
: Args extends [infer A1, infer A2, infer A3, infer A4, ...IBrandedService[]] ? [A1, A2, A3, A4]
: Args extends [infer A1, infer A2, infer A3, infer A4, infer A5, ...IBrandedService[]] ? [A1, A2, A3, A4, A5]
: Args extends [infer A1, infer A2, infer A3, infer A4, infer A5, infer A6, ...IBrandedService[]] ? [A1, A2, A3, A4, A5, A6]
: Args extends [infer A1, infer A2, infer A3, infer A4, infer A5, infer A6, infer A7, ...IBrandedService[]] ? [A1, A2, A3, A4, A5, A6, A7]
: Args extends [infer A1, infer A2, infer A3, infer A4, infer A5, infer A6, infer A7, infer A8, ...IBrandedService[]] ? [A1, A2, A3, A4, A5, A6, A7, A8]
: never;
type GetLeadingNonServiceArgs<TArgs extends any[]> = TArgs extends [] ? []
: TArgs extends [...infer TFirst, infer TLast] ? TLast extends IBrandedService ? GetLeadingNonServiceArgs<TFirst> : TArgs
: never;

export const IInstantiationService = createDecorator<IInstantiationService>('InstantiationService');
export interface IInstantiationService {
Expand Down

0 comments on commit bcfed71

Please sign in to comment.