-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
lodash - change weakmap declaration to work with TS 2.2 #14662
Conversation
lodash/index.d.ts to authors (@bczengel @chrootsu @stepancar). Could you review this PR? Checklist
|
@budiadiono I appreciate your idea but it's too early. It's because TypeScript hasn't released stable 2.2 version yet. |
Can this be merged now that 2.2 is stable? |
Builds breaking waiting for this change, 2.2 is now live |
👍 |
Thanks for the fix @budiadiono Just to echo what others have already mentioned here, this problem is causing issues with the TypeScript 2.2 release |
lodash/index.d.ts
Outdated
@@ -12701,7 +12701,7 @@ declare namespace _ { | |||
* @param value The value to check. | |||
* @returns Returns true if value is correctly classified, else false. | |||
*/ | |||
isWeakMap<K, V>(value?: any): value is WeakMap<K, V>; | |||
isWeakMap<K, V>(value?: any): value is WeakMapLike<K, V>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change disables the guard. WeakMapLike
does not even have the declarations of WeakMap
, so it is not usable.
I would say just remove WeakMap
declaration altogether, and make this function return boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so. this change seems good to me, but we just need to remove the weakMap reference altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhegazy thanks for the review. I'll update it now.
A better fix would be to have Then the test must be changed to use e.g. |
@andy-ms, the issue is not the user-defined type guard, the issue is the declaration of Ultimiatlly #14787 is the correct fix, but this unblocks ppl at the moment. |
In TS 2.2 WeakMap interface for ES6 has been changed from WeakMap<K, V> to WeakMap<K extends object, V>. This changes makes @types/lodash not working with new ES6 introduced in TS2.2.
To keep the backward compatibility with ES5, I think it is safe to rename the WeakMap declaration.
I know TS 2.2 is still in RC version now, but many people using it, including me :). So if you think this is too early and also bad idea then feel free to close this PR without merging it.
If this get merged then it's should close #14324.
This pull request is clean version of pull request #14502
Please fill in this template.
master
branch.tsc
without errors.npm run lint package-name
if atslint.json
is present.Select one of these and delete the others:
If changing an existing definition:
tslint.json
containing{ "extends": "../tslint.json" }
.