|
| 1 | +//// [tests/cases/compiler/inferenceExactOptionalProperties2.ts] //// |
| 2 | + |
| 3 | +=== inferenceExactOptionalProperties2.ts === |
| 4 | +type Values<T> = T[keyof T]; |
| 5 | +>Values : Symbol(Values, Decl(inferenceExactOptionalProperties2.ts, 0, 0)) |
| 6 | +>T : Symbol(T, Decl(inferenceExactOptionalProperties2.ts, 0, 12)) |
| 7 | +>T : Symbol(T, Decl(inferenceExactOptionalProperties2.ts, 0, 12)) |
| 8 | +>T : Symbol(T, Decl(inferenceExactOptionalProperties2.ts, 0, 12)) |
| 9 | + |
| 10 | +type EventObject = { |
| 11 | +>EventObject : Symbol(EventObject, Decl(inferenceExactOptionalProperties2.ts, 0, 28)) |
| 12 | + |
| 13 | + type: string; |
| 14 | +>type : Symbol(type, Decl(inferenceExactOptionalProperties2.ts, 2, 20)) |
| 15 | + |
| 16 | +}; |
| 17 | + |
| 18 | +interface ActorLogic<TEvent extends EventObject> { |
| 19 | +>ActorLogic : Symbol(ActorLogic, Decl(inferenceExactOptionalProperties2.ts, 4, 2)) |
| 20 | +>TEvent : Symbol(TEvent, Decl(inferenceExactOptionalProperties2.ts, 6, 21)) |
| 21 | +>EventObject : Symbol(EventObject, Decl(inferenceExactOptionalProperties2.ts, 0, 28)) |
| 22 | + |
| 23 | + transition: (ev: TEvent) => unknown; |
| 24 | +>transition : Symbol(ActorLogic.transition, Decl(inferenceExactOptionalProperties2.ts, 6, 50)) |
| 25 | +>ev : Symbol(ev, Decl(inferenceExactOptionalProperties2.ts, 7, 15)) |
| 26 | +>TEvent : Symbol(TEvent, Decl(inferenceExactOptionalProperties2.ts, 6, 21)) |
| 27 | +} |
| 28 | + |
| 29 | +type UnknownActorLogic = ActorLogic<never>; |
| 30 | +>UnknownActorLogic : Symbol(UnknownActorLogic, Decl(inferenceExactOptionalProperties2.ts, 8, 1)) |
| 31 | +>ActorLogic : Symbol(ActorLogic, Decl(inferenceExactOptionalProperties2.ts, 4, 2)) |
| 32 | + |
| 33 | +interface ProvidedActor { |
| 34 | +>ProvidedActor : Symbol(ProvidedActor, Decl(inferenceExactOptionalProperties2.ts, 10, 43)) |
| 35 | + |
| 36 | + src: string; |
| 37 | +>src : Symbol(ProvidedActor.src, Decl(inferenceExactOptionalProperties2.ts, 12, 25)) |
| 38 | + |
| 39 | + logic: UnknownActorLogic; |
| 40 | +>logic : Symbol(ProvidedActor.logic, Decl(inferenceExactOptionalProperties2.ts, 13, 14)) |
| 41 | +>UnknownActorLogic : Symbol(UnknownActorLogic, Decl(inferenceExactOptionalProperties2.ts, 8, 1)) |
| 42 | +} |
| 43 | + |
| 44 | +interface ActionFunction<TActor extends ProvidedActor> { |
| 45 | +>ActionFunction : Symbol(ActionFunction, Decl(inferenceExactOptionalProperties2.ts, 15, 1)) |
| 46 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 17, 25)) |
| 47 | +>ProvidedActor : Symbol(ProvidedActor, Decl(inferenceExactOptionalProperties2.ts, 10, 43)) |
| 48 | + |
| 49 | + (): void; |
| 50 | + _out_TActor?: TActor; |
| 51 | +>_out_TActor : Symbol(ActionFunction._out_TActor, Decl(inferenceExactOptionalProperties2.ts, 18, 11)) |
| 52 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 17, 25)) |
| 53 | +} |
| 54 | + |
| 55 | +interface AssignAction<TActor extends ProvidedActor> { |
| 56 | +>AssignAction : Symbol(AssignAction, Decl(inferenceExactOptionalProperties2.ts, 20, 1)) |
| 57 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 22, 23)) |
| 58 | +>ProvidedActor : Symbol(ProvidedActor, Decl(inferenceExactOptionalProperties2.ts, 10, 43)) |
| 59 | + |
| 60 | + (): void; |
| 61 | + _out_TActor?: TActor; |
| 62 | +>_out_TActor : Symbol(AssignAction._out_TActor, Decl(inferenceExactOptionalProperties2.ts, 23, 11)) |
| 63 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 22, 23)) |
| 64 | +} |
| 65 | + |
| 66 | +interface MachineConfig<TActor extends ProvidedActor> { |
| 67 | +>MachineConfig : Symbol(MachineConfig, Decl(inferenceExactOptionalProperties2.ts, 25, 1)) |
| 68 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 27, 24)) |
| 69 | +>ProvidedActor : Symbol(ProvidedActor, Decl(inferenceExactOptionalProperties2.ts, 10, 43)) |
| 70 | + |
| 71 | + entry?: ActionFunction<TActor>; |
| 72 | +>entry : Symbol(MachineConfig.entry, Decl(inferenceExactOptionalProperties2.ts, 27, 55)) |
| 73 | +>ActionFunction : Symbol(ActionFunction, Decl(inferenceExactOptionalProperties2.ts, 15, 1)) |
| 74 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 27, 24)) |
| 75 | +} |
| 76 | + |
| 77 | +declare function assign<TActor extends ProvidedActor>( |
| 78 | +>assign : Symbol(assign, Decl(inferenceExactOptionalProperties2.ts, 29, 1)) |
| 79 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 31, 24)) |
| 80 | +>ProvidedActor : Symbol(ProvidedActor, Decl(inferenceExactOptionalProperties2.ts, 10, 43)) |
| 81 | + |
| 82 | + _: (spawn: (actor: TActor["src"]) => void) => {}, |
| 83 | +>_ : Symbol(_, Decl(inferenceExactOptionalProperties2.ts, 31, 54)) |
| 84 | +>spawn : Symbol(spawn, Decl(inferenceExactOptionalProperties2.ts, 32, 6)) |
| 85 | +>actor : Symbol(actor, Decl(inferenceExactOptionalProperties2.ts, 32, 14)) |
| 86 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 31, 24)) |
| 87 | + |
| 88 | +): AssignAction<TActor>; |
| 89 | +>AssignAction : Symbol(AssignAction, Decl(inferenceExactOptionalProperties2.ts, 20, 1)) |
| 90 | +>TActor : Symbol(TActor, Decl(inferenceExactOptionalProperties2.ts, 31, 24)) |
| 91 | + |
| 92 | +type ToProvidedActor<TActors extends Record<string, UnknownActorLogic>> = |
| 93 | +>ToProvidedActor : Symbol(ToProvidedActor, Decl(inferenceExactOptionalProperties2.ts, 33, 24)) |
| 94 | +>TActors : Symbol(TActors, Decl(inferenceExactOptionalProperties2.ts, 35, 21)) |
| 95 | +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) |
| 96 | +>UnknownActorLogic : Symbol(UnknownActorLogic, Decl(inferenceExactOptionalProperties2.ts, 8, 1)) |
| 97 | + |
| 98 | + Values<{ |
| 99 | +>Values : Symbol(Values, Decl(inferenceExactOptionalProperties2.ts, 0, 0)) |
| 100 | + |
| 101 | + [K in keyof TActors & string]: { |
| 102 | +>K : Symbol(K, Decl(inferenceExactOptionalProperties2.ts, 37, 5)) |
| 103 | +>TActors : Symbol(TActors, Decl(inferenceExactOptionalProperties2.ts, 35, 21)) |
| 104 | + |
| 105 | + src: K; |
| 106 | +>src : Symbol(src, Decl(inferenceExactOptionalProperties2.ts, 37, 36)) |
| 107 | +>K : Symbol(K, Decl(inferenceExactOptionalProperties2.ts, 37, 5)) |
| 108 | + |
| 109 | + logic: TActors[K]; |
| 110 | +>logic : Symbol(logic, Decl(inferenceExactOptionalProperties2.ts, 38, 13)) |
| 111 | +>TActors : Symbol(TActors, Decl(inferenceExactOptionalProperties2.ts, 35, 21)) |
| 112 | +>K : Symbol(K, Decl(inferenceExactOptionalProperties2.ts, 37, 5)) |
| 113 | + |
| 114 | + }; |
| 115 | + }>; |
| 116 | + |
| 117 | +declare function setup< |
| 118 | +>setup : Symbol(setup, Decl(inferenceExactOptionalProperties2.ts, 41, 5)) |
| 119 | + |
| 120 | + TActors extends Record<string, UnknownActorLogic> = {}, |
| 121 | +>TActors : Symbol(TActors, Decl(inferenceExactOptionalProperties2.ts, 43, 23)) |
| 122 | +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) |
| 123 | +>UnknownActorLogic : Symbol(UnknownActorLogic, Decl(inferenceExactOptionalProperties2.ts, 8, 1)) |
| 124 | + |
| 125 | +>(implementations?: { |
| 126 | +>implementations : Symbol(implementations, Decl(inferenceExactOptionalProperties2.ts, 45, 2)) |
| 127 | + |
| 128 | + actors?: { [K in keyof TActors]: TActors[K] }; |
| 129 | +>actors : Symbol(actors, Decl(inferenceExactOptionalProperties2.ts, 45, 21)) |
| 130 | +>K : Symbol(K, Decl(inferenceExactOptionalProperties2.ts, 46, 14)) |
| 131 | +>TActors : Symbol(TActors, Decl(inferenceExactOptionalProperties2.ts, 43, 23)) |
| 132 | +>TActors : Symbol(TActors, Decl(inferenceExactOptionalProperties2.ts, 43, 23)) |
| 133 | +>K : Symbol(K, Decl(inferenceExactOptionalProperties2.ts, 46, 14)) |
| 134 | + |
| 135 | +}): { |
| 136 | + createMachine: < |
| 137 | +>createMachine : Symbol(createMachine, Decl(inferenceExactOptionalProperties2.ts, 47, 5)) |
| 138 | + |
| 139 | + const TConfig extends MachineConfig<ToProvidedActor<TActors>>, |
| 140 | +>TConfig : Symbol(TConfig, Decl(inferenceExactOptionalProperties2.ts, 48, 18)) |
| 141 | +>MachineConfig : Symbol(MachineConfig, Decl(inferenceExactOptionalProperties2.ts, 25, 1)) |
| 142 | +>ToProvidedActor : Symbol(ToProvidedActor, Decl(inferenceExactOptionalProperties2.ts, 33, 24)) |
| 143 | +>TActors : Symbol(TActors, Decl(inferenceExactOptionalProperties2.ts, 43, 23)) |
| 144 | + |
| 145 | + >( |
| 146 | + config: TConfig, |
| 147 | +>config : Symbol(config, Decl(inferenceExactOptionalProperties2.ts, 50, 4)) |
| 148 | +>TConfig : Symbol(TConfig, Decl(inferenceExactOptionalProperties2.ts, 48, 18)) |
| 149 | + |
| 150 | + ) => void; |
| 151 | +}; |
| 152 | + |
| 153 | +declare const counterLogic: ActorLogic<{ type: "INCREMENT" }>; |
| 154 | +>counterLogic : Symbol(counterLogic, Decl(inferenceExactOptionalProperties2.ts, 55, 13)) |
| 155 | +>ActorLogic : Symbol(ActorLogic, Decl(inferenceExactOptionalProperties2.ts, 4, 2)) |
| 156 | +>type : Symbol(type, Decl(inferenceExactOptionalProperties2.ts, 55, 40)) |
| 157 | + |
| 158 | +// example usage |
| 159 | +setup({ |
| 160 | +>setup({ actors: { counter: counterLogic },}).createMachine : Symbol(createMachine, Decl(inferenceExactOptionalProperties2.ts, 47, 5)) |
| 161 | +>setup : Symbol(setup, Decl(inferenceExactOptionalProperties2.ts, 41, 5)) |
| 162 | + |
| 163 | + actors: { counter: counterLogic }, |
| 164 | +>actors : Symbol(actors, Decl(inferenceExactOptionalProperties2.ts, 58, 7)) |
| 165 | +>counter : Symbol(counter, Decl(inferenceExactOptionalProperties2.ts, 59, 11)) |
| 166 | +>counterLogic : Symbol(counterLogic, Decl(inferenceExactOptionalProperties2.ts, 55, 13)) |
| 167 | + |
| 168 | +}).createMachine({ |
| 169 | +>createMachine : Symbol(createMachine, Decl(inferenceExactOptionalProperties2.ts, 47, 5)) |
| 170 | + |
| 171 | + entry: assign((spawn) => { |
| 172 | +>entry : Symbol(entry, Decl(inferenceExactOptionalProperties2.ts, 60, 18)) |
| 173 | +>assign : Symbol(assign, Decl(inferenceExactOptionalProperties2.ts, 29, 1)) |
| 174 | +>spawn : Symbol(spawn, Decl(inferenceExactOptionalProperties2.ts, 61, 17)) |
| 175 | + |
| 176 | + spawn("counter"); // ok |
| 177 | +>spawn : Symbol(spawn, Decl(inferenceExactOptionalProperties2.ts, 61, 17)) |
| 178 | + |
| 179 | + spawn("alarm"); // error |
| 180 | +>spawn : Symbol(spawn, Decl(inferenceExactOptionalProperties2.ts, 61, 17)) |
| 181 | + |
| 182 | + return {}; |
| 183 | + }), |
| 184 | +}); |
| 185 | + |
| 186 | +// no provided actors, `assign` should still work |
| 187 | +setup().createMachine({ |
| 188 | +>setup().createMachine : Symbol(createMachine, Decl(inferenceExactOptionalProperties2.ts, 47, 5)) |
| 189 | +>setup : Symbol(setup, Decl(inferenceExactOptionalProperties2.ts, 41, 5)) |
| 190 | +>createMachine : Symbol(createMachine, Decl(inferenceExactOptionalProperties2.ts, 47, 5)) |
| 191 | + |
| 192 | + entry: assign(() => ({})), |
| 193 | +>entry : Symbol(entry, Decl(inferenceExactOptionalProperties2.ts, 69, 23)) |
| 194 | +>assign : Symbol(assign, Decl(inferenceExactOptionalProperties2.ts, 29, 1)) |
| 195 | + |
| 196 | +}); |
| 197 | + |
0 commit comments