-
Notifications
You must be signed in to change notification settings - Fork 30.5k
[node] v15.0.0 released #48981
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] v15.0.0 released #48981
Conversation
|
👋 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? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
|
I noticed Edit: Done. |
Thanks! I have added this to PR. This PR is not ready, it is in progress state. I created it for collect advices and fix mistakes early. There are many types which should be defined (Crypto, AbortSignal, Event, EventTarget, ...), you can take some if you want to help. |
|
Hey @Semigradsky can you change the description to a checklist with the features you already implemented and what needs to be finished? So I can implement what is missing. :) |
|
@victorperin hi! I will update description later. You can take |
| setServers: typeof setServers; | ||
| } | ||
| } | ||
| const promises: typeof dnsPromises; |
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.
| const promises: typeof dnsPromises; | |
| export { dnsPromises as promises }; |
| unref(): void; | ||
| } | ||
|
|
||
| const promises: typeof streamPromises; |
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.
| const promises: typeof streamPromises; | |
| export { streamPromises as promises }; |
types/node/events.d.ts
Outdated
| interface EventInit { | ||
| bubbles?: boolean; | ||
| cancelable?: boolean; | ||
| composed?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * The `Event` object is an adaptation of the `Event Web API`. | ||
| * Instances are created internally by Node.js. | ||
| */ | ||
| class Event { | ||
| constructor(type: string, eventInitDict?: EventInit); | ||
| /** | ||
| * Always returns `false`. | ||
| * | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| readonly bubbles: boolean; | ||
| /** | ||
| * Alias for `event.stopPropagation()`. | ||
| * | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| cancelBubble(): void; | ||
| /** | ||
| * True if the event was created with the `cancelable` option. | ||
| */ | ||
| readonly cancelable: boolean; | ||
| /** | ||
| * Always returns `false`. | ||
| * | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| readonly composed: boolean; | ||
| /** | ||
| * Returns an array containing the current `EventTarget` as the only entry | ||
| * or empty if the event is not being dispatched. | ||
| * | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| composedPath(): EventTarget[]; | ||
| /** | ||
| * The `EventTarget` dispatching the event. | ||
| * | ||
| * Alias for `event.target`. | ||
| */ | ||
| readonly currentTarget: EventTarget | null; | ||
| /** | ||
| * Is true if `cancelable` is true and `event.preventDefault()` has been called. | ||
| */ | ||
| readonly defaultPrevented: boolean; | ||
| /** | ||
| * Returns `0` while an event is not being dispatched, `2` while it is being dispatched. | ||
| * | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| readonly eventPhase: number; | ||
| /** | ||
| * Always returns `false`. | ||
| * | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| readonly isTrusted: boolean; | ||
| /** | ||
| * Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. | ||
| */ | ||
| preventDefault(): void; | ||
| /** | ||
| * True if the event has not been canceled. | ||
| * | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| returnValue: boolean; | ||
| /** | ||
| * The `EventTarget` dispatching the event. | ||
| * | ||
| * Alias for `event.target`. | ||
| */ | ||
| readonly srcElement: EventTarget; | ||
| /** | ||
| * Stops the invocation of event listeners after the current one completes. | ||
| */ | ||
| stopImmediatePropagation(): void; | ||
| /** | ||
| * This is not used in Node.js and is provided purely for completeness. | ||
| */ | ||
| stopPropagation(): void; | ||
| /** | ||
| * The `EventTarget` dispatching the event. | ||
| */ | ||
| readonly target: EventTarget; | ||
| /** | ||
| * The millisecond timestamp when the `Event` object was created. | ||
| */ | ||
| readonly timeStamp: number; | ||
| /** | ||
| * The event type identifier. | ||
| */ | ||
| readonly type: string; | ||
|
|
||
| static readonly NONE: 0; | ||
| static readonly CAPTURING_PHASE: 1; | ||
| static readonly AT_TARGET: 2; | ||
| static readonly BUBBLING_PHASE: 3; | ||
| } | ||
|
|
||
| interface EventLike { | ||
| type: string; | ||
| } | ||
|
|
||
| interface EventListenerOptions { | ||
| /** | ||
| * Not directly used by Node.js. Added for API completeness. | ||
| */ | ||
| capture?: boolean; | ||
| } | ||
|
|
||
| interface AddEventListenerOptions extends EventListenerOptions { | ||
| /** | ||
| * When `true`, the listener is automatically removed when it is first invoked | ||
| */ | ||
| once?: boolean; | ||
| /** | ||
| * When `true`, serves as a hint that the listener will not call | ||
| * the `Event object's `preventDefault()` method. | ||
| */ | ||
| passive?: boolean; | ||
| } | ||
|
|
||
| type EventListener = ((event: Event) => void) | { handleEvent(event: Event): void; }; | ||
|
|
||
| class EventTarget { | ||
| constructor(); | ||
| /** | ||
| * Adds a new handler for the `type` event. Any given `listener` is added | ||
| * only once per `type` and per `capture` option value. | ||
| * | ||
| * If the `once` option is `true`, the `listener` is removed after the next time a `type` event is dispatched. | ||
| * | ||
| * The `capture` option is not used by Node.js in any functional way other than | ||
| * tracking registered event listeners per the `EventTarget` specification. | ||
| * Specifically, the `capture` option is used as part of the key when registering a `listener`. | ||
| * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. | ||
| */ | ||
| addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; | ||
| /** | ||
| * Dispatches the `event` to the list of handlers for `event.type`. | ||
| * | ||
| * The registered event listeners is synchronously invoked in the order they were registered. | ||
| */ | ||
| dispatchEvent(event: Event | EventLike): boolean; | ||
| /** | ||
| * Removes the `listener` from the list of handlers for event `type`. | ||
| */ | ||
| removeEventListener(type: string, callback: EventListener, options?: EventListenerOptions | boolean): void; | ||
| } |
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.
These need to be moved to the top‑level of global, since otherwise they won’t be accessible through the identifiers or globalThis, and the NodeJS namespace doesn’t exist at runtime.
types/node/globals.d.ts
Outdated
| /** | ||
| * A utility class used to signal cancelation in selected `Promise`-based APIs. | ||
| * The API is based on the Web API `AbortController`. | ||
| */ | ||
| class AbortController { | ||
| /** | ||
| * Returns the AbortSignal object associated with this object. | ||
| */ | ||
| readonly signal: AbortSignal; | ||
| /** | ||
| * Triggers the abort signal, causing the `abortController.signal` to emit the `'abort'` event. | ||
| */ | ||
| abort(): void; | ||
| } | ||
|
|
||
| /** | ||
| * The `AbortSignal` is used to notify observers when | ||
| * the `abortController.abort()` method is called. | ||
| */ | ||
| class AbortSignal extends EventTarget { | ||
| /** | ||
| * True after the `AbortController` has been aborted. | ||
| */ | ||
| readonly aborted: boolean; | ||
| /** | ||
| * An optional callback function that may be set by user code | ||
| * to be notified when the `abortController.abort()` function has been called. | ||
| */ | ||
| onabort: ((event: Event) => void) | null; | ||
| } |
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.
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.
In this case I have errors:
Duplicate identifier 'AbortController'.ts(2300)
lib.dom.d.ts(1931, 11): 'AbortController' was also declared here.
lib.dom.d.ts(1942, 13): and here.
Any ideas how to fix this?
The same with MessageEvent and others
types/node/worker_threads.d.ts
Outdated
| /** A message received by a target object. */ | ||
| class MessageEvent<T = any> extends Event { | ||
| /** | ||
| * Returns the data of the message. | ||
| */ | ||
| readonly data: T; | ||
| /** | ||
| * Returns the last event ID string, for server-sent events. | ||
| */ | ||
| readonly lastEventId: string; | ||
| /** | ||
| * Returns the origin of the message, for server-sent events and cross-document messaging. | ||
| */ | ||
| readonly origin: string; | ||
| /** | ||
| * Returns the MessagePort array sent with the message, for cross-document messaging and channel messaging. | ||
| */ | ||
| readonly ports: ReadonlyArray<MessagePort>; | ||
| } |
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.
| declare module "crypto" { | ||
| // TODO: Define `Crypto` | ||
| type Crypto = any; | ||
|
|
||
| const webCrypto: Crypto; | ||
| } |
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.
| declare module "crypto" { | |
| // TODO: Define `Crypto` | |
| type Crypto = any; | |
| const webCrypto: Crypto; | |
| } | |
| interface NodeCrypto extends Crypto { | |
| readonly CryptoKey: typeof CryptoKey | |
| } | |
| declare module 'crypto' { | |
| const webcrypto: NodeCrypto | |
| } |
Crypto is already defined in TS's lib.dom.d.ts. This just adds the "webcrypto" (you mistyped the property name, capitalizing the C) property as a crypto export and also adds the CryptoKey class instance.
Note: i'm not taking the node.js specific extensions into account here.
types/node/test/crypto.ts
Outdated
|
|
||
| { | ||
| (async () => { | ||
| const key = await crypto.webCrypto.subtle.generateKey({ |
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.
| const key = await crypto.webCrypto.subtle.generateKey({ | |
| const key = await crypto.webcrypto.subtle.generateKey({ |
- QUIC: Node.js 15 comes with experimental support QUIC - WIP - assert: add assert/strict alias module - dns: add dns/promises alias - lib: add EventTarget-related browser globals - lib: initial experimental AbortController implementation - crypto: refactoring internals, add WebCrypto - fs: deprecation warning on recursive rmdir - net: remove long deprecated server.connections property - stream: add promises version to utility functions - timers: introduce timers/promises - util: change default value of maxStringLength to 10000 - crypto: add getCipherInfo method - events: allow use of AbortController with on - events: allow use of AbortController with once - http2: add support for sensitive headers - net: add support for resolving DNS CAA records - net: introduce net.BlockList - timers: allow promisified timeouts/immediates to be canceled WIP
|
@Semigradsky Hi, what's the status of this PR, would you like continue doing this so that we can move forward ? |
|
@ZYSzys feel free to use my changes in your PR 👍 |
|
Closed in favor of #52357 |
https://github.com/nodejs/node/releases/tag/v15.0.0
WIP