From 59bda8f6c80e2e222ebd23827dcff73fc0d5eb6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 2 Dec 2025 21:10:28 +0100 Subject: [PATCH 1/2] Fixed `silentNeverType` leak by propagating it through `getIndexType` --- src/compiler/checker.ts | 2 +- .../noSilentNeverTypeLeak1.errors.txt | 110 ++++++++ .../reference/noSilentNeverTypeLeak1.symbols | 255 +++++++++++++++++ .../reference/noSilentNeverTypeLeak1.types | 262 ++++++++++++++++++ .../noSilentNeverTypeLeak2.errors.txt | 128 +++++++++ .../reference/noSilentNeverTypeLeak2.symbols | 254 +++++++++++++++++ .../reference/noSilentNeverTypeLeak2.types | 260 +++++++++++++++++ .../cases/compiler/noSilentNeverTypeLeak1.ts | 96 +++++++ .../cases/compiler/noSilentNeverTypeLeak2.ts | 94 +++++++ 9 files changed, 1460 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak1.errors.txt create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak1.symbols create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak1.types create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak2.symbols create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak2.types create mode 100644 tests/cases/compiler/noSilentNeverTypeLeak1.ts create mode 100644 tests/cases/compiler/noSilentNeverTypeLeak2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8e5c03560db3e..901f3bce24b0f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18932,7 +18932,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { type.flags & TypeFlags.Union ? getIntersectionType(map((type as UnionType).types, t => getIndexType(t, indexFlags))) : type.flags & TypeFlags.Intersection ? getUnionType(map((type as IntersectionType).types, t => getIndexType(t, indexFlags))) : getObjectFlags(type) & ObjectFlags.Mapped ? getIndexTypeForMappedType(type as MappedType, indexFlags) : - type === wildcardType ? wildcardType : + type === wildcardType || type === silentNeverType ? type : type.flags & TypeFlags.Unknown ? neverType : type.flags & (TypeFlags.Any | TypeFlags.Never) ? stringNumberSymbolType : getLiteralTypeFromProperties(type, (indexFlags & IndexFlags.NoIndexSignatures ? TypeFlags.StringLiteral : TypeFlags.StringLike) | (indexFlags & IndexFlags.StringsOnly ? 0 : TypeFlags.NumberLike | TypeFlags.ESSymbolLike), indexFlags === IndexFlags.None); diff --git a/tests/baselines/reference/noSilentNeverTypeLeak1.errors.txt b/tests/baselines/reference/noSilentNeverTypeLeak1.errors.txt new file mode 100644 index 0000000000000..f2353247675ff --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak1.errors.txt @@ -0,0 +1,110 @@ +noSilentNeverTypeLeak1.ts(90,5): error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. + Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. + Types of property 'params' are incompatible. + Type 'unknown' is not assignable to type 'number'. + + +==== noSilentNeverTypeLeak1.ts (1 errors) ==== + // https://github.com/microsoft/TypeScript/issues/62824 + + type Values = T[keyof T]; + + type MachineContext = Record; + + interface ParameterizedObject { + type: string; + params?: unknown; + } + + type ActionFunction< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, + > = { + (ctx: TContext, params: TParams): void; + _out_TAction?: TAction; + }; + + type ToParameterizedObject< + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, + > = Values<{ + [K in keyof TParameterizedMap & string]: { + type: K; + params: TParameterizedMap[K]; + }; + }>; + + type CollectActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + > = ( + { + context, + enqueue, + }: { + context: TContext; + enqueue: (action: () => void) => void; + }, + params: TParams, + ) => void; + + declare function enqueueActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, + >( + collect: CollectActions, + ): ActionFunction; + + declare function setup< + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, + >({ + types, + actions, + }: { + types?: { context?: TContext }; + actions?: { + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; + }): void; + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + }, + }); + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_, params: string) => {}, + }, + }); + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. +!!! error TS2322: Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. +!!! error TS2322: Types of property 'params' are incompatible. +!!! error TS2322: Type 'unknown' is not assignable to type 'number'. + doOtherStuff: (_: any, params: string) => {}, + }, + }); + \ No newline at end of file diff --git a/tests/baselines/reference/noSilentNeverTypeLeak1.symbols b/tests/baselines/reference/noSilentNeverTypeLeak1.symbols new file mode 100644 index 0000000000000..0574c6f9557fe --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak1.symbols @@ -0,0 +1,255 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak1.ts] //// + +=== noSilentNeverTypeLeak1.ts === +// https://github.com/microsoft/TypeScript/issues/62824 + +type Values = T[keyof T]; +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak1.ts, 0, 0)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 12)) + +type MachineContext = Record; +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +interface ParameterizedObject { +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + + type: string; +>type : Symbol(ParameterizedObject.type, Decl(noSilentNeverTypeLeak1.ts, 6, 31)) + + params?: unknown; +>params : Symbol(ParameterizedObject.params, Decl(noSilentNeverTypeLeak1.ts, 7, 15)) +} + +type ActionFunction< +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak1.ts, 9, 1)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 11, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 12, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + + TAction extends ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 13, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + +> = { + (ctx: TContext, params: TParams): void; +>ctx : Symbol(ctx, Decl(noSilentNeverTypeLeak1.ts, 16, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 11, 20)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 16, 17)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 12, 34)) + + _out_TAction?: TAction; +>_out_TAction : Symbol(_out_TAction, Decl(noSilentNeverTypeLeak1.ts, 16, 41)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 13, 60)) + +}; + +type ToParameterizedObject< +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 18, 2)) + + TParameterizedMap extends Record< +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak1.ts, 20, 27)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + + >, +> = Values<{ +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak1.ts, 0, 0)) + + [K in keyof TParameterizedMap & string]: { +>K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 26, 3)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak1.ts, 20, 27)) + + type: K; +>type : Symbol(type, Decl(noSilentNeverTypeLeak1.ts, 26, 44)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 26, 3)) + + params: TParameterizedMap[K]; +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 27, 12)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak1.ts, 20, 27)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 26, 3)) + + }; +}>; + +type CollectActions< +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak1.ts, 30, 3)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 32, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 33, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + +> = ( + { + context, +>context : Symbol(context, Decl(noSilentNeverTypeLeak1.ts, 36, 3)) + + enqueue, +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak1.ts, 37, 12)) + + }: { + context: TContext; +>context : Symbol(context, Decl(noSilentNeverTypeLeak1.ts, 39, 6)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 32, 20)) + + enqueue: (action: () => void) => void; +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak1.ts, 40, 22)) +>action : Symbol(action, Decl(noSilentNeverTypeLeak1.ts, 41, 14)) + + }, + params: TParams, +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 42, 4)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 33, 34)) + +) => void; + +declare function enqueueActions< +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 46, 32)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 47, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + + TAction extends ParameterizedObject = ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 48, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + +>( + collect: CollectActions, +>collect : Symbol(collect, Decl(noSilentNeverTypeLeak1.ts, 50, 2)) +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak1.ts, 30, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 46, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 47, 34)) + +): ActionFunction; +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak1.ts, 9, 1)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 46, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 47, 34)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 48, 60)) + +declare function setup< +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 54, 23)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) + + TActions extends Record< +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) + + > = {}, +>({ + types, +>types : Symbol(types, Decl(noSilentNeverTypeLeak1.ts, 60, 3)) + + actions, +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 61, 8)) + +}: { + types?: { context?: TContext }; +>types : Symbol(types, Decl(noSilentNeverTypeLeak1.ts, 63, 4)) +>context : Symbol(context, Decl(noSilentNeverTypeLeak1.ts, 64, 11)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 54, 23)) + + actions?: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 64, 33)) + + [K in keyof TActions]: ActionFunction< +>K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 66, 5)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak1.ts, 9, 1)) + + TContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 54, 23)) + + TActions[K], +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 66, 5)) + + ToParameterizedObject +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 18, 2)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) + + >; + }; +}): void; + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 74, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak1.ts, 75, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 76, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 76, 31)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 80, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak1.ts, 81, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 82, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 82, 31)) + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak1.ts, 82, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 83, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 83, 21)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 87, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak1.ts, 88, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 89, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 89, 31)) + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak1.ts, 89, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 90, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 90, 26)) + + }, +}); + diff --git a/tests/baselines/reference/noSilentNeverTypeLeak1.types b/tests/baselines/reference/noSilentNeverTypeLeak1.types new file mode 100644 index 0000000000000..609419f45757d --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak1.types @@ -0,0 +1,262 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak1.ts] //// + +=== noSilentNeverTypeLeak1.ts === +// https://github.com/microsoft/TypeScript/issues/62824 + +type Values = T[keyof T]; +>Values : Values +> : ^^^^^^^^^ + +type MachineContext = Record; +>MachineContext : MachineContext +> : ^^^^^^^^^^^^^^ + +interface ParameterizedObject { + type: string; +>type : string +> : ^^^^^^ + + params?: unknown; +>params : unknown +> : ^^^^^^^ +} + +type ActionFunction< +>ActionFunction : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; +>ctx : TContext +> : ^^^^^^^^ +>params : TParams +> : ^^^^^^^ + + _out_TAction?: TAction; +>_out_TAction : TAction | undefined +> : ^^^^^^^^^^^^^^^^^^^ + +}; + +type ToParameterizedObject< +>ToParameterizedObject : ToParameterizedObject +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap & string]: { + type: K; +>type : K +> : ^ + + params: TParameterizedMap[K]; +>params : TParameterizedMap[K] +> : ^^^^^^^^^^^^^^^^^^^^ + + }; +}>; + +type CollectActions< +>CollectActions : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, +>context : TContext +> : ^^^^^^^^ + + enqueue, +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ + + }: { + context: TContext; +>context : TContext +> : ^^^^^^^^ + + enqueue: (action: () => void) => void; +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ +>action : () => void +> : ^^^^^^ + + }, + params: TParams, +>params : TParams +> : ^^^^^^^ + +) => void; + +declare function enqueueActions< +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +>collect : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +): ActionFunction; + +declare function setup< +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + + actions, +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +}: { + types?: { context?: TContext }; +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ +>context : TContext | undefined +> : ^^^^^^^^^^^^^^^^^^^^ + + actions?: { +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), },} : { actions: { doStuff: ActionFunction; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), } : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },} : { actions: { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, } : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>(_, params: string) => {} : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>_ : MachineContext +> : ^^^^^^^^^^^^^^ +>params : string +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },} : { actions: { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, } : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>(_: any, params: string) => {} : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>_ : any +> : ^^^ +>params : string +> : ^^^^^^ + + }, +}); + diff --git a/tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt b/tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt new file mode 100644 index 0000000000000..a1a35cb966aca --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt @@ -0,0 +1,128 @@ +noSilentNeverTypeLeak2.ts(75,5): error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction'. + Type 'ParameterizedObject' is not assignable to type '{ type: "doStuff"; params: number; }'. + Types of property 'type' are incompatible. + Type 'string' is not assignable to type '"doStuff"'. +noSilentNeverTypeLeak2.ts(81,5): error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction>'. + Type 'ParameterizedObject' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type 'ParameterizedObject' is not assignable to type '{ type: "doOtherStuff"; params: string; }'. + Types of property 'type' are incompatible. + Type 'string' is not assignable to type '"doOtherStuff"'. +noSilentNeverTypeLeak2.ts(88,5): error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. + Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. + Types of property 'params' are incompatible. + Type 'unknown' is not assignable to type 'number'. + + +==== noSilentNeverTypeLeak2.ts (3 errors) ==== + type Values = T[keyof T]; + + type MachineContext = Record; + + interface ParameterizedObject { + type: string; + params?: unknown; + } + + type ActionFunction< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, + > = { + (ctx: TContext, params: TParams): void; + _out_TAction?: TAction; + }; + + type ToParameterizedObject< + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, + > = Values<{ + [K in keyof TParameterizedMap as K & string]: { + type: K & string; + params: TParameterizedMap[K]; + }; + }>; + + type CollectActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + > = ( + { + context, + enqueue, + }: { + context: TContext; + enqueue: (action: () => void) => void; + }, + params: TParams, + ) => void; + + declare function enqueueActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, + >( + collect: CollectActions, + ): ActionFunction; + + declare function setup< + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, + >({ + types, + actions, + }: { + types?: { context?: TContext }; + actions?: { + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; + }): void; + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction'. +!!! error TS2322: Type 'ParameterizedObject' is not assignable to type '{ type: "doStuff"; params: number; }'. +!!! error TS2322: Types of property 'type' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"doStuff"'. + }, + }); + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction>'. +!!! error TS2322: Type 'ParameterizedObject' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type 'ParameterizedObject' is not assignable to type '{ type: "doOtherStuff"; params: string; }'. +!!! error TS2322: Types of property 'type' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"doOtherStuff"'. + doOtherStuff: (_, params: string) => {}, + }, + }); + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. +!!! error TS2322: Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. +!!! error TS2322: Types of property 'params' are incompatible. +!!! error TS2322: Type 'unknown' is not assignable to type 'number'. + doOtherStuff: (_: any, params: string) => {}, + }, + }); + \ No newline at end of file diff --git a/tests/baselines/reference/noSilentNeverTypeLeak2.symbols b/tests/baselines/reference/noSilentNeverTypeLeak2.symbols new file mode 100644 index 0000000000000..89650a1f0bca5 --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak2.symbols @@ -0,0 +1,254 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak2.ts] //// + +=== noSilentNeverTypeLeak2.ts === +type Values = T[keyof T]; +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak2.ts, 0, 0)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak2.ts, 0, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak2.ts, 0, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak2.ts, 0, 12)) + +type MachineContext = Record; +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +interface ParameterizedObject { +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + + type: string; +>type : Symbol(ParameterizedObject.type, Decl(noSilentNeverTypeLeak2.ts, 4, 31)) + + params?: unknown; +>params : Symbol(ParameterizedObject.params, Decl(noSilentNeverTypeLeak2.ts, 5, 15)) +} + +type ActionFunction< +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 7, 1)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 9, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 10, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + + TAction extends ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 11, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + +> = { + (ctx: TContext, params: TParams): void; +>ctx : Symbol(ctx, Decl(noSilentNeverTypeLeak2.ts, 14, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 9, 20)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 14, 17)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 10, 34)) + + _out_TAction?: TAction; +>_out_TAction : Symbol(_out_TAction, Decl(noSilentNeverTypeLeak2.ts, 14, 41)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 11, 60)) + +}; + +type ToParameterizedObject< +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 16, 2)) + + TParameterizedMap extends Record< +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 18, 27)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + + >, +> = Values<{ +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak2.ts, 0, 0)) + + [K in keyof TParameterizedMap as K & string]: { +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 18, 27)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) + + type: K & string; +>type : Symbol(type, Decl(noSilentNeverTypeLeak2.ts, 24, 49)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) + + params: TParameterizedMap[K]; +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 25, 21)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 18, 27)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) + + }; +}>; + +type CollectActions< +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak2.ts, 28, 3)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 30, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 31, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + +> = ( + { + context, +>context : Symbol(context, Decl(noSilentNeverTypeLeak2.ts, 34, 3)) + + enqueue, +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak2.ts, 35, 12)) + + }: { + context: TContext; +>context : Symbol(context, Decl(noSilentNeverTypeLeak2.ts, 37, 6)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 30, 20)) + + enqueue: (action: () => void) => void; +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak2.ts, 38, 22)) +>action : Symbol(action, Decl(noSilentNeverTypeLeak2.ts, 39, 14)) + + }, + params: TParams, +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 40, 4)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 31, 34)) + +) => void; + +declare function enqueueActions< +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 44, 32)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 45, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + + TAction extends ParameterizedObject = ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 46, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + +>( + collect: CollectActions, +>collect : Symbol(collect, Decl(noSilentNeverTypeLeak2.ts, 48, 2)) +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak2.ts, 28, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 44, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 45, 34)) + +): ActionFunction; +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 7, 1)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 44, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 45, 34)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 46, 60)) + +declare function setup< +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 52, 23)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) + + TActions extends Record< +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) + + > = {}, +>({ + types, +>types : Symbol(types, Decl(noSilentNeverTypeLeak2.ts, 58, 3)) + + actions, +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 59, 8)) + +}: { + types?: { context?: TContext }; +>types : Symbol(types, Decl(noSilentNeverTypeLeak2.ts, 61, 4)) +>context : Symbol(context, Decl(noSilentNeverTypeLeak2.ts, 62, 11)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 52, 23)) + + actions?: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 62, 33)) + + [K in keyof TActions]: ActionFunction< +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 64, 5)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 7, 1)) + + TContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 52, 23)) + + TActions[K], +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 64, 5)) + + ToParameterizedObject +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 16, 2)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) + + >; + }; +}): void; + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 72, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 73, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 74, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 74, 31)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 78, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 79, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 80, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 80, 31)) + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak2.ts, 80, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 81, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 81, 21)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 85, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 86, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 87, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 87, 31)) + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak2.ts, 87, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 88, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 88, 26)) + + }, +}); + diff --git a/tests/baselines/reference/noSilentNeverTypeLeak2.types b/tests/baselines/reference/noSilentNeverTypeLeak2.types new file mode 100644 index 0000000000000..25b88f9348b1c --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak2.types @@ -0,0 +1,260 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak2.ts] //// + +=== noSilentNeverTypeLeak2.ts === +type Values = T[keyof T]; +>Values : Values +> : ^^^^^^^^^ + +type MachineContext = Record; +>MachineContext : MachineContext +> : ^^^^^^^^^^^^^^ + +interface ParameterizedObject { + type: string; +>type : string +> : ^^^^^^ + + params?: unknown; +>params : unknown +> : ^^^^^^^ +} + +type ActionFunction< +>ActionFunction : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; +>ctx : TContext +> : ^^^^^^^^ +>params : TParams +> : ^^^^^^^ + + _out_TAction?: TAction; +>_out_TAction : TAction | undefined +> : ^^^^^^^^^^^^^^^^^^^ + +}; + +type ToParameterizedObject< +>ToParameterizedObject : ToParameterizedObject +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap as K & string]: { + type: K & string; +>type : K & string +> : ^^^^^^^^^^ + + params: TParameterizedMap[K]; +>params : TParameterizedMap[K] +> : ^^^^^^^^^^^^^^^^^^^^ + + }; +}>; + +type CollectActions< +>CollectActions : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, +>context : TContext +> : ^^^^^^^^ + + enqueue, +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ + + }: { + context: TContext; +>context : TContext +> : ^^^^^^^^ + + enqueue: (action: () => void) => void; +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ +>action : () => void +> : ^^^^^^ + + }, + params: TParams, +>params : TParams +> : ^^^^^^^ + +) => void; + +declare function enqueueActions< +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +>collect : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +): ActionFunction; + +declare function setup< +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + + actions, +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +}: { + types?: { context?: TContext }; +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ +>context : TContext | undefined +> : ^^^^^^^^^^^^^^^^^^^^ + + actions?: { +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), },} : { actions: { doStuff: ActionFunction; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), } : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },} : { actions: { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, } : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>(_, params: string) => {} : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>_ : MachineContext +> : ^^^^^^^^^^^^^^ +>params : string +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },} : { actions: { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, } : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>(_: any, params: string) => {} : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>_ : any +> : ^^^ +>params : string +> : ^^^^^^ + + }, +}); + diff --git a/tests/cases/compiler/noSilentNeverTypeLeak1.ts b/tests/cases/compiler/noSilentNeverTypeLeak1.ts new file mode 100644 index 0000000000000..ccdb0d2498561 --- /dev/null +++ b/tests/cases/compiler/noSilentNeverTypeLeak1.ts @@ -0,0 +1,96 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/62824 + +type Values = T[keyof T]; + +type MachineContext = Record; + +interface ParameterizedObject { + type: string; + params?: unknown; +} + +type ActionFunction< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; + _out_TAction?: TAction; +}; + +type ToParameterizedObject< + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap & string]: { + type: K; + params: TParameterizedMap[K]; + }; +}>; + +type CollectActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, + enqueue, + }: { + context: TContext; + enqueue: (action: () => void) => void; + }, + params: TParams, +) => void; + +declare function enqueueActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +): ActionFunction; + +declare function setup< + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, + actions, +}: { + types?: { context?: TContext }; + actions?: { + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_, params: string) => {}, + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_: any, params: string) => {}, + }, +}); diff --git a/tests/cases/compiler/noSilentNeverTypeLeak2.ts b/tests/cases/compiler/noSilentNeverTypeLeak2.ts new file mode 100644 index 0000000000000..48c62c0efd255 --- /dev/null +++ b/tests/cases/compiler/noSilentNeverTypeLeak2.ts @@ -0,0 +1,94 @@ +// @strict: true +// @noEmit: true + +type Values = T[keyof T]; + +type MachineContext = Record; + +interface ParameterizedObject { + type: string; + params?: unknown; +} + +type ActionFunction< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; + _out_TAction?: TAction; +}; + +type ToParameterizedObject< + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap as K & string]: { + type: K & string; + params: TParameterizedMap[K]; + }; +}>; + +type CollectActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, + enqueue, + }: { + context: TContext; + enqueue: (action: () => void) => void; + }, + params: TParams, +) => void; + +declare function enqueueActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +): ActionFunction; + +declare function setup< + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, + actions, +}: { + types?: { context?: TContext }; + actions?: { + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_, params: string) => {}, + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_: any, params: string) => {}, + }, +}); From 2af1bf061fc03c625a70b5241e7f1ebb22b66c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 4 Dec 2025 13:25:33 +0100 Subject: [PATCH 2/2] add tests --- .../reference/noSilentNeverTypeLeak1.symbols | 283 ++--------------- .../reference/noSilentNeverTypeLeak1.types | 289 ++---------------- .../noSilentNeverTypeLeak2.errors.txt | 120 ++------ .../reference/noSilentNeverTypeLeak2.symbols | 272 +++++------------ .../reference/noSilentNeverTypeLeak2.types | 278 ++++++----------- ....txt => noSilentNeverTypeLeak3.errors.txt} | 4 +- .../reference/noSilentNeverTypeLeak3.symbols | 255 ++++++++++++++++ .../reference/noSilentNeverTypeLeak3.types | 262 ++++++++++++++++ .../noSilentNeverTypeLeak4.errors.txt | 128 ++++++++ .../reference/noSilentNeverTypeLeak4.symbols | 254 +++++++++++++++ .../reference/noSilentNeverTypeLeak4.types | 260 ++++++++++++++++ .../cases/compiler/noSilentNeverTypeLeak1.ts | 98 +----- .../cases/compiler/noSilentNeverTypeLeak2.ts | 86 ++---- .../cases/compiler/noSilentNeverTypeLeak3.ts | 96 ++++++ .../cases/compiler/noSilentNeverTypeLeak4.ts | 94 ++++++ 15 files changed, 1626 insertions(+), 1153 deletions(-) rename tests/baselines/reference/{noSilentNeverTypeLeak1.errors.txt => noSilentNeverTypeLeak3.errors.txt} (94%) create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak3.symbols create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak3.types create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak4.errors.txt create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak4.symbols create mode 100644 tests/baselines/reference/noSilentNeverTypeLeak4.types create mode 100644 tests/cases/compiler/noSilentNeverTypeLeak3.ts create mode 100644 tests/cases/compiler/noSilentNeverTypeLeak4.ts diff --git a/tests/baselines/reference/noSilentNeverTypeLeak1.symbols b/tests/baselines/reference/noSilentNeverTypeLeak1.symbols index 0574c6f9557fe..f8d6b272b75bb 100644 --- a/tests/baselines/reference/noSilentNeverTypeLeak1.symbols +++ b/tests/baselines/reference/noSilentNeverTypeLeak1.symbols @@ -1,255 +1,36 @@ //// [tests/cases/compiler/noSilentNeverTypeLeak1.ts] //// === noSilentNeverTypeLeak1.ts === -// https://github.com/microsoft/TypeScript/issues/62824 - -type Values = T[keyof T]; ->Values : Symbol(Values, Decl(noSilentNeverTypeLeak1.ts, 0, 0)) ->T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 12)) ->T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 12)) ->T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 12)) - -type MachineContext = Record; ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) ->Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) - -interface ParameterizedObject { ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - - type: string; ->type : Symbol(ParameterizedObject.type, Decl(noSilentNeverTypeLeak1.ts, 6, 31)) - - params?: unknown; ->params : Symbol(ParameterizedObject.params, Decl(noSilentNeverTypeLeak1.ts, 7, 15)) -} - -type ActionFunction< ->ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak1.ts, 9, 1)) - - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 11, 20)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) - - TParams extends ParameterizedObject["params"] | undefined, ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 12, 34)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - - TAction extends ParameterizedObject, ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 13, 60)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - -> = { - (ctx: TContext, params: TParams): void; ->ctx : Symbol(ctx, Decl(noSilentNeverTypeLeak1.ts, 16, 3)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 11, 20)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 16, 17)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 12, 34)) - - _out_TAction?: TAction; ->_out_TAction : Symbol(_out_TAction, Decl(noSilentNeverTypeLeak1.ts, 16, 41)) ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 13, 60)) - -}; - -type ToParameterizedObject< ->ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 18, 2)) - - TParameterizedMap extends Record< ->TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak1.ts, 20, 27)) ->Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) - - string, - ParameterizedObject["params"] | undefined ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - - >, -> = Values<{ ->Values : Symbol(Values, Decl(noSilentNeverTypeLeak1.ts, 0, 0)) - - [K in keyof TParameterizedMap & string]: { ->K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 26, 3)) ->TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak1.ts, 20, 27)) - - type: K; ->type : Symbol(type, Decl(noSilentNeverTypeLeak1.ts, 26, 44)) ->K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 26, 3)) - - params: TParameterizedMap[K]; ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 27, 12)) ->TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak1.ts, 20, 27)) ->K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 26, 3)) - - }; -}>; - -type CollectActions< ->CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak1.ts, 30, 3)) - - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 32, 20)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) - - TParams extends ParameterizedObject["params"] | undefined, ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 33, 34)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - -> = ( - { - context, ->context : Symbol(context, Decl(noSilentNeverTypeLeak1.ts, 36, 3)) - - enqueue, ->enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak1.ts, 37, 12)) - - }: { - context: TContext; ->context : Symbol(context, Decl(noSilentNeverTypeLeak1.ts, 39, 6)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 32, 20)) - - enqueue: (action: () => void) => void; ->enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak1.ts, 40, 22)) ->action : Symbol(action, Decl(noSilentNeverTypeLeak1.ts, 41, 14)) - - }, - params: TParams, ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 42, 4)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 33, 34)) - -) => void; - -declare function enqueueActions< ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) - - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 46, 32)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) - - TParams extends ParameterizedObject["params"] | undefined, ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 47, 34)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - - TAction extends ParameterizedObject = ParameterizedObject, ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 48, 60)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - ->( - collect: CollectActions, ->collect : Symbol(collect, Decl(noSilentNeverTypeLeak1.ts, 50, 2)) ->CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak1.ts, 30, 3)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 46, 32)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 47, 34)) - -): ActionFunction; ->ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak1.ts, 9, 1)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 46, 32)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak1.ts, 47, 34)) ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak1.ts, 48, 60)) - -declare function setup< ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) - - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 54, 23)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak1.ts, 2, 28)) - - TActions extends Record< ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) ->Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) - - string, - ParameterizedObject["params"] | undefined ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 4, 42)) - - > = {}, ->({ - types, ->types : Symbol(types, Decl(noSilentNeverTypeLeak1.ts, 60, 3)) - - actions, ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 61, 8)) - -}: { - types?: { context?: TContext }; ->types : Symbol(types, Decl(noSilentNeverTypeLeak1.ts, 63, 4)) ->context : Symbol(context, Decl(noSilentNeverTypeLeak1.ts, 64, 11)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 54, 23)) - - actions?: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 64, 33)) - - [K in keyof TActions]: ActionFunction< ->K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 66, 5)) ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) ->ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak1.ts, 9, 1)) - - TContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak1.ts, 54, 23)) - - TActions[K], ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) ->K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 66, 5)) - - ToParameterizedObject ->ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak1.ts, 18, 2)) ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak1.ts, 55, 34)) - - >; - }; -}): void; - -setup({ ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) - - actions: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 74, 7)) - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak1.ts, 75, 12)) ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 76, 29)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 76, 31)) - - }, -}); - -setup({ ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) - - actions: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 80, 7)) - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak1.ts, 81, 12)) ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 82, 29)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 82, 31)) - - doOtherStuff: (_, params: string) => {}, ->doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak1.ts, 82, 55)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 83, 19)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 83, 21)) - - }, -}); - -setup({ ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak1.ts, 52, 46)) - - actions: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak1.ts, 87, 7)) - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak1.ts, 88, 12)) ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak1.ts, 44, 10)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 89, 29)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 89, 31)) - - doOtherStuff: (_: any, params: string) => {}, ->doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak1.ts, 89, 55)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak1.ts, 90, 19)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak1.ts, 90, 26)) - - }, -}); +type Fn = (arg: T) => void; +>Fn : Symbol(Fn, Decl(noSilentNeverTypeLeak1.ts, 0, 0)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 0, 8)) +>arg : Symbol(arg, Decl(noSilentNeverTypeLeak1.ts, 0, 14)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 0, 8)) + +declare function fn1(): Fn; +>fn1 : Symbol(fn1, Decl(noSilentNeverTypeLeak1.ts, 0, 30)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 21)) +>Fn : Symbol(Fn, Decl(noSilentNeverTypeLeak1.ts, 0, 0)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 2, 21)) + +declare function fn2( +>fn2 : Symbol(fn2, Decl(noSilentNeverTypeLeak1.ts, 2, 33)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 4, 21)) + + cb: Fn<{ +>cb : Symbol(cb, Decl(noSilentNeverTypeLeak1.ts, 4, 24)) +>Fn : Symbol(Fn, Decl(noSilentNeverTypeLeak1.ts, 0, 0)) + + [K in keyof T & string]: T[K]; +>K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 6, 5)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 4, 21)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak1.ts, 4, 21)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak1.ts, 6, 5)) + + }>, +): void; + +fn2(fn1()); +>fn2 : Symbol(fn2, Decl(noSilentNeverTypeLeak1.ts, 2, 33)) +>fn1 : Symbol(fn1, Decl(noSilentNeverTypeLeak1.ts, 0, 30)) diff --git a/tests/baselines/reference/noSilentNeverTypeLeak1.types b/tests/baselines/reference/noSilentNeverTypeLeak1.types index 609419f45757d..35138ef7ac2ba 100644 --- a/tests/baselines/reference/noSilentNeverTypeLeak1.types +++ b/tests/baselines/reference/noSilentNeverTypeLeak1.types @@ -1,262 +1,35 @@ //// [tests/cases/compiler/noSilentNeverTypeLeak1.ts] //// === noSilentNeverTypeLeak1.ts === -// https://github.com/microsoft/TypeScript/issues/62824 - -type Values = T[keyof T]; ->Values : Values -> : ^^^^^^^^^ - -type MachineContext = Record; ->MachineContext : MachineContext -> : ^^^^^^^^^^^^^^ - -interface ParameterizedObject { - type: string; ->type : string -> : ^^^^^^ - - params?: unknown; ->params : unknown -> : ^^^^^^^ -} - -type ActionFunction< ->ActionFunction : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject, -> = { - (ctx: TContext, params: TParams): void; ->ctx : TContext -> : ^^^^^^^^ ->params : TParams -> : ^^^^^^^ - - _out_TAction?: TAction; ->_out_TAction : TAction | undefined -> : ^^^^^^^^^^^^^^^^^^^ - -}; - -type ToParameterizedObject< ->ToParameterizedObject : ToParameterizedObject -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - TParameterizedMap extends Record< - string, - ParameterizedObject["params"] | undefined - >, -> = Values<{ - [K in keyof TParameterizedMap & string]: { - type: K; ->type : K -> : ^ - - params: TParameterizedMap[K]; ->params : TParameterizedMap[K] -> : ^^^^^^^^^^^^^^^^^^^^ - - }; -}>; - -type CollectActions< ->CollectActions : CollectActions -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, -> = ( - { - context, ->context : TContext -> : ^^^^^^^^ - - enqueue, ->enqueue : (action: () => void) => void -> : ^ ^^ ^^^^^ - - }: { - context: TContext; ->context : TContext -> : ^^^^^^^^ - - enqueue: (action: () => void) => void; ->enqueue : (action: () => void) => void -> : ^ ^^ ^^^^^ ->action : () => void -> : ^^^^^^ - - }, - params: TParams, ->params : TParams -> : ^^^^^^^ - -) => void; - -declare function enqueueActions< ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ - - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject = ParameterizedObject, ->( - collect: CollectActions, ->collect : CollectActions -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -): ActionFunction; - -declare function setup< ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ - - TContext extends MachineContext, - TActions extends Record< - string, - ParameterizedObject["params"] | undefined - > = {}, ->({ - types, ->types : { context?: TContext; } | undefined -> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ - - actions, ->actions : { [K in keyof TActions]: ActionFunction>; } | undefined -> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -}: { - types?: { context?: TContext }; ->types : { context?: TContext; } | undefined -> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ->context : TContext | undefined -> : ^^^^^^^^^^^^^^^^^^^^ - - actions?: { ->actions : { [K in keyof TActions]: ActionFunction>; } | undefined -> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - [K in keyof TActions]: ActionFunction< - TContext, - TActions[K], - ToParameterizedObject - >; - }; -}): void; - -setup({ ->setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), },}) : void -> : ^^^^ ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ ->{ actions: { doStuff: enqueueActions((_, params: number) => {}), },} : { actions: { doStuff: ActionFunction; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - actions: { ->actions : { doStuff: ActionFunction; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ doStuff: enqueueActions((_, params: number) => {}), } : { doStuff: ActionFunction; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions((_, params: number) => {}) : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ ->(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ ->_ : { context: MachineContext; enqueue: (action: () => void) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ->params : number -> : ^^^^^^ - - }, -}); - -setup({ ->setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },}) : void -> : ^^^^ ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ ->{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },} : { actions: { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^ - - actions: { ->actions : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ ->{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, } : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions((_, params: number) => {}) : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ ->(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ ->_ : { context: MachineContext; enqueue: (action: () => void) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ->params : number -> : ^^^^^^ - - doOtherStuff: (_, params: string) => {}, ->doOtherStuff : (_: MachineContext, params: string) => void -> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ ->(_, params: string) => {} : (_: MachineContext, params: string) => void -> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ ->_ : MachineContext -> : ^^^^^^^^^^^^^^ ->params : string -> : ^^^^^^ - - }, -}); - -setup({ ->setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },}) : void -> : ^^^^ ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ ->{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },} : { actions: { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^ - - actions: { ->actions : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ ->{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, } : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : ActionFunction> -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions((_, params: number) => {}) : ActionFunction> -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ ->(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ ->_ : { context: MachineContext; enqueue: (action: () => void) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ->params : number -> : ^^^^^^ - - doOtherStuff: (_: any, params: string) => {}, ->doOtherStuff : (_: any, params: string) => void -> : ^ ^^ ^^ ^^ ^^^^^^^^^ ->(_: any, params: string) => {} : (_: any, params: string) => void -> : ^ ^^ ^^ ^^ ^^^^^^^^^ ->_ : any -> : ^^^ ->params : string -> : ^^^^^^ - - }, -}); +type Fn = (arg: T) => void; +>Fn : Fn +> : ^^^^^ +>arg : T +> : ^ + +declare function fn1(): Fn; +>fn1 : () => Fn +> : ^ ^^^^^^^ + +declare function fn2( +>fn2 : (cb: Fn<{ [K in keyof T & string]: T[K]; }>) => void +> : ^ ^^ ^^ ^^^^^ + + cb: Fn<{ +>cb : Fn<{ [K in keyof T & string]: T[K]; }> +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [K in keyof T & string]: T[K]; + }>, +): void; + +fn2(fn1()); +>fn2(fn1()) : void +> : ^^^^ +>fn2 : (cb: Fn<{ [K in keyof T & string]: T[K]; }>) => void +> : ^ ^^ ^^ ^^^^^ +>fn1() : Fn<{}> +> : ^^^^^^ +>fn1 : () => Fn +> : ^ ^^^^^^^ diff --git a/tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt b/tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt index a1a35cb966aca..9818c097906c1 100644 --- a/tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt +++ b/tests/baselines/reference/noSilentNeverTypeLeak2.errors.txt @@ -1,13 +1,4 @@ -noSilentNeverTypeLeak2.ts(75,5): error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction'. - Type 'ParameterizedObject' is not assignable to type '{ type: "doStuff"; params: number; }'. - Types of property 'type' are incompatible. - Type 'string' is not assignable to type '"doStuff"'. -noSilentNeverTypeLeak2.ts(81,5): error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction>'. - Type 'ParameterizedObject' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. - Type 'ParameterizedObject' is not assignable to type '{ type: "doOtherStuff"; params: string; }'. - Types of property 'type' are incompatible. - Type 'string' is not assignable to type '"doOtherStuff"'. -noSilentNeverTypeLeak2.ts(88,5): error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. +noSilentNeverTypeLeak2.ts(36,3): error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. @@ -15,114 +6,55 @@ noSilentNeverTypeLeak2.ts(88,5): error TS2322: Type 'ActionFunction = T[keyof T]; - type MachineContext = Record; - interface ParameterizedObject { type: string; params?: unknown; } - type ActionFunction< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject, - > = { - (ctx: TContext, params: TParams): void; + type ActionFunction = { + (params: TParams): void; _out_TAction?: TAction; }; - type ToParameterizedObject< - TParameterizedMap extends Record< - string, - ParameterizedObject["params"] | undefined - >, - > = Values<{ - [K in keyof TParameterizedMap as K & string]: { - type: K & string; + type ToParameterizedObject = Values<{ + [K in keyof TParameterizedMap & string]: { + type: K; params: TParameterizedMap[K]; }; }>; - type CollectActions< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - > = ( - { - context, - enqueue, - }: { - context: TContext; - enqueue: (action: () => void) => void; - }, - params: TParams, - ) => void; - - declare function enqueueActions< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject = ParameterizedObject, - >( - collect: CollectActions, - ): ActionFunction; + declare function enqueueActions( + collect: (params: TParams) => void, + ): ActionFunction; - declare function setup< - TContext extends MachineContext, - TActions extends Record< - string, - ParameterizedObject["params"] | undefined - > = {}, - >({ - types, - actions, - }: { - types?: { context?: TContext }; - actions?: { - [K in keyof TActions]: ActionFunction< - TContext, - TActions[K], - ToParameterizedObject - >; - }; + declare function setup(actions: { + [K in keyof TActions]: ActionFunction< + TActions[K], + ToParameterizedObject + >; }): void; setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - ~~~~~~~ -!!! error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction'. -!!! error TS2322: Type 'ParameterizedObject' is not assignable to type '{ type: "doStuff"; params: number; }'. -!!! error TS2322: Types of property 'type' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type '"doStuff"'. - }, - }); - - setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - ~~~~~~~ -!!! error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction>'. -!!! error TS2322: Type 'ParameterizedObject' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. -!!! error TS2322: Type 'ParameterizedObject' is not assignable to type '{ type: "doOtherStuff"; params: string; }'. -!!! error TS2322: Types of property 'type' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type '"doOtherStuff"'. - doOtherStuff: (_, params: string) => {}, - }, + doStuff: enqueueActions((params: number) => {}), }); setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - ~~~~~~~ -!!! error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. + doStuff: enqueueActions((params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. !!! error TS2322: Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. !!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. !!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. !!! error TS2322: Types of property 'params' are incompatible. !!! error TS2322: Type 'unknown' is not assignable to type 'number'. - doOtherStuff: (_: any, params: string) => {}, - }, +!!! related TS6500 noSilentNeverTypeLeak2.ts:36:3: The expected type comes from property 'doStuff' which is declared here on type '{ doStuff: ActionFunction>; doOtherStuff: ActionFunction>; }' + doOtherStuff: (params: string) => {}, }); - \ No newline at end of file + + setup({ + doStuff: enqueueActions((params: number) => {}), + doOtherStuff: (params) => {}, + }); \ No newline at end of file diff --git a/tests/baselines/reference/noSilentNeverTypeLeak2.symbols b/tests/baselines/reference/noSilentNeverTypeLeak2.symbols index 89650a1f0bca5..2d5e0d30ab850 100644 --- a/tests/baselines/reference/noSilentNeverTypeLeak2.symbols +++ b/tests/baselines/reference/noSilentNeverTypeLeak2.symbols @@ -7,248 +7,124 @@ type Values = T[keyof T]; >T : Symbol(T, Decl(noSilentNeverTypeLeak2.ts, 0, 12)) >T : Symbol(T, Decl(noSilentNeverTypeLeak2.ts, 0, 12)) -type MachineContext = Record; ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) ->Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) - interface ParameterizedObject { ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) type: string; ->type : Symbol(ParameterizedObject.type, Decl(noSilentNeverTypeLeak2.ts, 4, 31)) +>type : Symbol(ParameterizedObject.type, Decl(noSilentNeverTypeLeak2.ts, 2, 31)) params?: unknown; ->params : Symbol(ParameterizedObject.params, Decl(noSilentNeverTypeLeak2.ts, 5, 15)) +>params : Symbol(ParameterizedObject.params, Decl(noSilentNeverTypeLeak2.ts, 3, 15)) } -type ActionFunction< ->ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 7, 1)) - - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 9, 20)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) - - TParams extends ParameterizedObject["params"] | undefined, ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 10, 34)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) - - TAction extends ParameterizedObject, ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 11, 60)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) +type ActionFunction = { +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 5, 1)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 7, 20)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 7, 28)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) -> = { - (ctx: TContext, params: TParams): void; ->ctx : Symbol(ctx, Decl(noSilentNeverTypeLeak2.ts, 14, 3)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 9, 20)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 14, 17)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 10, 34)) + (params: TParams): void; +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 8, 3)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 7, 20)) _out_TAction?: TAction; ->_out_TAction : Symbol(_out_TAction, Decl(noSilentNeverTypeLeak2.ts, 14, 41)) ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 11, 60)) +>_out_TAction : Symbol(_out_TAction, Decl(noSilentNeverTypeLeak2.ts, 8, 26)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 7, 28)) }; -type ToParameterizedObject< ->ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 16, 2)) - - TParameterizedMap extends Record< ->TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 18, 27)) ->Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) - - string, - ParameterizedObject["params"] | undefined ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) - - >, -> = Values<{ +type ToParameterizedObject = Values<{ +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 10, 2)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 12, 27)) >Values : Symbol(Values, Decl(noSilentNeverTypeLeak2.ts, 0, 0)) - [K in keyof TParameterizedMap as K & string]: { ->K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) ->TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 18, 27)) ->K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) + [K in keyof TParameterizedMap & string]: { +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 13, 3)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 12, 27)) - type: K & string; ->type : Symbol(type, Decl(noSilentNeverTypeLeak2.ts, 24, 49)) ->K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) + type: K; +>type : Symbol(type, Decl(noSilentNeverTypeLeak2.ts, 13, 44)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 13, 3)) params: TParameterizedMap[K]; ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 25, 21)) ->TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 18, 27)) ->K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 14, 12)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak2.ts, 12, 27)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 13, 3)) }; }>; -type CollectActions< ->CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak2.ts, 28, 3)) - - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 30, 20)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) - - TParams extends ParameterizedObject["params"] | undefined, ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 31, 34)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) - -> = ( - { - context, ->context : Symbol(context, Decl(noSilentNeverTypeLeak2.ts, 34, 3)) - - enqueue, ->enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak2.ts, 35, 12)) - - }: { - context: TContext; ->context : Symbol(context, Decl(noSilentNeverTypeLeak2.ts, 37, 6)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 30, 20)) - - enqueue: (action: () => void) => void; ->enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak2.ts, 38, 22)) ->action : Symbol(action, Decl(noSilentNeverTypeLeak2.ts, 39, 14)) - - }, - params: TParams, ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 40, 4)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 31, 34)) - -) => void; +declare function enqueueActions( +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 17, 3)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 19, 32)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 19, 40)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) -declare function enqueueActions< ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) + collect: (params: TParams) => void, +>collect : Symbol(collect, Decl(noSilentNeverTypeLeak2.ts, 19, 78)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 20, 12)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 19, 32)) - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 44, 32)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) +): ActionFunction; +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 5, 1)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 19, 32)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 19, 40)) - TParams extends ParameterizedObject["params"] | undefined, ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 45, 34)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) +declare function setup(actions: { +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 21, 36)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 23, 23)) +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 23, 33)) - TAction extends ParameterizedObject = ParameterizedObject, ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 46, 60)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) - ->( - collect: CollectActions, ->collect : Symbol(collect, Decl(noSilentNeverTypeLeak2.ts, 48, 2)) ->CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak2.ts, 28, 3)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 44, 32)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 45, 34)) - -): ActionFunction; ->ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 7, 1)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 44, 32)) ->TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak2.ts, 45, 34)) ->TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak2.ts, 46, 60)) - -declare function setup< ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) - - TContext extends MachineContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 52, 23)) ->MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak2.ts, 0, 28)) - - TActions extends Record< ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) ->Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) - - string, - ParameterizedObject["params"] | undefined ->ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 2, 42)) - - > = {}, ->({ - types, ->types : Symbol(types, Decl(noSilentNeverTypeLeak2.ts, 58, 3)) - - actions, ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 59, 8)) + [K in keyof TActions]: ActionFunction< +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 23, 23)) +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 5, 1)) -}: { - types?: { context?: TContext }; ->types : Symbol(types, Decl(noSilentNeverTypeLeak2.ts, 61, 4)) ->context : Symbol(context, Decl(noSilentNeverTypeLeak2.ts, 62, 11)) ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 52, 23)) + TActions[K], +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 23, 23)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 24, 3)) - actions?: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 62, 33)) + ToParameterizedObject +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 10, 2)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 23, 23)) - [K in keyof TActions]: ActionFunction< ->K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 64, 5)) ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) ->ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak2.ts, 7, 1)) - - TContext, ->TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak2.ts, 52, 23)) - - TActions[K], ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) ->K : Symbol(K, Decl(noSilentNeverTypeLeak2.ts, 64, 5)) - - ToParameterizedObject ->ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak2.ts, 16, 2)) ->TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak2.ts, 53, 34)) - - >; - }; + >; }): void; setup({ ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) - - actions: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 72, 7)) +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 21, 36)) - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 73, 12)) ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 74, 29)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 74, 31)) + doStuff: enqueueActions((params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 30, 7)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 17, 3)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 31, 27)) - }, }); setup({ ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 21, 36)) - actions: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 78, 7)) + doStuff: enqueueActions((params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 34, 7)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 17, 3)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 35, 27)) - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 79, 12)) ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 80, 29)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 80, 31)) + doOtherStuff: (params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak2.ts, 35, 50)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 36, 17)) - doOtherStuff: (_, params: string) => {}, ->doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak2.ts, 80, 55)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 81, 19)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 81, 21)) - - }, }); setup({ ->setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 50, 46)) - - actions: { ->actions : Symbol(actions, Decl(noSilentNeverTypeLeak2.ts, 85, 7)) +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak2.ts, 21, 36)) - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 86, 12)) ->enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 42, 10)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 87, 29)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 87, 31)) + doStuff: enqueueActions((params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak2.ts, 39, 7)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak2.ts, 17, 3)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 40, 27)) - doOtherStuff: (_: any, params: string) => {}, ->doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak2.ts, 87, 55)) ->_ : Symbol(_, Decl(noSilentNeverTypeLeak2.ts, 88, 19)) ->params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 88, 26)) + doOtherStuff: (params) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak2.ts, 40, 50)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak2.ts, 41, 17)) - }, }); - diff --git a/tests/baselines/reference/noSilentNeverTypeLeak2.types b/tests/baselines/reference/noSilentNeverTypeLeak2.types index 25b88f9348b1c..6ca10badace9f 100644 --- a/tests/baselines/reference/noSilentNeverTypeLeak2.types +++ b/tests/baselines/reference/noSilentNeverTypeLeak2.types @@ -5,10 +5,6 @@ type Values = T[keyof T]; >Values : Values > : ^^^^^^^^^ -type MachineContext = Record; ->MachineContext : MachineContext -> : ^^^^^^^^^^^^^^ - interface ParameterizedObject { type: string; >type : string @@ -19,17 +15,11 @@ interface ParameterizedObject { > : ^^^^^^^ } -type ActionFunction< ->ActionFunction : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +type ActionFunction = { +>ActionFunction : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject, -> = { - (ctx: TContext, params: TParams): void; ->ctx : TContext -> : ^^^^^^^^ + (params: TParams): void; >params : TParams > : ^^^^^^^ @@ -39,19 +29,14 @@ type ActionFunction< }; -type ToParameterizedObject< +type ToParameterizedObject = Values<{ >ToParameterizedObject : ToParameterizedObject > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - TParameterizedMap extends Record< - string, - ParameterizedObject["params"] | undefined - >, -> = Values<{ - [K in keyof TParameterizedMap as K & string]: { - type: K & string; ->type : K & string -> : ^^^^^^^^^^ + [K in keyof TParameterizedMap & string]: { + type: K; +>type : K +> : ^ params: TParameterizedMap[K]; >params : TParameterizedMap[K] @@ -60,201 +45,108 @@ type ToParameterizedObject< }; }>; -type CollectActions< ->CollectActions : CollectActions -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, -> = ( - { - context, ->context : TContext -> : ^^^^^^^^ - - enqueue, ->enqueue : (action: () => void) => void -> : ^ ^^ ^^^^^ +declare function enqueueActions( +>enqueueActions : (collect: (params: TParams) => void) => ActionFunction +> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ - }: { - context: TContext; ->context : TContext -> : ^^^^^^^^ - - enqueue: (action: () => void) => void; ->enqueue : (action: () => void) => void -> : ^ ^^ ^^^^^ ->action : () => void -> : ^^^^^^ - - }, - params: TParams, + collect: (params: TParams) => void, +>collect : (params: TParams) => void +> : ^ ^^ ^^^^^ >params : TParams > : ^^^^^^^ -) => void; - -declare function enqueueActions< ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ - - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject = ParameterizedObject, ->( - collect: CollectActions, ->collect : CollectActions -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -): ActionFunction; - -declare function setup< ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ - - TContext extends MachineContext, - TActions extends Record< - string, - ParameterizedObject["params"] | undefined - > = {}, ->({ - types, ->types : { context?: TContext; } | undefined -> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ - - actions, ->actions : { [K in keyof TActions]: ActionFunction>; } | undefined -> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -}: { - types?: { context?: TContext }; ->types : { context?: TContext; } | undefined -> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ->context : TContext | undefined -> : ^^^^^^^^^^^^^^^^^^^^ +): ActionFunction; - actions?: { ->actions : { [K in keyof TActions]: ActionFunction>; } | undefined -> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +declare function setup(actions: { +>setup : (actions: { [K in keyof TActions]: ActionFunction>; }) => void +> : ^ ^^ ^^ ^^^^^ +>actions : { [K in keyof TActions]: ActionFunction>; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - [K in keyof TActions]: ActionFunction< - TContext, - TActions[K], - ToParameterizedObject - >; - }; + [K in keyof TActions]: ActionFunction< + TActions[K], + ToParameterizedObject + >; }): void; setup({ ->setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), },}) : void -> : ^^^^ ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ ->{ actions: { doStuff: enqueueActions((_, params: number) => {}), },} : { actions: { doStuff: ActionFunction; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - actions: { ->actions : { doStuff: ActionFunction; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ doStuff: enqueueActions((_, params: number) => {}), } : { doStuff: ActionFunction; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions((_, params: number) => {}) : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ ->(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ ->_ : { context: MachineContext; enqueue: (action: () => void) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>setup({ doStuff: enqueueActions((params: number) => {}),}) : void +> : ^^^^ +>setup : (actions: { [K in keyof TActions]: ActionFunction>; }) => void +> : ^ ^^ ^^ ^^^^^ +>{ doStuff: enqueueActions((params: number) => {}),} : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + doStuff: enqueueActions((params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: (params: TParams) => void) => ActionFunction +> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>(params: number) => {} : (params: number) => void +> : ^ ^^ ^^^^^^^^^ >params : number > : ^^^^^^ - }, }); setup({ ->setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },}) : void -> : ^^^^ ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ ->{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },} : { actions: { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^ - - actions: { ->actions : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ ->{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, } : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions((_, params: number) => {}) : ActionFunction -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ ->(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ ->_ : { context: MachineContext; enqueue: (action: () => void) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>setup({ doStuff: enqueueActions((params: number) => {}), doOtherStuff: (params: string) => {},}) : void +> : ^^^^ +>setup : (actions: { [K in keyof TActions]: ActionFunction>; }) => void +> : ^ ^^ ^^ ^^^^^ +>{ doStuff: enqueueActions((params: number) => {}), doOtherStuff: (params: string) => {},} : { doStuff: ActionFunction>; doOtherStuff: (params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((params: number) => {}), +>doStuff : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((params: number) => {}) : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: (params: TParams) => void) => ActionFunction +> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>(params: number) => {} : (params: number) => void +> : ^ ^^ ^^^^^^^^^ >params : number > : ^^^^^^ - doOtherStuff: (_, params: string) => {}, ->doOtherStuff : (_: MachineContext, params: string) => void -> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ ->(_, params: string) => {} : (_: MachineContext, params: string) => void -> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ ->_ : MachineContext -> : ^^^^^^^^^^^^^^ + doOtherStuff: (params: string) => {}, +>doOtherStuff : (params: string) => void +> : ^ ^^ ^^^^^^^^^ +>(params: string) => {} : (params: string) => void +> : ^ ^^ ^^^^^^^^^ >params : string > : ^^^^^^ - }, }); setup({ ->setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },}) : void -> : ^^^^ ->setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ ->{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },} : { actions: { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^ - - actions: { ->actions : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ ->{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, } : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ - - doStuff: enqueueActions((_, params: number) => {}), ->doStuff : ActionFunction> -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions((_, params: number) => {}) : ActionFunction> -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->enqueueActions : (collect: CollectActions) => ActionFunction -> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ ->(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ ->_ : { context: MachineContext; enqueue: (action: () => void) => void; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>setup({ doStuff: enqueueActions((params: number) => {}), doOtherStuff: (params) => {},}) : void +> : ^^^^ +>setup : (actions: { [K in keyof TActions]: ActionFunction>; }) => void +> : ^ ^^ ^^ ^^^^^ +>{ doStuff: enqueueActions((params: number) => {}), doOtherStuff: (params) => {},} : { doStuff: ActionFunction; doOtherStuff: (params: unknown) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ + + doStuff: enqueueActions((params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: (params: TParams) => void) => ActionFunction +> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>(params: number) => {} : (params: number) => void +> : ^ ^^ ^^^^^^^^^ >params : number > : ^^^^^^ - doOtherStuff: (_: any, params: string) => {}, ->doOtherStuff : (_: any, params: string) => void -> : ^ ^^ ^^ ^^ ^^^^^^^^^ ->(_: any, params: string) => {} : (_: any, params: string) => void -> : ^ ^^ ^^ ^^ ^^^^^^^^^ ->_ : any -> : ^^^ ->params : string -> : ^^^^^^ + doOtherStuff: (params) => {}, +>doOtherStuff : (params: unknown) => void +> : ^ ^^^^^^^^^^^^^^^^^^ +>(params) => {} : (params: unknown) => void +> : ^ ^^^^^^^^^^^^^^^^^^ +>params : unknown +> : ^^^^^^^ - }, }); - diff --git a/tests/baselines/reference/noSilentNeverTypeLeak1.errors.txt b/tests/baselines/reference/noSilentNeverTypeLeak3.errors.txt similarity index 94% rename from tests/baselines/reference/noSilentNeverTypeLeak1.errors.txt rename to tests/baselines/reference/noSilentNeverTypeLeak3.errors.txt index f2353247675ff..e7c0caa8e6878 100644 --- a/tests/baselines/reference/noSilentNeverTypeLeak1.errors.txt +++ b/tests/baselines/reference/noSilentNeverTypeLeak3.errors.txt @@ -1,4 +1,4 @@ -noSilentNeverTypeLeak1.ts(90,5): error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. +noSilentNeverTypeLeak3.ts(90,5): error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. @@ -6,7 +6,7 @@ noSilentNeverTypeLeak1.ts(90,5): error TS2322: Type 'ActionFunction = T[keyof T]; diff --git a/tests/baselines/reference/noSilentNeverTypeLeak3.symbols b/tests/baselines/reference/noSilentNeverTypeLeak3.symbols new file mode 100644 index 0000000000000..a9bd18dbb9c80 --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak3.symbols @@ -0,0 +1,255 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak3.ts] //// + +=== noSilentNeverTypeLeak3.ts === +// https://github.com/microsoft/TypeScript/issues/62824 + +type Values = T[keyof T]; +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak3.ts, 0, 0)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak3.ts, 2, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak3.ts, 2, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak3.ts, 2, 12)) + +type MachineContext = Record; +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak3.ts, 2, 28)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +interface ParameterizedObject { +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + + type: string; +>type : Symbol(ParameterizedObject.type, Decl(noSilentNeverTypeLeak3.ts, 6, 31)) + + params?: unknown; +>params : Symbol(ParameterizedObject.params, Decl(noSilentNeverTypeLeak3.ts, 7, 15)) +} + +type ActionFunction< +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak3.ts, 9, 1)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 11, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak3.ts, 2, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak3.ts, 12, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + + TAction extends ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak3.ts, 13, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + +> = { + (ctx: TContext, params: TParams): void; +>ctx : Symbol(ctx, Decl(noSilentNeverTypeLeak3.ts, 16, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 11, 20)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 16, 17)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak3.ts, 12, 34)) + + _out_TAction?: TAction; +>_out_TAction : Symbol(_out_TAction, Decl(noSilentNeverTypeLeak3.ts, 16, 41)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak3.ts, 13, 60)) + +}; + +type ToParameterizedObject< +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 18, 2)) + + TParameterizedMap extends Record< +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak3.ts, 20, 27)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + + >, +> = Values<{ +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak3.ts, 0, 0)) + + [K in keyof TParameterizedMap & string]: { +>K : Symbol(K, Decl(noSilentNeverTypeLeak3.ts, 26, 3)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak3.ts, 20, 27)) + + type: K; +>type : Symbol(type, Decl(noSilentNeverTypeLeak3.ts, 26, 44)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak3.ts, 26, 3)) + + params: TParameterizedMap[K]; +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 27, 12)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak3.ts, 20, 27)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak3.ts, 26, 3)) + + }; +}>; + +type CollectActions< +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak3.ts, 30, 3)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 32, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak3.ts, 2, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak3.ts, 33, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + +> = ( + { + context, +>context : Symbol(context, Decl(noSilentNeverTypeLeak3.ts, 36, 3)) + + enqueue, +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak3.ts, 37, 12)) + + }: { + context: TContext; +>context : Symbol(context, Decl(noSilentNeverTypeLeak3.ts, 39, 6)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 32, 20)) + + enqueue: (action: () => void) => void; +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak3.ts, 40, 22)) +>action : Symbol(action, Decl(noSilentNeverTypeLeak3.ts, 41, 14)) + + }, + params: TParams, +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 42, 4)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak3.ts, 33, 34)) + +) => void; + +declare function enqueueActions< +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak3.ts, 44, 10)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 46, 32)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak3.ts, 2, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak3.ts, 47, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + + TAction extends ParameterizedObject = ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak3.ts, 48, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + +>( + collect: CollectActions, +>collect : Symbol(collect, Decl(noSilentNeverTypeLeak3.ts, 50, 2)) +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak3.ts, 30, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 46, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak3.ts, 47, 34)) + +): ActionFunction; +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak3.ts, 9, 1)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 46, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak3.ts, 47, 34)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak3.ts, 48, 60)) + +declare function setup< +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak3.ts, 52, 46)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 54, 23)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak3.ts, 2, 28)) + + TActions extends Record< +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak3.ts, 55, 34)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 4, 42)) + + > = {}, +>({ + types, +>types : Symbol(types, Decl(noSilentNeverTypeLeak3.ts, 60, 3)) + + actions, +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak3.ts, 61, 8)) + +}: { + types?: { context?: TContext }; +>types : Symbol(types, Decl(noSilentNeverTypeLeak3.ts, 63, 4)) +>context : Symbol(context, Decl(noSilentNeverTypeLeak3.ts, 64, 11)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 54, 23)) + + actions?: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak3.ts, 64, 33)) + + [K in keyof TActions]: ActionFunction< +>K : Symbol(K, Decl(noSilentNeverTypeLeak3.ts, 66, 5)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak3.ts, 55, 34)) +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak3.ts, 9, 1)) + + TContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak3.ts, 54, 23)) + + TActions[K], +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak3.ts, 55, 34)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak3.ts, 66, 5)) + + ToParameterizedObject +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak3.ts, 18, 2)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak3.ts, 55, 34)) + + >; + }; +}): void; + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak3.ts, 52, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak3.ts, 74, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak3.ts, 75, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak3.ts, 44, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak3.ts, 76, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 76, 31)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak3.ts, 52, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak3.ts, 80, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak3.ts, 81, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak3.ts, 44, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak3.ts, 82, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 82, 31)) + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak3.ts, 82, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak3.ts, 83, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 83, 21)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak3.ts, 52, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak3.ts, 87, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak3.ts, 88, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak3.ts, 44, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak3.ts, 89, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 89, 31)) + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak3.ts, 89, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak3.ts, 90, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak3.ts, 90, 26)) + + }, +}); + diff --git a/tests/baselines/reference/noSilentNeverTypeLeak3.types b/tests/baselines/reference/noSilentNeverTypeLeak3.types new file mode 100644 index 0000000000000..3acae103e33fc --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak3.types @@ -0,0 +1,262 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak3.ts] //// + +=== noSilentNeverTypeLeak3.ts === +// https://github.com/microsoft/TypeScript/issues/62824 + +type Values = T[keyof T]; +>Values : Values +> : ^^^^^^^^^ + +type MachineContext = Record; +>MachineContext : MachineContext +> : ^^^^^^^^^^^^^^ + +interface ParameterizedObject { + type: string; +>type : string +> : ^^^^^^ + + params?: unknown; +>params : unknown +> : ^^^^^^^ +} + +type ActionFunction< +>ActionFunction : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; +>ctx : TContext +> : ^^^^^^^^ +>params : TParams +> : ^^^^^^^ + + _out_TAction?: TAction; +>_out_TAction : TAction | undefined +> : ^^^^^^^^^^^^^^^^^^^ + +}; + +type ToParameterizedObject< +>ToParameterizedObject : ToParameterizedObject +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap & string]: { + type: K; +>type : K +> : ^ + + params: TParameterizedMap[K]; +>params : TParameterizedMap[K] +> : ^^^^^^^^^^^^^^^^^^^^ + + }; +}>; + +type CollectActions< +>CollectActions : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, +>context : TContext +> : ^^^^^^^^ + + enqueue, +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ + + }: { + context: TContext; +>context : TContext +> : ^^^^^^^^ + + enqueue: (action: () => void) => void; +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ +>action : () => void +> : ^^^^^^ + + }, + params: TParams, +>params : TParams +> : ^^^^^^^ + +) => void; + +declare function enqueueActions< +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +>collect : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +): ActionFunction; + +declare function setup< +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + + actions, +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +}: { + types?: { context?: TContext }; +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ +>context : TContext | undefined +> : ^^^^^^^^^^^^^^^^^^^^ + + actions?: { +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), },} : { actions: { doStuff: ActionFunction; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), } : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },} : { actions: { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, } : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>(_, params: string) => {} : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>_ : MachineContext +> : ^^^^^^^^^^^^^^ +>params : string +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },} : { actions: { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, } : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>(_: any, params: string) => {} : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>_ : any +> : ^^^ +>params : string +> : ^^^^^^ + + }, +}); + diff --git a/tests/baselines/reference/noSilentNeverTypeLeak4.errors.txt b/tests/baselines/reference/noSilentNeverTypeLeak4.errors.txt new file mode 100644 index 0000000000000..8d7fc3381d346 --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak4.errors.txt @@ -0,0 +1,128 @@ +noSilentNeverTypeLeak4.ts(75,5): error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction'. + Type 'ParameterizedObject' is not assignable to type '{ type: "doStuff"; params: number; }'. + Types of property 'type' are incompatible. + Type 'string' is not assignable to type '"doStuff"'. +noSilentNeverTypeLeak4.ts(81,5): error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction>'. + Type 'ParameterizedObject' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type 'ParameterizedObject' is not assignable to type '{ type: "doOtherStuff"; params: string; }'. + Types of property 'type' are incompatible. + Type 'string' is not assignable to type '"doOtherStuff"'. +noSilentNeverTypeLeak4.ts(88,5): error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. + Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. + Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. + Types of property 'params' are incompatible. + Type 'unknown' is not assignable to type 'number'. + + +==== noSilentNeverTypeLeak4.ts (3 errors) ==== + type Values = T[keyof T]; + + type MachineContext = Record; + + interface ParameterizedObject { + type: string; + params?: unknown; + } + + type ActionFunction< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, + > = { + (ctx: TContext, params: TParams): void; + _out_TAction?: TAction; + }; + + type ToParameterizedObject< + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, + > = Values<{ + [K in keyof TParameterizedMap as K & string]: { + type: K & string; + params: TParameterizedMap[K]; + }; + }>; + + type CollectActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + > = ( + { + context, + enqueue, + }: { + context: TContext; + enqueue: (action: () => void) => void; + }, + params: TParams, + ) => void; + + declare function enqueueActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, + >( + collect: CollectActions, + ): ActionFunction; + + declare function setup< + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, + >({ + types, + actions, + }: { + types?: { context?: TContext }; + actions?: { + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; + }): void; + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction'. +!!! error TS2322: Type 'ParameterizedObject' is not assignable to type '{ type: "doStuff"; params: number; }'. +!!! error TS2322: Types of property 'type' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"doStuff"'. + }, + }); + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction' is not assignable to type 'ActionFunction>'. +!!! error TS2322: Type 'ParameterizedObject' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type 'ParameterizedObject' is not assignable to type '{ type: "doOtherStuff"; params: string; }'. +!!! error TS2322: Types of property 'type' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type '"doOtherStuff"'. + doOtherStuff: (_, params: string) => {}, + }, + }); + + setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + ~~~~~~~ +!!! error TS2322: Type 'ActionFunction>' is not assignable to type 'ActionFunction>'. +!!! error TS2322: Type 'ToParameterizedObject<{ doStuff: unknown; doOtherStuff: string; }>' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type 'ToParameterizedObject<{ doStuff: number; doOtherStuff: string; }>'. +!!! error TS2322: Type '{ type: "doStuff"; params: unknown; }' is not assignable to type '{ type: "doStuff"; params: number; }'. +!!! error TS2322: Types of property 'params' are incompatible. +!!! error TS2322: Type 'unknown' is not assignable to type 'number'. + doOtherStuff: (_: any, params: string) => {}, + }, + }); + \ No newline at end of file diff --git a/tests/baselines/reference/noSilentNeverTypeLeak4.symbols b/tests/baselines/reference/noSilentNeverTypeLeak4.symbols new file mode 100644 index 0000000000000..68992120f5883 --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak4.symbols @@ -0,0 +1,254 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak4.ts] //// + +=== noSilentNeverTypeLeak4.ts === +type Values = T[keyof T]; +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak4.ts, 0, 0)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak4.ts, 0, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak4.ts, 0, 12)) +>T : Symbol(T, Decl(noSilentNeverTypeLeak4.ts, 0, 12)) + +type MachineContext = Record; +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak4.ts, 0, 28)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +interface ParameterizedObject { +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + + type: string; +>type : Symbol(ParameterizedObject.type, Decl(noSilentNeverTypeLeak4.ts, 4, 31)) + + params?: unknown; +>params : Symbol(ParameterizedObject.params, Decl(noSilentNeverTypeLeak4.ts, 5, 15)) +} + +type ActionFunction< +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak4.ts, 7, 1)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 9, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak4.ts, 0, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak4.ts, 10, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + + TAction extends ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak4.ts, 11, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + +> = { + (ctx: TContext, params: TParams): void; +>ctx : Symbol(ctx, Decl(noSilentNeverTypeLeak4.ts, 14, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 9, 20)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 14, 17)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak4.ts, 10, 34)) + + _out_TAction?: TAction; +>_out_TAction : Symbol(_out_TAction, Decl(noSilentNeverTypeLeak4.ts, 14, 41)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak4.ts, 11, 60)) + +}; + +type ToParameterizedObject< +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 16, 2)) + + TParameterizedMap extends Record< +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak4.ts, 18, 27)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + + >, +> = Values<{ +>Values : Symbol(Values, Decl(noSilentNeverTypeLeak4.ts, 0, 0)) + + [K in keyof TParameterizedMap as K & string]: { +>K : Symbol(K, Decl(noSilentNeverTypeLeak4.ts, 24, 3)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak4.ts, 18, 27)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak4.ts, 24, 3)) + + type: K & string; +>type : Symbol(type, Decl(noSilentNeverTypeLeak4.ts, 24, 49)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak4.ts, 24, 3)) + + params: TParameterizedMap[K]; +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 25, 21)) +>TParameterizedMap : Symbol(TParameterizedMap, Decl(noSilentNeverTypeLeak4.ts, 18, 27)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak4.ts, 24, 3)) + + }; +}>; + +type CollectActions< +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak4.ts, 28, 3)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 30, 20)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak4.ts, 0, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak4.ts, 31, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + +> = ( + { + context, +>context : Symbol(context, Decl(noSilentNeverTypeLeak4.ts, 34, 3)) + + enqueue, +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak4.ts, 35, 12)) + + }: { + context: TContext; +>context : Symbol(context, Decl(noSilentNeverTypeLeak4.ts, 37, 6)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 30, 20)) + + enqueue: (action: () => void) => void; +>enqueue : Symbol(enqueue, Decl(noSilentNeverTypeLeak4.ts, 38, 22)) +>action : Symbol(action, Decl(noSilentNeverTypeLeak4.ts, 39, 14)) + + }, + params: TParams, +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 40, 4)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak4.ts, 31, 34)) + +) => void; + +declare function enqueueActions< +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak4.ts, 42, 10)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 44, 32)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak4.ts, 0, 28)) + + TParams extends ParameterizedObject["params"] | undefined, +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak4.ts, 45, 34)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + + TAction extends ParameterizedObject = ParameterizedObject, +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak4.ts, 46, 60)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + +>( + collect: CollectActions, +>collect : Symbol(collect, Decl(noSilentNeverTypeLeak4.ts, 48, 2)) +>CollectActions : Symbol(CollectActions, Decl(noSilentNeverTypeLeak4.ts, 28, 3)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 44, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak4.ts, 45, 34)) + +): ActionFunction; +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak4.ts, 7, 1)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 44, 32)) +>TParams : Symbol(TParams, Decl(noSilentNeverTypeLeak4.ts, 45, 34)) +>TAction : Symbol(TAction, Decl(noSilentNeverTypeLeak4.ts, 46, 60)) + +declare function setup< +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak4.ts, 50, 46)) + + TContext extends MachineContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 52, 23)) +>MachineContext : Symbol(MachineContext, Decl(noSilentNeverTypeLeak4.ts, 0, 28)) + + TActions extends Record< +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak4.ts, 53, 34)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + string, + ParameterizedObject["params"] | undefined +>ParameterizedObject : Symbol(ParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 2, 42)) + + > = {}, +>({ + types, +>types : Symbol(types, Decl(noSilentNeverTypeLeak4.ts, 58, 3)) + + actions, +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak4.ts, 59, 8)) + +}: { + types?: { context?: TContext }; +>types : Symbol(types, Decl(noSilentNeverTypeLeak4.ts, 61, 4)) +>context : Symbol(context, Decl(noSilentNeverTypeLeak4.ts, 62, 11)) +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 52, 23)) + + actions?: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak4.ts, 62, 33)) + + [K in keyof TActions]: ActionFunction< +>K : Symbol(K, Decl(noSilentNeverTypeLeak4.ts, 64, 5)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak4.ts, 53, 34)) +>ActionFunction : Symbol(ActionFunction, Decl(noSilentNeverTypeLeak4.ts, 7, 1)) + + TContext, +>TContext : Symbol(TContext, Decl(noSilentNeverTypeLeak4.ts, 52, 23)) + + TActions[K], +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak4.ts, 53, 34)) +>K : Symbol(K, Decl(noSilentNeverTypeLeak4.ts, 64, 5)) + + ToParameterizedObject +>ToParameterizedObject : Symbol(ToParameterizedObject, Decl(noSilentNeverTypeLeak4.ts, 16, 2)) +>TActions : Symbol(TActions, Decl(noSilentNeverTypeLeak4.ts, 53, 34)) + + >; + }; +}): void; + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak4.ts, 50, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak4.ts, 72, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak4.ts, 73, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak4.ts, 42, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak4.ts, 74, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 74, 31)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak4.ts, 50, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak4.ts, 78, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak4.ts, 79, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak4.ts, 42, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak4.ts, 80, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 80, 31)) + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak4.ts, 80, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak4.ts, 81, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 81, 21)) + + }, +}); + +setup({ +>setup : Symbol(setup, Decl(noSilentNeverTypeLeak4.ts, 50, 46)) + + actions: { +>actions : Symbol(actions, Decl(noSilentNeverTypeLeak4.ts, 85, 7)) + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : Symbol(doStuff, Decl(noSilentNeverTypeLeak4.ts, 86, 12)) +>enqueueActions : Symbol(enqueueActions, Decl(noSilentNeverTypeLeak4.ts, 42, 10)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak4.ts, 87, 29)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 87, 31)) + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : Symbol(doOtherStuff, Decl(noSilentNeverTypeLeak4.ts, 87, 55)) +>_ : Symbol(_, Decl(noSilentNeverTypeLeak4.ts, 88, 19)) +>params : Symbol(params, Decl(noSilentNeverTypeLeak4.ts, 88, 26)) + + }, +}); + diff --git a/tests/baselines/reference/noSilentNeverTypeLeak4.types b/tests/baselines/reference/noSilentNeverTypeLeak4.types new file mode 100644 index 0000000000000..69973e7ea6c1d --- /dev/null +++ b/tests/baselines/reference/noSilentNeverTypeLeak4.types @@ -0,0 +1,260 @@ +//// [tests/cases/compiler/noSilentNeverTypeLeak4.ts] //// + +=== noSilentNeverTypeLeak4.ts === +type Values = T[keyof T]; +>Values : Values +> : ^^^^^^^^^ + +type MachineContext = Record; +>MachineContext : MachineContext +> : ^^^^^^^^^^^^^^ + +interface ParameterizedObject { + type: string; +>type : string +> : ^^^^^^ + + params?: unknown; +>params : unknown +> : ^^^^^^^ +} + +type ActionFunction< +>ActionFunction : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; +>ctx : TContext +> : ^^^^^^^^ +>params : TParams +> : ^^^^^^^ + + _out_TAction?: TAction; +>_out_TAction : TAction | undefined +> : ^^^^^^^^^^^^^^^^^^^ + +}; + +type ToParameterizedObject< +>ToParameterizedObject : ToParameterizedObject +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap as K & string]: { + type: K & string; +>type : K & string +> : ^^^^^^^^^^ + + params: TParameterizedMap[K]; +>params : TParameterizedMap[K] +> : ^^^^^^^^^^^^^^^^^^^^ + + }; +}>; + +type CollectActions< +>CollectActions : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, +>context : TContext +> : ^^^^^^^^ + + enqueue, +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ + + }: { + context: TContext; +>context : TContext +> : ^^^^^^^^ + + enqueue: (action: () => void) => void; +>enqueue : (action: () => void) => void +> : ^ ^^ ^^^^^ +>action : () => void +> : ^^^^^^ + + }, + params: TParams, +>params : TParams +> : ^^^^^^^ + +) => void; + +declare function enqueueActions< +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +>collect : CollectActions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +): ActionFunction; + +declare function setup< +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ + + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + + actions, +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +}: { + types?: { context?: TContext }; +>types : { context?: TContext; } | undefined +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ +>context : TContext | undefined +> : ^^^^^^^^^^^^^^^^^^^^ + + actions?: { +>actions : { [K in keyof TActions]: ActionFunction>; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), },} : { actions: { doStuff: ActionFunction; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), } : { doStuff: ActionFunction; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, },} : { actions: { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_, params: string) => {}, } : { doStuff: ActionFunction; doOtherStuff: (_: MachineContext, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_, params: string) => {}, +>doOtherStuff : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>(_, params: string) => {} : (_: MachineContext, params: string) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^ +>_ : MachineContext +> : ^^^^^^^^^^^^^^ +>params : string +> : ^^^^^^ + + }, +}); + +setup({ +>setup({ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },}) : void +> : ^^^^ +>setup : = {}>({ types, actions, }: { types?: { context?: TContext; }; actions?: { [K in keyof TActions]: ActionFunction>; }; }) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, },} : { actions: { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ +>{ doStuff: enqueueActions((_, params: number) => {}), doOtherStuff: (_: any, params: string) => {}, } : { doStuff: ActionFunction>; doOtherStuff: (_: any, params: string) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ + + doStuff: enqueueActions((_, params: number) => {}), +>doStuff : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions((_, params: number) => {}) : ActionFunction> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>enqueueActions : (collect: CollectActions) => ActionFunction +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ +>(_, params: number) => {} : (_: { context: MachineContext; enqueue: (action: () => void) => void; }, params: number) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^^ +>_ : { context: MachineContext; enqueue: (action: () => void) => void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>params : number +> : ^^^^^^ + + doOtherStuff: (_: any, params: string) => {}, +>doOtherStuff : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>(_: any, params: string) => {} : (_: any, params: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>_ : any +> : ^^^ +>params : string +> : ^^^^^^ + + }, +}); + diff --git a/tests/cases/compiler/noSilentNeverTypeLeak1.ts b/tests/cases/compiler/noSilentNeverTypeLeak1.ts index ccdb0d2498561..0186f50b50159 100644 --- a/tests/cases/compiler/noSilentNeverTypeLeak1.ts +++ b/tests/cases/compiler/noSilentNeverTypeLeak1.ts @@ -1,96 +1,14 @@ // @strict: true // @noEmit: true -// https://github.com/microsoft/TypeScript/issues/62824 +type Fn = (arg: T) => void; -type Values = T[keyof T]; +declare function fn1(): Fn; -type MachineContext = Record; +declare function fn2( + cb: Fn<{ + [K in keyof T & string]: T[K]; + }>, +): void; -interface ParameterizedObject { - type: string; - params?: unknown; -} - -type ActionFunction< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject, -> = { - (ctx: TContext, params: TParams): void; - _out_TAction?: TAction; -}; - -type ToParameterizedObject< - TParameterizedMap extends Record< - string, - ParameterizedObject["params"] | undefined - >, -> = Values<{ - [K in keyof TParameterizedMap & string]: { - type: K; - params: TParameterizedMap[K]; - }; -}>; - -type CollectActions< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, -> = ( - { - context, - enqueue, - }: { - context: TContext; - enqueue: (action: () => void) => void; - }, - params: TParams, -) => void; - -declare function enqueueActions< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject = ParameterizedObject, ->( - collect: CollectActions, -): ActionFunction; - -declare function setup< - TContext extends MachineContext, - TActions extends Record< - string, - ParameterizedObject["params"] | undefined - > = {}, ->({ - types, - actions, -}: { - types?: { context?: TContext }; - actions?: { - [K in keyof TActions]: ActionFunction< - TContext, - TActions[K], - ToParameterizedObject - >; - }; -}): void; - -setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - }, -}); - -setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - doOtherStuff: (_, params: string) => {}, - }, -}); - -setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - doOtherStuff: (_: any, params: string) => {}, - }, -}); +fn2(fn1()); diff --git a/tests/cases/compiler/noSilentNeverTypeLeak2.ts b/tests/cases/compiler/noSilentNeverTypeLeak2.ts index 48c62c0efd255..182f8be7e0d5f 100644 --- a/tests/cases/compiler/noSilentNeverTypeLeak2.ts +++ b/tests/cases/compiler/noSilentNeverTypeLeak2.ts @@ -3,92 +3,44 @@ type Values = T[keyof T]; -type MachineContext = Record; - interface ParameterizedObject { type: string; params?: unknown; } -type ActionFunction< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject, -> = { - (ctx: TContext, params: TParams): void; +type ActionFunction = { + (params: TParams): void; _out_TAction?: TAction; }; -type ToParameterizedObject< - TParameterizedMap extends Record< - string, - ParameterizedObject["params"] | undefined - >, -> = Values<{ - [K in keyof TParameterizedMap as K & string]: { - type: K & string; +type ToParameterizedObject = Values<{ + [K in keyof TParameterizedMap & string]: { + type: K; params: TParameterizedMap[K]; }; }>; -type CollectActions< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, -> = ( - { - context, - enqueue, - }: { - context: TContext; - enqueue: (action: () => void) => void; - }, - params: TParams, -) => void; - -declare function enqueueActions< - TContext extends MachineContext, - TParams extends ParameterizedObject["params"] | undefined, - TAction extends ParameterizedObject = ParameterizedObject, ->( - collect: CollectActions, -): ActionFunction; +declare function enqueueActions( + collect: (params: TParams) => void, +): ActionFunction; -declare function setup< - TContext extends MachineContext, - TActions extends Record< - string, - ParameterizedObject["params"] | undefined - > = {}, ->({ - types, - actions, -}: { - types?: { context?: TContext }; - actions?: { - [K in keyof TActions]: ActionFunction< - TContext, - TActions[K], - ToParameterizedObject - >; - }; +declare function setup(actions: { + [K in keyof TActions]: ActionFunction< + TActions[K], + ToParameterizedObject + >; }): void; setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - }, + doStuff: enqueueActions((params: number) => {}), }); setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - doOtherStuff: (_, params: string) => {}, - }, + doStuff: enqueueActions((params: number) => {}), + doOtherStuff: (params: string) => {}, }); setup({ - actions: { - doStuff: enqueueActions((_, params: number) => {}), - doOtherStuff: (_: any, params: string) => {}, - }, -}); + doStuff: enqueueActions((params: number) => {}), + doOtherStuff: (params) => {}, +}); \ No newline at end of file diff --git a/tests/cases/compiler/noSilentNeverTypeLeak3.ts b/tests/cases/compiler/noSilentNeverTypeLeak3.ts new file mode 100644 index 0000000000000..ccdb0d2498561 --- /dev/null +++ b/tests/cases/compiler/noSilentNeverTypeLeak3.ts @@ -0,0 +1,96 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/62824 + +type Values = T[keyof T]; + +type MachineContext = Record; + +interface ParameterizedObject { + type: string; + params?: unknown; +} + +type ActionFunction< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; + _out_TAction?: TAction; +}; + +type ToParameterizedObject< + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap & string]: { + type: K; + params: TParameterizedMap[K]; + }; +}>; + +type CollectActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, + enqueue, + }: { + context: TContext; + enqueue: (action: () => void) => void; + }, + params: TParams, +) => void; + +declare function enqueueActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +): ActionFunction; + +declare function setup< + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, + actions, +}: { + types?: { context?: TContext }; + actions?: { + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_, params: string) => {}, + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_: any, params: string) => {}, + }, +}); diff --git a/tests/cases/compiler/noSilentNeverTypeLeak4.ts b/tests/cases/compiler/noSilentNeverTypeLeak4.ts new file mode 100644 index 0000000000000..48c62c0efd255 --- /dev/null +++ b/tests/cases/compiler/noSilentNeverTypeLeak4.ts @@ -0,0 +1,94 @@ +// @strict: true +// @noEmit: true + +type Values = T[keyof T]; + +type MachineContext = Record; + +interface ParameterizedObject { + type: string; + params?: unknown; +} + +type ActionFunction< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject, +> = { + (ctx: TContext, params: TParams): void; + _out_TAction?: TAction; +}; + +type ToParameterizedObject< + TParameterizedMap extends Record< + string, + ParameterizedObject["params"] | undefined + >, +> = Values<{ + [K in keyof TParameterizedMap as K & string]: { + type: K & string; + params: TParameterizedMap[K]; + }; +}>; + +type CollectActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, +> = ( + { + context, + enqueue, + }: { + context: TContext; + enqueue: (action: () => void) => void; + }, + params: TParams, +) => void; + +declare function enqueueActions< + TContext extends MachineContext, + TParams extends ParameterizedObject["params"] | undefined, + TAction extends ParameterizedObject = ParameterizedObject, +>( + collect: CollectActions, +): ActionFunction; + +declare function setup< + TContext extends MachineContext, + TActions extends Record< + string, + ParameterizedObject["params"] | undefined + > = {}, +>({ + types, + actions, +}: { + types?: { context?: TContext }; + actions?: { + [K in keyof TActions]: ActionFunction< + TContext, + TActions[K], + ToParameterizedObject + >; + }; +}): void; + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_, params: string) => {}, + }, +}); + +setup({ + actions: { + doStuff: enqueueActions((_, params: number) => {}), + doOtherStuff: (_: any, params: string) => {}, + }, +});