TypeScript Awaited utility type

Issue Description: What’s happening?

When trying to use the Awaited utility type and then deploying it to 8base platform, the cli output gives an error: Cannot find name 'Awaited'.

Reproduce the Issue: What steps can someone take to replicate the problem?

  1. Use Awaited type in the file to be deployed on the server
  2. Run 8base cli deploy command to deploy your changes.
  3. Check logs in cli output.

Expected Behavior: What did you expect to happen?

The file will deploy to the server without any errors.

Actual Behavior: What actually happened?

CLI output showing error with

Error: "path/tothefile/.." (3,13): Cannot find name 'Awaited'.

Hello @gert.vali, this is because the TypeScript version that the 8base CLI use, try to add a polyfill of this type, I suggest you to use the same as the TypeScript code-base:

  * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
 type Awaited<T> =
     T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
         T extends object ? // `await` only unwraps object types with a callable then. Non-object types are not unwrapped.
             T extends { then(onfulfilled: infer F): any } ? // thenable, extracts the first argument to `then()`
                 F extends ((value: infer V) => any) ? // if the argument to `then` is callable, extracts the argument
                     Awaited<V> : // recursively unwrap the value
                     never : // the argument to `then` was not callable.
             T : // argument was not an object
         T; // non-thenable

Note: You can add it in a .d.ts file and include it into your tsconfig.json file like: include: ["./types/**/*.d.ts"] to avoid to export/import it :wink: