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

[node] Added globalThis support to global #44700

Merged

Conversation

JasonHK
Copy link
Contributor

@JasonHK JasonHK commented May 13, 2020

This is a rewrite of #43308 and #43821. Although this PR brings breaking change to global, it corrects the type of global.


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

Select one of these and delete the others:

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://node.green/#ES2020-features-globalThis
  • 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
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

node/v*

Comparison details for node/* 📊
master #44700 diff
Batch compilation
Memory usage (MiB) 105.6 104.4 -1.1%
Type count 17146 17147 0%
Assignability cache size 37592 37592 0%
Language service
Samples taken 46 46 0%
Identifiers in tests 46 46 0%
getCompletionsAtPosition
    Mean duration (ms) 543.6 544.3 +0.1%
    Mean CV 12.8% 10.8%
    Worst duration (ms) 646.9 670.2 +3.6%
    Worst identifier deepStrictEqual deepStrictEqual
getQuickInfoAtPosition
    Mean duration (ms) 528.3 540.8 +2.4%
    Mean CV 10.8% 12.3% +13.7%
    Worst duration (ms) 710.8 622.4 -12.4%
    Worst identifier a ok

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

node/v*

Comparison details for node/* 📊
master #44700 diff
Batch compilation
Memory usage (MiB) 105.1 105.1 -0.1%
Type count 17146 17147 0%
Assignability cache size 37592 37592 0%
Language service
Samples taken 46 46 0%
Identifiers in tests 46 46 0%
getCompletionsAtPosition
    Mean duration (ms) 537.7 541.3 +0.7%
    Mean CV 10.4% 11.3%
    Worst duration (ms) 685.8 643.2 -6.2%
    Worst identifier assert a
getQuickInfoAtPosition
    Mean duration (ms) 536.1 528.4 -1.4%
    Mean CV 11.0% 11.8% +6.4%
    Worst duration (ms) 669.6 653.6 -2.4%
    Worst identifier a a

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

node/v*

Comparison details for node/* 📊
master #44700 diff
Batch compilation
Memory usage (MiB) 105.1 105.1 0.0%
Type count 17146 17147 0%
Assignability cache size 37592 37592 0%
Language service
Samples taken 46 46 0%
Identifiers in tests 46 46 0%
getCompletionsAtPosition
    Mean duration (ms) 549.8 550.2 +0.1%
    Mean CV 11.3% 11.0%
    Worst duration (ms) 636.5 703.7 +10.6%
    Worst identifier b assert
getQuickInfoAtPosition
    Mean duration (ms) 540.6 537.8 -0.5%
    Mean CV 11.0% 11.6% +5.4%
    Worst duration (ms) 672.5 704.5 +4.7%
    Worst identifier deepStrictEqual deepStrictEqual

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label May 13, 2020
@JasonHK JasonHK marked this pull request as ready for review May 13, 2020 16:03
@JasonHK JasonHK requested a review from vvakame as a code owner May 13, 2020 16:03
@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board May 13, 2020
@typescript-bot
Copy link
Contributor

typescript-bot commented May 13, 2020

@JasonHK Thank you for submitting this PR!

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ❌ Only a DT maintainer can merge changes without tests

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": 44700,
  "author": "JasonHK",
  "owners": [
    "Microsoft",
    "DefinitelyTyped",
    "jkomyno",
    "a-tarasyuk",
    "alvis",
    "r3nya",
    "btoueg",
    "brunoscheufler",
    "smac89",
    "touffy",
    "DeividasBakanas",
    "eyqs",
    "Flarna",
    "Hannes-Magnusson-CK",
    "KSXGitHub",
    "hoo29",
    "kjin",
    "ajafff",
    "islishude",
    "mwiktorczyk",
    "mohsen1",
    "n-e",
    "octo-sniffle",
    "galkin",
    "parambirs",
    "eps1lon",
    "SimonSchick",
    "ThomasdenH",
    "WilcoBakker",
    "wwwy3y3",
    "samuela",
    "kuehlein",
    "j-oliveras",
    "bhongy",
    "chyzwar",
    "trivikr",
    "nguymin4",
    "yoursunny",
    "qwelias",
    "ExE-Boss",
    "Ryan-Willpower",
    "peterblazejewicz",
    "addaleax",
    "vvakame"
  ],
  "dangerLevel": "MultiplePackagesEdited",
  "headCommitAbbrOid": "84bf705",
  "headCommitOid": "84bf7058fd34c00276fb0cbd65e1cbabaac7fdd0",
  "mergeIsRequested": false,
  "stalenessInDays": 0,
  "lastCommitDate": "2020-05-21T06:14:58.000Z",
  "reopenedDate": "2020-05-13T16:03:44.000Z",
  "lastCommentDate": "2020-05-21T08:23:28.000Z",
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44700/files",
  "hasMergeConflict": false,
  "authorIsOwner": false,
  "isFirstContribution": false,
  "popularityLevel": "Critical",
  "anyPackageIsNew": false,
  "packages": [
    "node",
    "window-or-global"
  ],
  "files": [
    {
      "filePath": "types/node/globals.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/globals.global.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/index.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/ts3.2/base.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/ts3.2/index.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/ts3.5/base.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/ts3.5/globals.global.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/ts3.5/test/globals.ts",
      "kind": "test",
      "package": "node"
    },
    {
      "filePath": "types/node/ts3.5/tsconfig.json",
      "kind": "package-meta",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/globals.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/globals.global.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/index.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/package.json",
      "kind": "package-meta",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.2/base.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.2/index.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.4/base.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.4/globals.global.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.4/index.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.4/node-tests.ts",
      "kind": "test",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.4/test/globals.ts",
      "kind": "test",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.4/tsconfig.json",
      "kind": "package-meta",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.4/tslint.json",
      "kind": "package-meta",
      "package": "node"
    },
    {
      "filePath": "types/node/v12/ts3.7/base.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/globals.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/globals.global.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/index.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/ts3.2/base.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/ts3.2/index.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/ts3.5/base.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/ts3.5/globals.global.d.ts",
      "kind": "definition",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/ts3.5/test/globals.ts",
      "kind": "test",
      "package": "node"
    },
    {
      "filePath": "types/node/v13/ts3.5/tsconfig.json",
      "kind": "package-meta",
      "package": "node"
    },
    {
      "filePath": "types/window-or-global/index.d.ts",
      "kind": "definition",
      "package": "window-or-global"
    },
    {
      "filePath": "types/window-or-global/package.json",
      "kind": "package-meta",
      "package": "window-or-global"
    },
    {
      "filePath": "types/window-or-global/ts3.4/index.d.ts",
      "kind": "definition",
      "package": "window-or-global"
    },
    {
      "filePath": "types/window-or-global/ts3.4/tsconfig.json",
      "kind": "package-meta",
      "package": "window-or-global"
    },
    {
      "filePath": "types/window-or-global/ts3.4/tslint.json",
      "kind": "package-meta",
      "package": "window-or-global"
    },
    {
      "filePath": "types/window-or-global/ts3.4/window-or-global-tests.ts",
      "kind": "test",
      "package": "window-or-global"
    }
  ],
  "hasDismissedReview": false,
  "travisResult": "pass",
  "lastReviewDate": "2020-05-21T11:14:55.000Z",
  "reviewersWithStaleReviews": [],
  "approvalFlags": 2,
  "isChangesRequested": false
}

@typescript-bot
Copy link
Contributor

typescript-bot commented May 13, 2020

@JasonHK
Copy link
Contributor Author

JasonHK commented May 16, 2020

@SimonSchick
Copy link
Contributor

Can we perhaps add these changes to TS3.5 instead to avoid fragmenting versions even further?

@ExE-Boss
Copy link
Contributor

You should also add tests for globalThis members to types/node/ts3.4/test/global.ts.

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board May 18, 2020
@JasonHK
Copy link
Contributor Author

JasonHK commented May 18, 2020

Can we perhaps add these changes to TS3.5 instead to avoid fragmenting versions even further?

@SimonSchick Thanks for your advice, I'll update it today.

@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Code Reviews in New Pull Request Status Board May 18, 2020
@JasonHK
Copy link
Contributor Author

JasonHK commented May 19, 2020

@SimonSchick @ExE-Boss The latest commit should have fixed the issues you mentioned, please tell me if there were things that also need to be fixed.

@typescript-bot typescript-bot added the Has Merge Conflict This PR can't be merged because it has a merge conflict. The author needs to update it. label May 20, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board May 20, 2020
@typescript-bot
Copy link
Contributor

@JasonHK Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day!

@typescript-bot typescript-bot removed the Has Merge Conflict This PR can't be merged because it has a merge conflict. The author needs to update it. label May 20, 2020
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board May 20, 2020
Copy link
Contributor

@ExE-Boss ExE-Boss left a comment

Choose a reason for hiding this comment

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

LGTM with the following nits.


P.S.: The Node v12.x types should use TS3.4+ instead of TS3.5+.

types/window-or-global/index.d.ts Outdated Show resolved Hide resolved
types/window-or-global/ts3.4/index.d.ts Outdated Show resolved Hide resolved
@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label May 20, 2020
@typescript-bot typescript-bot removed the Owner Approved A listed owner of this package signed off on the pull request. label May 20, 2020
@typescript-bot
Copy link
Contributor

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

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label May 20, 2020
Co-authored-by: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
@typescript-bot typescript-bot removed the Owner Approved A listed owner of this package signed off on the pull request. label May 21, 2020
@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label May 21, 2020
@sheetalkamat sheetalkamat merged commit 1ac17e4 into DefinitelyTyped:master May 21, 2020
@typescript-bot typescript-bot removed this from Waiting for Code Reviews in New Pull Request Status Board May 21, 2020
@typescript-bot
Copy link
Contributor

I just published @types/node@14.0.5 to npm.

JasonHK added a commit to JasonHK/node-globalthis that referenced this pull request May 22, 2020
JasonHK added a commit to JasonHK/node-globalthis that referenced this pull request May 22, 2020
jjballano-qatium pushed a commit to jjballano-qatium/DefinitelyTyped that referenced this pull request Jun 16, 2020
ngbrown pushed a commit to ngbrown-forks/DefinitelyTyped that referenced this pull request Jul 11, 2020
taneliang added a commit to taneliang/neh that referenced this pull request Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical package Owner Approved A listed owner of this package signed off on the pull request. Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants