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

feat!: Port to TypeScript, closes #762 #763

Merged
merged 34 commits into from
Jul 16, 2024
Merged

feat!: Port to TypeScript, closes #762 #763

merged 34 commits into from
Jul 16, 2024

Conversation

broofa
Copy link
Member

@broofa broofa commented Jun 10, 2024

Switching the codebase to Typescript.

  • Move src/.js -> src/.ts
  • add type annotations throughout
  • Prefer Uint8Array for binary uuids throughout (BREAKING CHANGE)
  • Port unit tests to TS
  • Switch test runner from jest to node:test
  • Switch to tsc for generating buidls
  • Get all checks passing

Other notes:

  • Changes to src/*.js files should be limited to...
    • Adding type annotations
    • Switching to Uint8Array for binary UUIDs
  • The examples/node-jest test passes, but I don't see it being run as part of CI or npm test anywhere. I'm tempted to remove it. 🤔
  • Updated to eslint@latest, and switched config to ESM.
  • Updated to @wdio/*@latest
  • Switched prettier config to ESM
  • Added VSCode configuration. @ctavan, iirc you've objected to this in the past, but these are very helpful to me and to other vscode users that may want to contribute to this codebase. Specifically:
    • tasks.json starts the build:watch and test:watch scripts automatically when you open the project
    • extensions.json identifies the plugins that devs should use to apply our eslint and prettier settings while editing code
  • Sorted package.json#scripts alphabetically
    • Added build:watch and test:watch scripts, which I'm using in vscode
  • Unit tests have been ported to TS, but should be functionally identical.
  • Tests and CI are run using the dist/esm directory (unless they're explicitely testing other dist/* builds.
  • build.sh now builds ESM and CJS versions of code using tsc rather than babel.
    • The top-level dist/*.js files can now be found in dist/esm, alongside the other builds (esm-browser, cjs, and cjs-browser)
  • Switched to using Uint8Array for binary (byte) UUID data structures throughout. The one exception is the return type for md5 and sha1 on node, which is still Buffer (but that's a subclass of Uint8Array these days anyways so... 🤷)

@broofa broofa linked an issue Jun 10, 2024 that may be closed by this pull request
@uuidjs uuidjs deleted a comment from Young8881 Jun 28, 2024
@broofa broofa marked this pull request as ready for review June 30, 2024 14:58
@broofa
Copy link
Member Author

broofa commented Jun 30, 2024

@LinusU @pmccarren I would particularly appreciate a review of the TS types I've added, particularly with regard to API surface where I've used overload signatures to capture the different method incantations.

@ctavan et al: Thoughts on release process? I know we just pushed v10, so pushing a v11 this soon after feels a bit... sudden? We could do a prerelease ("11.0.0-beta") and dist tag as npm dist-tag add 11.0.0-beta beta, I suppose.

@broofa broofa linked an issue Jul 2, 2024 that may be closed by this pull request
@broofa
Copy link
Member Author

broofa commented Jul 2, 2024

@joshkel As the most recent contributor to @types/uuid, I'd certainly appreciate any feedback you have on this.

@broofa
Copy link
Member Author

broofa commented Jul 11, 2024

Final call. Merging this by week's end unless someone objects.

@ctavan @LinusU @pmccarren @joshkel

@broofa broofa merged commit 1e0f987 into main Jul 16, 2024
12 checks passed
@broofa broofa deleted the ts_port branch July 17, 2024 13:14
molaeiali added a commit to molaeiali/uuid that referenced this pull request Aug 5, 2024
broofa pushed a commit that referenced this pull request Aug 7, 2024
…D from being used (#786)

* fix: remove options default assignment introduced during porting to ts, pull #763 preventing native.randomUUID being used

* test: add unit test to check if native randomUUID should be used or not
@veksa veksa mentioned this pull request Oct 29, 2024
2 tasks
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.

Port codebase to TypeScript Make Uint8Array the one and only type used for binary (byte) uuid values
2 participants