Closed
Description
I know this has already had a quick fix via #119 but with @sinclair/typebox@0.20.6
I still get this error for this very basic code:
import { Static, Type as T } from "@sinclair/typebox";
import got from "got";
const MySchema = T.Object({
name: T.String(),
});
type MyType = Static<typeof MySchema>;
async function getThing(id: string): Promise<MyType> {
const url = `https://example.com/myThing.json`;
return await got(url).json();
}
async function getAllThings(ids: string[]): Promise<MyType[]> {
return await Promise.all(ids.map((id) => getThing(id)));
}
Error returned:
> tsc --noEmit
index.ts:16:16 - error TS2589: Type instantiation is excessively deep and possibly infinite.
16 return await Promise.all(ids.map((id) => getThing(id)));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Minimal repro here: https://github.com/gmaclennan/typebox-error-repro
Error running on CI: https://github.com/gmaclennan/typebox-error-repro/runs/4251888078?check_suite_focus=true
For what it's worth, I checked with other version of Typebox, and this code compiles with v0.11.0 but fails on any later version including v0.20.6