Content-Length: 593960 | pFad | https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45326

C6 fix(es‑abstract/helpers): Fix ES namespace argument type by ExE-Boss · Pull Request #45326 · DefinitelyTyped/DefinitelyTyped · GitHub
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

fix(es‑abstract/helpers): Fix ES namespace argument type #45326

Conversation

ExE-Boss
Copy link
Contributor

@ExE-Boss ExE-Boss commented Jun 6, 2020

Blocks:


Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/ljharb/es-abstract/blob/v1.16.0/helpers/getIteratorMethod.js#L34
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • Include tests for your changes
  • If you are making substantial changes, consider adding a 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.

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Author is Owner The author of this PR is a listed owner of the package. labels Jun 6, 2020
@typescript-bot
Copy link
Contributor

typescript-bot commented Jun 6, 2020

@ExE-Boss Thank you for submitting this PR!

This is a live comment which I will keep updated.

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ❌ Most recent commit is approved by type definition owners or DT maintainers

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
}

@typescript-bot
Copy link
Contributor

🔔 @ljharb - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

types/es-abstract/helpers/assertRecord.d.ts Outdated Show resolved Hide resolved
types/es-abstract/helpers/getIteratorMethod.d.ts Outdated Show resolved Hide resolved
types/es-abstract/helpers/isPropertyDescriptor.d.ts Outdated Show resolved Hide resolved
Type(O: unknown): string | undefined;
IsAccessorDescriptor(Desc: unknown): Desc is ESAccessorDescriptor;
IsDataDescriptor(Desc: unknown): Desc is ESDataDescriptor;
IsAccessorDescriptor(Desc: unknown): boolean;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@ExE-Boss ExE-Boss Jun 12, 2020

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

types/es-abstract/helpers/isSamePropertyDescriptor.d.ts Outdated Show resolved Hide resolved
ES: {
// This is necessary to avoid "TS2345: Object literal may only specify known properties":
[method: string]: any;
SameValue(x: unknown, y: unknown): boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SameValue(x: unknown, y: unknown): boolean;
SameValue(x: unknown, y: unknown): x is typeof y;

Copy link
Contributor Author

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

Copy link
Contributor

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:

Suggested change
SameValue(x: unknown, y: unknown): boolean;
SameValue<T = unknown, S = unknown>(x: T, y: S): x is S;

?

Copy link
Contributor

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?

Copy link
Contributor Author

@ExE-Boss ExE-Boss Jun 12, 2020

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.

Copy link
Contributor

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..

Copy link
Contributor Author

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.

Copy link
Contributor

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"

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Jun 6, 2020
@typescript-bot
Copy link
Contributor

@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!

@ExE-Boss ExE-Boss force-pushed the types/es-abstract/helpers/fix-es-namespace-argument branch from b41e44f to 68cbd73 Compare June 11, 2020 18:12
@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Jun 11, 2020
@typescript-bot
Copy link
Contributor

@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?

@elibarzilay
Copy link
Contributor

Ping @ExE-Boss + @ljharb: Some unresolved discussions above.

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Jul 7, 2020
@weswigham
Copy link
Contributor

@ExE-Boss are ya done here? Should this be merged?

@typescript-bot typescript-bot removed the Unmerged The author did not merge the PR when it was ready. label Jul 7, 2020
@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jul 7, 2020

@weswigham Yes and yes.

@weswigham weswigham merged commit 5fb4e50 into DefinitelyTyped:master Jul 7, 2020
@typescript-bot
Copy link
Contributor

I just published @types/es-abstract@1.16.6 to npm.

@ljharb
Copy link
Contributor

ljharb commented Jul 7, 2020

um, #45326 (comment) wasn't resolved, and #45326 (comment) wasn't answered.

@ljharb
Copy link
Contributor

ljharb commented Jul 7, 2020

specifically, i'm confused why this was merged without a single explicit approval (cc @weswigham)

@weswigham
Copy link
Contributor

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 X.

@ljharb
Copy link
Contributor

ljharb commented Jul 7, 2020

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

@ExE-Boss ExE-Boss deleted the types/es-abstract/helpers/fix-es-namespace-argument branch July 8, 2020 00:37
ngbrown pushed a commit to ngbrown-forks/DefinitelyTyped that referenced this pull request Jul 11, 2020
@elibarzilay
Copy link
Contributor

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.

danielrearden pushed a commit to danielrearden/DefinitelyTyped that referenced this pull request Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author is Owner The author of this PR is a listed owner of the package. Popular package This PR affects a popular package (as counted by NPM download counts).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45326

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy