Skip to content

Remove static abort from AbortSignal #1093

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

Merged
merged 2 commits into from
Aug 11, 2021
Merged

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Aug 4, 2021

@types/node doesn't have it, and it's not worth it to make @types/node create a new typingsVersion.

@types/node doesn't have it, and it's not worth it to make @types/node
create a new @types/node version.

Co-authored-by: Orta Therox <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2021

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

"AbortSignal": {
"methods": {
"method": {
"abort": null
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 this one should be preferred over node, as Node is just following the web standard? What happened there?

@SimonSchick
Copy link
Contributor

But node does have this method?

Type ".help" for more information.
> AbortSignal.abort()
AbortSignal { aborted: true }

@saschanaz
Copy link
Contributor

But node does have this method?

Web browsers and Node.js have the method defined as https://dom.spec.whatwg.org/#interface-AbortSignal .

@orta
Copy link
Contributor

orta commented Aug 4, 2021

Yeah, agree - its more that we didn't think adding this was worth forcing @types/node to have to switch to TS 4.5 for their types and then requiring many projects to update for this one property. Not that it's incorrect

@saschanaz
Copy link
Contributor

Can it be fixed locally in TS rather than affecting @types/web?

@orta
Copy link
Contributor

orta commented Aug 4, 2021

It's a normal assignability bug, not a change in TypeScript (you can see a tonne in here)

node_modules/@types/node/globals.d.ts(85,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; abort(): AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; }'.

Basically it means that anyone with a current or older version of @types/node cannot upgrade to TS 4.5 without updating their node types, and it means that the @types/node would need to bump their minimum TS version to 4.5 for this one property.

Which to me isn't a reasonable trade-off for that extra definition

@saschanaz
Copy link
Contributor

I mean, we'll have to add that to node one day, so it would be good if TS have a local patch that removes abort() so that anyone need it can install @types/web?

@saschanaz
Copy link
Contributor

That can happen in deploy script IMO.

@SimonSchick
Copy link
Contributor

Can we not change the type of AbortSignal to be an interface and use declaration merging?

@saschanaz
Copy link
Contributor

Can we not change the type of AbortSignal to be an interface and use declaration merging?

Sounds like an option tbh.

@sandersn
Copy link
Member Author

sandersn commented Aug 6, 2021

Does the code have the ability to generate an interface for the static side too? If not, I guess we could add that.

@saschanaz
Copy link
Contributor

No such ability, I think AbortSignal can be special cased.

@sandersn
Copy link
Member Author

sandersn commented Aug 6, 2021

oh, I forgot about addedTypes.jsonc. That should work.

@orta
Copy link
Contributor

orta commented Aug 6, 2021

So, I think we're going to have to take this PR as-is because I don't think we're going to get a good answer which doesn't force users to update node or force a typesVersion on node before the release today. We shipped a build to TypeScript with these changes in, because we don't want to force the node update on anyone migrating to the new TS build, and I want to have corresponding @types/web to refer to it.

I'll make a PR reverting it after we're sure the RC dom is going to be what we ship in TS.

I brought up microsoft/TypeScript#43972 in a TS language design meeting on Wednesday and there was general agreement to explore finding the common subset and extract it in here which is going to probably be tricky work in this repo. microsoft/TypeScript#45328

@saschanaz
Copy link
Contributor

I want to have corresponding @types/web to refer to it.

I'd prefer manual patching in deploy script if this isn't a strict requirement.

@orta
Copy link
Contributor

orta commented Aug 6, 2021

It's not, I can do that

@saschanaz
Copy link
Contributor

Looks good, please reformat 😉

@orta orta force-pushed the remove-abort-from-AbortSignal branch from 5c5d446 to 8e00927 Compare August 6, 2021 16:31
@orta orta force-pushed the remove-abort-from-AbortSignal branch from 8e00927 to e79b67f Compare August 6, 2021 16:33
@saschanaz
Copy link
Contributor

LGTM

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2021

Sorry @saschanaz, you don't have access to merge: /deploy/createTypesPackages.js.

iterateThroughFiles((content) => {
return content.replace(
"abort(): AbortSignal;",
"// abort(): AbortSignal; - To be re-added in the future"
Copy link
Contributor

Choose a reason for hiding this comment

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

This maaayy advertise @types/web but your call really.

@orta
Copy link
Contributor

orta commented Aug 11, 2021

OK, let's get this in - which will unblock merging some of the other PRs

@orta orta merged commit 237685a into main Aug 11, 2021
@sandersn sandersn deleted the remove-abort-from-AbortSignal branch September 7, 2021 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants