diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-11 16:02:26 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-11 16:02:26 +0530 |
| commit | 49d6379c3d40b684b28f4a957ff1ffb81a2560ee (patch) | |
| tree | fac62b2de1670ecfea6496949b028fa8fe0fe444 /examples/guess-number.ts | |
| parent | a6ff70d09e1e5f161e401a3665bfe44b2abfc44e (diff) | |
| download | ts-types-lang-49d6379c3d40b684b28f4a957ff1ffb81a2560ee.tar.gz ts-types-lang-49d6379c3d40b684b28f4a957ff1ffb81a2560ee.zip | |
refactor: minor refactor all around
Diffstat (limited to '')
| -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'] ] > |
