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] Add node:‑prefixed module aliases #51107

Conversation

ExE-Boss
Copy link
Contributor

@ExE-Boss ExE-Boss commented Feb 7, 2021

Please fill in this template.

If changing an existing definition:

@typescript-bot typescript-bot added Critical package Author is Owner The author of this PR is a listed owner of the package. Check Config Changes a module config files labels Feb 7, 2021
@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board Feb 7, 2021
@typescript-bot
Copy link
Contributor

typescript-bot commented Feb 7, 2021

@ExE-Boss Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in 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
  • ✅ A DT maintainer needs to approve changes which affect module config files

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 51107,
  "author": "ExE-Boss",
  "headCommitOid": "a70c7573e100376db55762025065ec3b3af16690",
  "lastPushDate": "2021-02-07T14:47:40.000Z",
  "lastActivityDate": "2021-02-12T09:08:13.000Z",
  "maintainerBlessed": false,
  "mergeOfferDate": "2021-02-11T20:05:32.000Z",
  "mergeRequestDate": "2021-02-12T09:07:52.000Z",
  "mergeRequestUser": "ExE-Boss",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "node",
      "kind": "edit",
      "files": [
        {
          "path": "types/node/assert.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/async_hooks.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/buffer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/child_process.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/cluster.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/console.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/constants.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/crypto.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/dgram.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/dns.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/domain.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/events.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/fs.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/fs/promises.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/http.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/http2.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/https.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/inspector.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/module.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/net.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/node-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/node/os.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/path.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/perf_hooks.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/process.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/punycode.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/querystring.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/readline.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/repl.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/scripts/generate-inspector/inspector.d.ts.template",
          "kind": "package-meta",
          "suspect": "edited"
        },
        {
          "path": "types/node/stream.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/string_decoder.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/test/assert.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/async_hooks.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/buffer.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/child_process.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/cluster.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/constants.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/crypto.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/dgram.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/dns.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/events.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/fs.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/global.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/http.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/http2.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/module.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/net.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/os.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/path.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/perf_hooks.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/process.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/querystring.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/readline.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/repl.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/stream.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/string_decoder.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/tls.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/tty.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/url.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/util.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/v8.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/vm.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/wasi.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/worker_threads.ts",
          "kind": "test"
        },
        {
          "path": "types/node/test/zlib.ts",
          "kind": "test"
        },
        {
          "path": "types/node/timers.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/tls.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/trace_events.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/ts3.4/assert.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/ts3.4/node-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/node/ts3.6/node-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/node/tty.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/url.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/util.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/assert.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/async_hooks.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/buffer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/child_process.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/cluster.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/console.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/constants.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/crypto.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/dgram.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/dns.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/domain.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/events.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/fs.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/http.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/http2.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/https.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/inspector.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/module.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/net.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/node-tests.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v12/os.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/path.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/perf_hooks.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v12/process.d.ts",
          "kind": "definition"
        }
      ],
      "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",
        "galkin",
        "parambirs",
        "eps1lon",
        "SimonSchick",
        "ThomasdenH",
        "WilcoBakker",
        "wwwy3y3",
        "samuela",
        "kuehlein",
        "j-oliveras",
        "bhongy",
        "chyzwar",
        "trivikr",
        "nguymin4",
        "yoursunny",
        "qwelias",
        "ExE-Boss",
        "Ryan-Willpower",
        "peterblazejewicz",
        "addaleax",
        "JasonHK",
        "victorperin",
        "ZYSzys"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "rbuckton",
      "date": "2021-02-11T20:04:56.000Z",
      "isMaintainer": true
    }
  ],
  "ciResult": "pass"
}

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Feb 7, 2021
@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/v14.14

Comparison details for node/14.14 📊
master #51107 diff
Batch compilation
Memory usage (MiB) 132.7 132.3 -0.2%
Type count 22675 22610 0%
Assignability cache size 7617 7584 0%
Language service
Samples taken 28 28 0%
Identifiers in tests 28 28 0%
getCompletionsAtPosition
    Mean duration (ms) 687.8 679.6 -1.2%
    Mean CV 11.7% 10.0%
    Worst duration (ms) 851.4 837.7 -1.6%
    Worst identifier instance instance
getQuickInfoAtPosition
    Mean duration (ms) 668.1 670.7 +0.4%
    Mean CV 9.3% 10.4%
    Worst duration (ms) 764.1 707.2 -7.5%
    Worst identifier instantiate process

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

node/v14.14

Comparison details for node/14.14 📊
master #51107 diff
Batch compilation
Memory usage (MiB) 124.8 124.3 -0.4%
Type count 22675 22610 0%
Assignability cache size 7617 7584 0%
Language service
Samples taken 28 28 0%
Identifiers in tests 28 28 0%
getCompletionsAtPosition
    Mean duration (ms) 681.2 680.9 0.0%
    Mean CV 10.7% 9.7%
    Worst duration (ms) 924.7 849.7 -8.1%
    Worst identifier instance start
getQuickInfoAtPosition
    Mean duration (ms) 675.4 678.3 +0.4%
    Mean CV 10.3% 9.2%
    Worst duration (ms) 760.4 778.5 +2.4%
    Worst identifier WebAssembly instance

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

@typescript-bot typescript-bot added Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. The CI failed When GH Actions fails labels Feb 7, 2021
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Needs Author Action in New Pull Request Status Board Feb 7, 2021
@typescript-bot
Copy link
Contributor

@ExE-Boss The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Feb 7, 2021
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Feb 7, 2021
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Feb 7, 2021
@rbuckton
Copy link
Collaborator

I think using the non-prefixed version is the correct call, as anyone currently using module augmentation against a module like fs, for example, wouldn't be broken by this change. Users will have to take care, however, that they don't add module augmentations for the node:-prefixed versions. It may be worthwhile to add a comment as to why the non-prefixed form is the version that contains the definitions.

This does lead to an interesting discussion we should have in the TypeScript team about the possibility of defining multiple canonical names for a package in the package itself (as I think this can be accomplished using "paths" on a per-project basis). I've filed microsoft/TypeScript#42764 to track this on the TypeScript side.

/cc @DanielRosenwasser @sheetalkamat

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels Feb 11, 2021
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Author to Merge in New Pull Request Status Board Feb 11, 2021
@Flarna
Copy link
Contributor

Flarna commented Feb 11, 2021

As far as I know the prefixed versions work only in esm mode but not in commonjs.
But I guess there is no way to add the prefixed versions only if users transpile to esm.

@ExE-Boss
Copy link
Contributor Author

Ready to merge

@ExE-Boss
Copy link
Contributor Author

@Flarna The node:‑prefixed form is coming to CommonJS as well: nodejs/node#36098 (PR nodejs/node#37246)

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Feb 12, 2021
@typescript-bot typescript-bot merged commit cd10dd7 into DefinitelyTyped:master Feb 12, 2021
@ExE-Boss ExE-Boss deleted the types/node/add-node-prefixed-module-aliases branch February 12, 2021 09:09
@typescript-bot
Copy link
Contributor

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

@typescript-bot
Copy link
Contributor

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

@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Feb 12, 2021
ansu5555 pushed a commit to ansu5555/DefinitelyTyped that referenced this pull request Feb 19, 2021
…liases by @ExE-Boss

* [node] Add `node:`‑prefixed module aliases

* fixup! [node] Add `node:`‑prefixed module aliases
kaznovac pushed a commit to kaznovac/DefinitelyTyped that referenced this pull request Mar 2, 2021
…liases by @ExE-Boss

* [node] Add `node:`‑prefixed module aliases

* fixup! [node] Add `node:`‑prefixed module aliases
@lucascaro
Copy link

lucascaro commented Mar 31, 2021

I think this change broke my IDE (vscode), it will alwaws add the node: prefix to all imports even when working with commonjs modules. node itself has no idea how to "import path from "node:path" or what node:path is.

is there any way to opt out and back into the non-prefixed version?

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Apr 1, 2021

@lucascaro That will most likely depend on microsoft/TypeScript#42764.

@SimonSchick
Copy link
Contributor

Should we perhaps temporarily revert this then? I have not seen the node: prefix in the wild yet.

@lucascaro
Copy link

either reverting or moving the prefixed declarations after the non-prefixed ones would work, I think.

@adekau
Copy link

adekau commented Apr 20, 2021

Should we perhaps temporarily revert this then? I have not seen the node: prefix in the wild yet.

I discovered this pull request after looking into a StackOverflow question (https://stackoverflow.com/questions/67172090/vscode-typescript-why-suggest-auto-import-from-nodepath), so it seems like something that is starting to show up in the wild.

@G-Rath
Copy link
Contributor

G-Rath commented Apr 20, 2021

@ExE-Boss @SimonSchick I think we should just revert this for now, at least until it lands in new versions of node. Ideally it might best to wait until this feature is available in the current LTS (which if I'm understanding things correctly, will be v16 which is in a few months so not that far away) before re-landing it.

It might be worth including a check for this in eslint-plugin-node too? (/cc @mysticatea - I'm thinking one of the node/no-unsupported-features rules maybe?)

(I'm also getting this behaviour in WebStorm btw - it prefers node: when suggesting where to import native modules from)

@matt-huh
Copy link
Contributor

Reverting this sounds good. VSCode does auto imports well for my old projects, but it's broken for my new projects with the latest type definition.

@SimonSchick
Copy link
Contributor

Currently my nodev15 PR contains node aliases, can we have a decision here so I can either remove them or move forward?

@ExE-Boss
Copy link
Contributor Author

@SimonSchick I’d prefer if we tried moving the node:‑prefixed module names after the unprefixed forms before removing them entirely.

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. Check Config Changes a module config files Critical package Maintainer Approved Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Self Merge This PR can now be self-merged by the PR author or an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants