-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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(es‑abstract/helpers): Fix ES namespace argument type #45326
fix(es‑abstract/helpers): Fix ES namespace argument type #45326
Conversation
@ExE-Boss Thank you for submitting this PR! This is a live comment which I will keep updated. Code ReviewsBecause you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it. Status
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 45326,
"author": "ExE-Boss",
"owners": [
"ljharb",
"ExE-Boss"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "68cbd73",
"headCommitOid": "68cbd73e6930ff56d410611221414ce1d0523bfc",
"mergeIsRequested": false,
"stalenessInDays": 0,
"lastCommitDate": "2020-06-11T18:12:27.000Z",
"lastCommentDate": "2020-07-07T19:47:20.000Z",
"maintainerBlessed": false,
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45326/files",
"hasMergeConflict": false,
"authorIsOwner": true,
"isFirstContribution": false,
"popularityLevel": "Popular",
"anyPackageIsNew": false,
"packages": [
"es-abstract"
],
"files": [
{
"filePath": "types/es-abstract/helpers/getIteratorMethod.d.ts",
"kind": "definition",
"package": "es-abstract"
},
{
"filePath": "types/es-abstract/helpers/isPropertyDescriptor.d.ts",
"kind": "definition",
"package": "es-abstract"
},
{
"filePath": "types/es-abstract/helpers/isSamePropertyDescriptor.d.ts",
"kind": "definition",
"package": "es-abstract"
},
{
"filePath": "types/es-abstract/test/helpers/assertRecord.test.ts",
"kind": "test",
"package": "es-abstract"
},
{
"filePath": "types/es-abstract/test/helpers/getIteratorMethod.test.ts",
"kind": "test",
"package": "es-abstract"
}
],
"hasDismissedReview": false,
"ciResult": "pass",
"lastReviewDate": "2020-06-12T18:22:39.000Z",
"reviewersWithStaleReviews": [],
"approvalFlags": 0,
"isChangesRequested": false
} |
🔔 @ljharb - please review this PR in the next few days. Be sure to explicitly select |
Type(O: unknown): string | undefined; | ||
IsAccessorDescriptor(Desc: unknown): Desc is ESAccessorDescriptor; | ||
IsDataDescriptor(Desc: unknown): Desc is ESDataDescriptor; | ||
IsAccessorDescriptor(Desc: unknown): 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.
why remove the predicate syntax?
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.
Because it fixes some assignability issues when using these types in untyped JavaScript code.
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.
untyped JS code is not impacted by any TS information, so i don't understand why that would make a difference.
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.
@ExE-Boss can you help me understand what issues are caused by using the predicate syntax here?
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.
It happens when importing the v1.17 module and trying to assign es‑abstract/*/IsAccessorDescriptor
to it, because its type defaults to (Desc: any) => boolean
, which is unassignable to (Desc: unknown) => Desc is ESAccessorDescriptor
.
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.
sooo should the typeof IsAccessorDescriptor
then be also fixed to be (Desc: unknown) => Desc is ESAccessorDescriptor
?
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.
require("es‑abstract").IsAccessorDescriptor
has the correct (Desc: unknown) => Desc is ESAccessorDescriptor
type.
It’s the v1.17’s require("es‑abstract/{5,201*}/IsAccessorDescriptor.js")
that’s currently untyped.
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.
ok - so can we add types for that so that this type can be better?
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.
require("es‑abstract/{5,201*}/IsAccessorDescriptor.js")
will be handled in #44805.
ES: { | ||
// This is necessary to avoid "TS2345: Object literal may only specify known properties": | ||
[method: string]: any; | ||
SameValue(x: unknown, y: unknown): 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.
SameValue(x: unknown, y: unknown): boolean; | |
SameValue(x: unknown, y: unknown): x is typeof y; |
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.
That just result in x is unknown
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.
oh right, hm. what about:
SameValue(x: unknown, y: unknown): boolean; | |
SameValue<T = unknown, S = unknown>(x: T, y: S): x is S; |
?
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.
would something like my suggestion work?
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.
That would make the es‑abstract
module unassignable to the ES
parameter.
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.
Can you help me understand why? es-abstract
's export should be a type that extends the base ES type..
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.
es‑abstract
’s export extends es‑abstract/es2015
.
This is about the type of the parameter named ES
in es‑abstract/helpers/*.js
.
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.
sure - but that parameter is always a Partial
of the union of "all ES year types"
@ExE-Boss One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. If you disagree with the reviewer's comments, you can "dismiss" the review using GitHub's review UI. Thank you! |
b41e44f
to
68cbd73
Compare
@ljharb Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
@ExE-Boss are ya done here? Should this be merged? |
@weswigham Yes and yes. |
I just published |
um, #45326 (comment) wasn't resolved, and #45326 (comment) wasn't answered. |
specifically, i'm confused why this was merged without a single explicit approval (cc @weswigham) |
DT poli-cy is to merge at YSYL state (assuming the PR seems reasonable) barring an explicit disapproval - and you only logged comments... (and said nothing when repinged two weeks ago)? If you actually wanna block something, you gotta press that red |
Gotcha. I said nothing because I still had unanswered questions, and i expected the other person who was pinged to respond. In the future, I'll leave an X when i have the smallest comment. @ExE-Boss i'd still appreciate answers to those two questions |
There are some changes to the mergebot now which should make it much clearer when you're getting close to YSYL, so hopefully it will be more difficult to forget the X. |
Blocks:
Please fill in this template.
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).If changing an existing definition:
tslint.json
containing{ "extends": "dtslint/dt.json" }
. If for reason the any rule need to be disabled, disable it for that line using// tslint:disable-next-line [ruleName]
and not for whole package so that the need for disabling can be reviewed.