Skip to content

WIP: feat(node): v13#40438

Closed
SimonSchick wants to merge 2 commits intoDefinitelyTyped:masterfrom
SimonSchick:feat/node-v13
Closed

WIP: feat(node): v13#40438
SimonSchick wants to merge 2 commits intoDefinitelyTyped:masterfrom
SimonSchick:feat/node-v13

Conversation

@SimonSchick
Copy link
Contributor

@SimonSchick SimonSchick commented Nov 16, 2019

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://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V13.md#13.1.0
  • 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.
  • 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.

This ended up being quite a large PR and I want some feedback on if we can proceed with this or if this needs to be broken down further.

General list of changes:

  • Changed constants to be re-exported in constants module to avoid duplication.
  • Removed various es2015, 16, 17 shims (requires es2018 lib now).
    • Have to potentially revert since /// references don't support lib until TS 3.x async iteration ones retained
  • Various type restrictions in API that could be considered breaking changes.
  • Alias Moved various global interface into NodeJS namespace.
    • Have to potentially retain some globals to not break other packages.
  • Scheduling in cluster
  • Use of unique symbol
  • Removal of redundant interfaces
  • Replaced global EventEmitter class with interface as it's purely virtual and only there for global declarations.
    • This required various updates in other package since they sometimes used extends EventEmitter or extends NodeJS.EventEmitter.

This is somewhat WIP and I expect lots of changes.

@typescript-bot typescript-bot added New Definition This PR creates a new definition package. 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. The Travis CI build failed labels Nov 16, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 16, 2019

@SimonSchick Thank you for submitting this PR!

Because this is a new definition, a DefinitelyTyped maintainer will be reviewing this PR in the next few days once the Travis CI build passes.

In the meantime, if the build fails or a merge conflict occurs, I'll let you know. Have a nice day!

@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 16, 2019

@SimonSchick The Travis 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
Copy link
Contributor

@SimonSchick The Travis 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
Copy link
Contributor

typescript-bot commented Nov 17, 2019

@SimonSchick The Travis 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
Copy link
Contributor

typescript-bot commented Nov 17, 2019

@SimonSchick The Travis CI build failed! Please review the logs for more information.

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

@SimonSchick
Copy link
Contributor Author

Hey @Flarna mind giving some early input?
This is pretty WIP and I will likely have to revert a thing or 2 :)

@typescript-bot typescript-bot removed the Author is Owner The author of this PR is a listed owner of the package. label Nov 17, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 17, 2019

@SimonSchick The Travis CI build failed! Please review the logs for more information.

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

@Flarna
Copy link
Contributor

Flarna commented Nov 17, 2019

Had a few minutes only therefore not seen most of the changes.
2 findings:

@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 18, 2019

@SimonSchick The Travis CI build failed! Please review the logs for more information.

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

prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
}

const SCHED_NONE: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add these two also to interface cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to dedupe cluster, will take care of this tho!

}

{
new events();
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, have you seen this used anywhere in the ecosystem?
Things like these are super annoying to model and usually require hacks such as fake inheritance.
Any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't remember a specific place; I expect this is a relict from node 0.x so if this is used somewhere then most likely in old modules.
It's the same/similar for module (see https://github.com/nodejs/node/blob/v13.1.0/lib/internal/modules/cjs/loader.js#L1261) and stream as also similar.
What was the problem with the exisiting variant export = internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured v13 was a good opportunity to clean things up a bit and remove this virtual inheritance nonsense, but it sounds like this could break a few people 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually pretty curious to see how many people would be affected by this.
Do you think it would be an acceptable risk to do this on v13 or does it have too much potential for breaking changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know ES6 modules don't allow such exports anyway so seems to be a step forward. Fixing an app is easy so I'm ok with it. Reverting in case of a lot complains should be also not that hard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same applies to module, stream. Although I won't be touching stream for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly speaking I would be also careful with module as this is usually just required to get the static methods exposed there. So at least these should be kept.

// Buffer class
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";

interface Buffer {
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 this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not really needed and was a special case that was added just because someone wanted to have access to the type safe constructor ¯\(ツ)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I remember... was related to webpack to avoid that too much is packed.
So you plan is to break the build for this user? 😕

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 sounds odd, usually types don't affect webpack builds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#28900 there is no mention of Webpack in this issue. Seems like it was pure convenience, since buffer was moved to a class it most likely doesn't matter anymore.

Copy link
Contributor

@Flarna Flarna Nov 18, 2019

Choose a reason for hiding this comment

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

The comment was Because if i do that, bundlers include an entire Buffer polyfill, I assumed the bundler was webpack but could be anything.
Anyhow, I feel not well in removing this added by someone else by a dedicated PR. It doesn't harm and let's hope that typescript is at some time able to ship this out of the box.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

webpack doesn't implicitly emit node polyfills anymore.
And in any case the person can just cast Buffer.constructor to typeof Buffer 😛

* @deprecated Deprecated since: v12.2.0. Please use createRequire() instead.
*/
static createRequireFromPath(path: string): NodeJS.RequireFunction;
static createRequire(path: string): NodeJS.RequireFunction;
Copy link
Contributor

Choose a reason for hiding this comment

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

A while ago I tried also to move Module from gobal to here but failed for some reason and never created a PR. Maybe because of some typescript version no longer supported...
Anyhow, could you please add URL support here: static createRequire(path: string | URL) and import { URL } from "url";.

That time I had also some you could reuse now:

import m = require('module');
import { createRequireFromPath, createRequire } from 'module';
import { URL } from "url";

let rf: (m: string) => any;

rf = createRequire('mod');
rf = createRequireFromPath('mod');
rf = createRequire(new URL('file:///C:/path/'));

const aModule: NodeModule = new m.Module("s");
const bModule: NodeModule = new m("b", aModule);

const builtIn: string[] = m.builtinModules;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

@SimonSchick
Copy link
Contributor Author

@sandersn I'm not sure who's in an authority position but can we potentially halt all merged to the node package until v13 is done?
I have to constantly rebase and manually update the v12 folder.
Also the build has been broken for days (passes locally).

Is there any way we can move forward in getting this in?

@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 Nov 26, 2019
@typescript-bot
Copy link
Contributor

@SimonSchick The Travis CI build failed! Please review the logs for more information.

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

@SimonSchick
Copy link
Contributor Author

Great, so the requirement for file inclusion changed...
How do I fix this correctly?
Can we skip this for now?

@sandersn
Copy link
Contributor

You haven't touched tsconfig, so you should be able to merge from master to get rid of the now-excess d.ts references in the files list. See microsoft/types-publisher#708 for details.

@sandersn
Copy link
Contributor

As for reviewers from the TS team, @rbuckton is the local node expert, although he's on vacation for Thanksgiving until next Monday.

@SimonSchick
Copy link
Contributor Author

I missed updating the moved tsconfig file yes, I already fixed it.

@sandersn
Copy link
Contributor

Now there's a failure with an unused test file:

Unused file /home/vsts/work/1/s/types/node/v12/test/async_hooks.ts (used files: ["assert.ts","buffer.ts","child_process.ts","cluster.ts","crypto.ts","dgram.ts","events.ts","fs.ts","global.ts","http.ts","http2.ts","net.ts","os.ts","path.ts","perf_hooks.ts","process.ts","querystring.ts","readline.ts","repl.ts","stream.ts","string_decoder.ts","tls.ts","tty.ts","util.ts","v8.ts","vm.ts","worker_threads.ts","zlib.ts"])

This looks to me like it's just missing from v12/tsconfig.json.

@SimonSchick
Copy link
Contributor Author

Yea I'm on it, I tried to be too smart with git :)

@SimonSchick
Copy link
Contributor Author

Seems like there are more packages that violate the new tsconfig rules:

Found 6232 packages.
Parsing in parallel...
Error: Unused file /Users/simon/projects/DefinitelyTyped/types/flux/lib/FluxContainer.d.ts

Btw it would be great if it would emit a list of all files, not just the first it can find and bail.

@sandersn
Copy link
Contributor

sandersn commented Nov 26, 2019

Is that from a local run? I don't see it on my local run. You merged from master already, right?

Edit: And I don't see it on the Azure run either.

@SimonSchick
Copy link
Contributor Author

Well no, but apparently npm doesn't like updating sometimes when using non npm packages eg. github:Microsoft/types-publisher#production and it also doesn't show up as outdated 😛
Updating that package seems to have fixed it.

@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 27, 2019

@SimonSchick The Travis 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
Copy link
Contributor

@SimonSchick I haven't seen anything from you in a while and this PR currently has problems that prevent it from being merged. The PR will be closed tomorrow if there aren't new commits to fix the issues.

@SimonSchick
Copy link
Contributor Author

@rbuckton Can we move forward on this before the bot it's thing again (mildly frustrating btw).

@typescript-bot typescript-bot added the Abandoned This PR had no activity for a long time, and is considered abandoned label Dec 3, 2019
@typescript-bot
Copy link
Contributor

@SimonSchick To keep things tidy, we have to close PRs that aren't mergeable but don't have activity from their author. No worries, though - please open a new PR if you'd like to continue with this change. Thank you!

@SimonSchick
Copy link
Contributor Author

I'm growing progressively dissatisfied with this bot...

@SimonSchick
Copy link
Contributor Author

@rbuckton (sorry for the many mentions), but what do?
If I re-open the PR the build will probably fail again 😅

@SimonSchick
Copy link
Contributor Author

ping

@Flarna
Copy link
Contributor

Flarna commented Dec 6, 2019

@SimonSchick To keep a PR alive it's needed to keep the commit date young. a merge from master, rebase or just git commit --amend without a change followed by a push should be enough as keep alive. On the other hand creating a new PR based on old branch result in a fast close by bot.

@SimonSchick
Copy link
Contributor Author

I'm hesitant to create a new PR after seeing how this one went.
Can we please have some sort of exception for the node package for the bot not to close PRs for it, or at least keep them open longer?
The build/ci process has been notoriously unstable (randomly breaking) and lengthy for anything that touches the node typings.

@SimonSchick SimonSchick mentioned this pull request Dec 9, 2019
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned This PR had no activity for a long time, and is considered abandoned New Definition This PR creates a new definition 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.

4 participants