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

Fix array handling in SchemaOf type #1169

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

chasecaleb
Copy link
Contributor

  1. Move array before object so that inference works correctly
  2. Include Lazy as part of ArraySchema's generic, to match the class definition

Here's a quick snippet that illustrates why 1 is necessary:

export const array: Array<string> = ["abc"];
// Valid - an Array is a Record (note: AnyObject is a type alias for Record<string, any>)
export const record: Record<string, any> = array;
// Doesn't compile
export const anotherArray: Array<string> = record;

By the way, I noticed that eslint isn't checking the $ExpectType comments in test/type.ts... I investigated it for a little bit, but ran into more problems so I gave up. You need to add --ext=.ts,.js when running eslint to make sure it checks the ts file, but then eslint started to give parser errors and I lost motivation. That's my excuse for not adding tests, sorry about that.

- Move array before object so that inference works correctly
- Include lazy as part of array type, to match the class definition
@jquense jquense merged commit e785e1a into jquense:master Dec 10, 2020
@jquense
Copy link
Owner

jquense commented Dec 10, 2020

huh TIL. thanks!

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.

None yet

2 participants