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

As of 0.6.0, new Map() cannot satisfy existing generic constraints #206

Closed
amitdahan opened this issue Sep 1, 2024 · 1 comment · Fixed by #207
Closed

As of 0.6.0, new Map() cannot satisfy existing generic constraints #206

amitdahan opened this issue Sep 1, 2024 · 1 comment · Fixed by #207

Comments

@amitdahan
Copy link
Contributor

Related #41, and specifically - this bug was introduced in #53.


Previously (when new Map() returned a Map<any, any>) - this would have worked:

function expectsBooleanMap(map: Map<string, boolean>) {}
expectsBooleanMap(new Map());

But with 0.6.0 it no longer works!

error TS2345: Argument of type 'Map<unknown, unknown>' is not assignable to parameter of type 'Map<string, boolean>'.

This also reproduces with usages such as:

const map: Map<string, boolean> = new Map();
const map = new Map() satisfies Map<string, boolean>;
@jaens
Copy link

jaens commented Sep 2, 2024

Can confirm, after upgrade most new Map()s return a type error now, before they were type inferred properly.

(needed to revert to previous version)

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 a pull request may close this issue.

2 participants