Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Enum Key Inference on Record #647

Merged
merged 3 commits into from
Oct 26, 2023
Merged

Support Enum Key Inference on Record #647

merged 3 commits into from
Oct 26, 2023

Conversation

sinclairzx81
Copy link
Owner

@sinclairzx81 sinclairzx81 commented Oct 26, 2023

This PR adds an additional inference path for Record Keys of type Enum

enum E { A, B, C }

const T = Type.Record(Type.Enum(E), Type.Number())

type T = Static<typeof T> // type T = {
                          //   0: number;
                          //   1: number;
                          //   2: number;
                          // }

console.log(T)            // {
                          //   type: 'object',
                          //   properties: {
                          //     '0': { type: 'number', [Symbol(TypeBox.Kind)]: 'Number' },
                          //     '1': { type: 'number', [Symbol(TypeBox.Kind)]: 'Number' },
                          //     '2': { type: 'number', [Symbol(TypeBox.Kind)]: 'Number' }
                          //   },
                          //   required: [ '0', '1', '2' ],
                          //   [Symbol(TypeBox.Hint)]: 'Record',
                          //   [Symbol(TypeBox.Kind)]: 'Object'
                          // }

Fixes #646

@sinclairzx81 sinclairzx81 merged commit a9cfd7e into master Oct 26, 2023
18 checks passed
@sinclairzx81 sinclairzx81 deleted the enum branch October 26, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type.Record() type inference is broken since version 0.31.0
1 participant