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

Updated type tests for [Ordered]Set.fromKeys #1968

Closed
wants to merge 2 commits into from

Conversation

johnw42
Copy link
Contributor

@johnw42 johnw42 commented Oct 4, 2023

This change updates the tests to report that the actual type inferred by tsc is correct. It would be easy to make the existing tests pass by changing the order of the overloadings in immutable.d.ts, but in this case I believe tsc is doing the right thing: it can't automatically infer the correct type of the values returned by fromKeys, so it's better to infer the type as unknown.

@johnw42
Copy link
Contributor Author

johnw42 commented Oct 4, 2023

Odd. I see dtslint is reporting an error under Typescript 4.9, but for me, it's fine with my changes, but without them it reports an error with Typescript 5.0.

@johnw42
Copy link
Contributor Author

johnw42 commented Oct 4, 2023

Ok, I'm getting more reasonable results after running npm ci. The trouble is that either way the test is written, it fails with either TS 4.9 or 5.0. It's still possible to make the tests pass by swapping the order of overloads in immutable.d.ts as lines 1716-1717 and 1939-1940, but I still think that's a bad idea, and the new behavior of tsc is more correct. For now I think the best solution is to remove those two type tests entirely; what do you think?

@jdeniau
Copy link
Member

jdeniau commented Oct 13, 2023

Hi !

it seems like the runtime is not that easy:

image

Because if you pass an object, number keys are converted to string, but if you set, this stays a number :/

@jdeniau
Copy link
Member

jdeniau commented Jan 26, 2024

Hi, I fixed this comportment in #1971 : it seems that the issue is with Collection.Keyed.

About the issue I did point in my previous comment, I think the issue is with the Map constructor and not Set.fromKeys

@jdeniau jdeniau closed this Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants