diff options
Diffstat (limited to 'examples/guess-number.ts')
| -rw-r--r-- | examples/guess-number.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/guess-number.ts b/examples/guess-number.ts index 169805f..45d60e6 100644 --- a/examples/guess-number.ts +++ b/examples/guess-number.ts @@ -7,15 +7,15 @@ export type main = [ Bind<JsExpr<'Math.floor(Math.random() * 10)'>, StartGuessing> ] +type Len<Ls extends any[]> = Ls['length'] extends number ? Ls['length'] : 0 + interface AskForGuess<N extends number, Attempts extends 0[]> extends Kind1<string> { return: `${this['input']}` extends `${N}` ? PutStringLn<'Yay! You got it right!'> : Do< [ PutString<'Wrong guess. Total attempts'>, - PutStringLn<` ${[...Attempts, 0] extends infer Ls extends 0[] - ? Ls['length'] - : 0}/5`>, + PutStringLn<` ${Len<[...Attempts, 0]>}/5`>, (StartGuessing<[...Attempts, 0]> & { input: N })['return'] ] > |
