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

Introduce ES2024 target and fix some types #58573

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

petamoriken
Copy link
Contributor

@petamoriken petamoriken commented May 19, 2024

Fixes #54636
Past PRs #54637, #57858
Refs denoland/deno#19191, denoland/deno#24238

This PR includes the following changes:

Introduce ES2024 target

  • Introduce ES2024 target
  • Move some ESNext types to ES2024
  • BREAKING: Move Atomics.waitAsync types from ES2022 to ES2024
  • Add Resizable/Transfer ArrayBuffer types to ES2024

Fix some types

  • Fix ArrayBuffer.prototype.slice types in ES5
  • Fix SharedArrayBuffer.prototype.slice types in ES2017
  • Add empty arguments of ArrayBuffer/SharedArrayBuffer constructor types to ES2017

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label May 19, 2024
@petamoriken petamoriken changed the title fix(dts): Update ES2017 and ES2024 types fix(dts): Update ES5, ES2017 and ES2024 types May 19, 2024
@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary.

@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@petamoriken petamoriken changed the title fix(dts): Update ES5, ES2017 and ES2024 types Fix ES5, ES2017 types and introduce ES2024 types and target May 19, 2024
@petamoriken
Copy link
Contributor Author

It is strange that ES2024 Atomics.waitAsync is defined in es2022.sharedmemory.d.ts, but probably cannot be fixed.

@petamoriken petamoriken changed the title Fix ES5, ES2017 types and introduce ES2024 types and target Introduce ES2024 types, target and fix ES5, ES2017 types May 20, 2024
@jakebailey
Copy link
Member

If it was a mistake, I don't think we'd be against fixing it. If you make that change, we can run the extended tests and see how bad it would be.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 23, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 23, 2024

Hey @rbuckton, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/162976/artifacts?artifactName=tgz&fileId=9B134F6B73EF0334DC56B90577381A1DBB6A4FF614ECEFC5830AD3185B92A0C602&fileName=/typescript-5.6.0-insiders.20240723.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.6.0-pr-58573-19".;

@rbuckton
Copy link
Member

For the failing tests in top 400:

  • majodev/google-webfonts-helper - In jszip, the InputFileFormat type only includes ArrayBuffer and not SharedArrayBuffer (or ArrayBufferLike), so either majodev/google-webfonts-helper needs to assert the buffer is an ArrayBuffer or jszip needs to be updated to allow SharedArrayBuffer. This error seems correct as we can only assume jszip did not expect SharedArrayBuffer inputs.

  • mapbox/mapbox-gl-js, pixijs - It looks like the errors are expected as ArrayBuffer and SharedArrayBuffer now actually have divergent interfaces due to resizable/growable array buffers.

  • spacedriveapp/spacedrive - The error comes from ArrayBuffer now differing sufficiently from Buffer. It looks like archive-wasm indicates that extractTo only accepts ArrayBufferLike, though if you follow the argument through it should probably also accept Uint8Array.

  • wandb/openui

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
@rbuckton
Copy link
Member

The only other change I see we need to make here is a small nit in the test comment. The fix for SubtleCrypto will likely need an update to https://github.com/microsoft/TypeScript-DOM-lib-generator, however.

@rbuckton
Copy link
Member

The second error indicates a typo in the DOM types for crypto.subtle.verify in that BufferSource should also include SharedArrayBuffer, per:

Correction, verify is correctly typed, but runs afoul of every typed array having a .buffer that is potentially a SharedArrayBuffer.

@petamoriken
Copy link
Contributor Author

@guest271314 This PR has not yet been merged so probably is not available yet.

@rbuckton
Copy link
Member

I'd hoped to get this in before the 5.6 beta cutoff, but it looks like there are some long-term concerns related to ArrayBufferLike and typed arrays we may need to address before this can go in.

@guest271314
Copy link

This PR has not yet been merged so probably is not available yet.

I should be able to fork your code, build tsc and go on about my business, without waiting for an official merge in this repository, correct?

@DanielRosenwasser
Copy link
Member

Yes, you can just use the following in your package.json for a mostly-up-to-date version of the PR.

{
  "devDependencies": {
    "typescript": "npm:@typescript-deploys/pr-build@5.6.0-pr-58573-19"
  }
}

@guest271314
Copy link

@DanielRosenwasser

bun install npm:@typescript-deploys/pr-build@5.6.0-pr-58573-19

without a package.json works, too.

Is there a "latest" or "nightly" URL?

@guest271314
Copy link

@DanielRosenwasser Got this working in Deno reading this https://docs.deno.com/runtime/manual/advanced/typescript/types/#using-ambient-or-global-types. Thanks.

nm_host.ts

#!/usr/bin/env -S /home/xubuntu/bin/deno run 
// https://www.codeconvert.ai/javascript-to-typescript-converter
// @ts-self-types="./lib.es2023.d.ts"
// @ts-self-types="./lib.es2024.arraybuffer.d.ts"

const runtime: string = navigator.userAgent;
const buffer: ArrayBuffer = new ArrayBuffer(0, { maxByteLength: 1024 ** 2 });

or path node_modules of this PR source

// Convert JavaScript to TypeScript, no obvious equivalent with tsc
// https://www.codeconvert.ai/javascript-to-typescript-converter
//
// @ts-self-types="./node_modules/@typescript-deploys/pr-build/lib/lib.es2023.d.ts"
// @ts-self-types="./node_modules/@typescript-deploys/pr-build/lib/lib.es2024.arraybuffer.d.ts"

const runtime: string = navigator.userAgent;
const buffer: ArrayBuffer = new ArrayBuffer(0, { maxByteLength: 1024 ** 2 });

src/lib/es2024.collection.d.ts Outdated Show resolved Hide resolved
src/lib/es2024.object.d.ts Outdated Show resolved Hide resolved
@petamoriken
Copy link
Contributor Author

Blocked by #59417

@rbuckton
Copy link
Member

What we might want to do is to extract the interface changes for ArrayBuffer and SharedArrayBuffer to an independent PR so that we can merge the rest of this sooner. We can then take the ArrayBuffer/SharedArrayBuffer changes once #59417 has merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on author
Development

Successfully merging this pull request may close these issues.

fix(dts): Update type of ArrayBuffer
9 participants