Type aliases are not displayed when the type alias is defined using an indexed access type #50766
Closed
5 tasks done
Labels
Duplicate
An existing issue was already created
Suggestion
π Search Terms
"lookup type"
"zod"
"type alias"
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
It appears that type aliases are not used when the type alias is defined using a lookup type.
In projects using libraries like
io-ts
andzod
, the types generated bytsc
(and then used in IDE integrations and.d.ts
definition files) are overly verbose and difficult to read. Errors involving the types can be very difficult to understand; the type aliases you have defined are not used, and the entire type itself is used instead.π Motivating Example
Here's a simple illustration of the issue:
π Playground link
π» Use Cases
This is a problem in e.g. codebases using
io-ts
types because:The error should say
is not assignable to parameter of type T1
, rather thanis not assignable to parameter of type '{ field1: string; }'
For small types with a limited number of fields, this isn't really an issue; but for a real-world use case, types can be quite large. This can even trigger
TS7056: The inferred type of this node exceeds the maximum length
errors as in colinhacks/zod#1040 (comment)The text was updated successfully, but these errors were encountered: