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

#39 tests for array checking #44

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@mraak
Copy link
Collaborator

commented May 8, 2019

I made the tests for Array stuff. You will see there are errors happening from tuple onwards.

Basically in a case like this, it finds errors in both assignments, instead of just the bottom one.

var x = array`(int | string)[]`;
x = [ 1, 2, "hello", 4 ];		// OK!
x = [ 1, 2, true, 4 ];			// error

This is because it recognizes the array as type any instead of type of ints and/or strings.

@mraak mraak requested a review from getify May 8, 2019

@getify

This comment has been minimized.

Copy link
Owner

commented May 8, 2019

union types aren't implemented yet

@mraak

This comment has been minimized.

Copy link
Collaborator Author

commented May 9, 2019

@getify

This comment has been minimized.

Copy link
Owner

commented May 9, 2019

There's no issue for union types yet. The syntax (int | string) is a union type, meaning that it can either be an int or a string. I am deferring that work until after we release 1.0.

But the syntax <int,string> is a tuple, meaning a 2-element array that holds an int in position 0 and a string in position 1. Those are fully implemented.

The ticket I closed is just generally support for arrays, which are (other than destructuring -- still WIP) finished. It's just that any type that is (int | string) is a union type, whether it's in an array or not, and that's not supported anywhere yet.

Show resolved Hide resolved README.md

@mraak mraak requested a review from getify May 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.