MasterKale / SimpleWebAuthn

WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more.
https://simplewebauthn.dev
MIT License
1.62k stars 137 forks source link

Typescript types not working with `moduleResolution`: `nodenext` #394

Closed kansson closed 1 year ago

kansson commented 1 year ago

Describe the issue

No types are recognized when importing any functions from either the server or client packages when moduleResolution is set to nodenext in tsconfig.json. Installing the separate types package does not solve the issue.

Reproduction Steps

  1. Create new typescript project
  2. Set moduleResolution to nodenext
  3. Install server and browser packages
  4. Import any function and see no types

Expected behavior

The types should be recognized as expected with this setting.

Dependencies

SimpleWebAuthn Libraries

Using the latest version of both packages.

Additional context

Not sure why this is happening, tried looking into it but couldn't figure it out. Some info of the setting: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#esm-nodejs

MasterKale commented 1 year ago

I'm pretty sure this is an ESM environment issue. Right now only CommonJS (read: Node) runtimes are officially supported by @simplewebauthn/server.

That said #338 has been tracking my efforts to add support for use of SimpleWebAuthn in ESM environments. There's no ETA right now as I work on that particular problem when I have time.

kansson commented 1 year ago

I'm pretty sure this is an ESM environment issue. Right now only CommonJS (read: Node) runtimes are officially supported by @simplewebauthn/server.

That said #338 has been tracking my efforts to add support for use of SimpleWebAuthn in ESM environments. There's no ETA right now as I work on that particular problem when I have time.

Understood! The server package does work in edge environments like Cloudflare Workers. Probably due to the new Node compatibility mode https://blog.cloudflare.com/workers-node-js-asynclocalstorage. Reverted moduleResolution: nodenext until the ESM support has fully landed. Feel free to close this in favour of #338.

MasterKale commented 1 year ago

As acknowledged, closing as a dupe of #338 ✌️