arktype icon indicating copy to clipboard operation
arktype copied to clipboard

Default values for tuple elements

Open ssalbdivad opened this issue 1 year ago • 3 comments

This would allow an expression like the following with the same semantics as the default value expressions currently available on object literals:

const t = type(["string", ["number", "=", 5]]);

type Expected = Type<[string, (In?: number | undefined) => Default<5>]>;

attest<[string, number?]>(o.inferIn);
attest<[string, number]>(o.infer);

See tests for object literals at ark/type/__tests__/defaults.test.ts.

ssalbdivad avatar May 17 '24 04:05 ssalbdivad

hey @ssalbdivad can i work on this issue?

renu-123-pixel avatar May 17 '24 08:05 renu-123-pixel

@renu-123-pixel This issue is a lot more approachable than most other issues in the repo because all the correct behavior can be inferred from the object literal behavior, but it will still involve a fair amount of complex work with TypeScript and type-level functionality.

If you feel confident in those areas, feel free, but it might not be a good fit if you're new to the ecosystem.

ssalbdivad avatar May 17 '24 08:05 ssalbdivad

ok ! if u say so u can assign it to someone else ! As I'm literal noob!! Thank you for your response !

renu-123-pixel avatar May 17 '24 08:05 renu-123-pixel