Giter Club home page Giter Club logo

Comments (9)

MasterKale avatar MasterKale commented on May 23, 2024 1

I created kriszyp/cbor-x#100 over in the cbor-x project because I discovered that locally duplicating their index.d.ts as index-no-eval.d.ts in my example project here's node_modules/cbor-x/ folder allowed tsc to understand types for cbor-x/index-no-eval. However I couldn't think of anything clever to do on the SimpleWebAuthn side of the house to get TypeScript to "alias" the index.d.ts type declarations for cbor-x/index-no-eval imports...

from simplewebauthn.

MasterKale avatar MasterKale commented on May 23, 2024 1

Okay, enough people are affected by this I think I'll have to revert #511 and figure something else out. The cbor-x project looks like it's being actively maintained, but there's evidence they may not have a lot of time to dedicate to addressing issues. I'll have to break Vercel's Edge runtime support for sake of restoring Node support, but my gut tells me there are more people in the latter group than the former.

from simplewebauthn.

MasterKale avatar MasterKale commented on May 23, 2024

Hello @mat813, thanks for the report. This is related to #511, weird that an issue like this wasn't caught locally or in CI. I'll dig into this and report back.

Can you share your project's tsconfig.json?

from simplewebauthn.

sualko avatar sualko commented on May 23, 2024

I have the same issue.

{
  "ts-node": {
    "files": true
  },
  "compilerOptions": {
    "module": "commonjs",
    "strict": true,
    "strictPropertyInitialization": false,
    "noImplicitOverride": true,
    "declaration": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "target": "es6",
    "lib": ["dom", "dom.iterable", "esnext"],
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "exclude": ["node_modules", "dist", "tmp"],
  "include": ["src", "test"]
}

Not sure if this is related, but for some reason the default export no longer works for me. Instead of

import SimpleWebAuthnServer from '@simplewebauthn/server';

I have to use

import * as SimpleWebAuthnServer from '@simplewebauthn/server';

We are running Typescript in version 5.3.3.

I removed the node_modules folder and installed all dependencies again, but the package doesn't seam to be installed.

$ npm why cbor-x/index-no-eval
npm ERR! No dependencies found matching cbor-x/index-no-eval

from simplewebauthn.

mat813 avatar mat813 commented on May 23, 2024

Here is my tsconfig.json :

{
  "compilerOptions": {
    "target": "es2021",
    "module": "commonjs",
    "esModuleInterop": true,
    "noImplicitAny": true,
    "outDir": "./built",
    "sourceMap": true,
    "inlineSources": true,
    "sourceRoot": "/",
    "noEmitHelpers": true,
    "importHelpers": true,
    "resolveJsonModule": true,
    "strictBindCallApply": true,
    "strictFunctionTypes": true,
    "strictNullChecks": true
  },
  "types": ["jest", "jest-extended"],
  "exclude": ["node_modules"],
  "include": [
    "apps/**/*.ts",
    "graphql/**/*.ts",
    "graphql/*.d.ts",
    "mailers/**/*.ts",
    "scripts/**/*.ts",
    "ecosystem.json"
  ]
}

This still happens with @simplewebauthn/[email protected] and @simplewebauthn/[email protected].

from simplewebauthn.

spendres avatar spendres commented on May 23, 2024

Isn't @simplewebauthn/* installed in node_modules?
You may need to include "node_modules/@simplewebauthn/**/*.ts" since you excluded all of node_modules.

from simplewebauthn.

MasterKale avatar MasterKale commented on May 23, 2024

Good eye @spendres, I'll bet that's it. cbor-x/no-index-eval is defined in the dependency's package.json here:

https://github.com/kriszyp/cbor-x/blob/0b5e8807622619c6a7a062f7e771478ecfd52f83/package.json#L59

If TypeScript can't see any types in node_modules/ (as evident in both tsconfig.json samples pasted above) I'm not surprised it's having issues transpiling.

My suggestion to fix that tsc error is to move "node_modules" from "exclude" to "include" instead and try again.

No, wait a minute, it's not that - exclude is about what gets transpiled. I get this same issue with the example project once I install @simplewebauthn/types (oops, gotta fix that) and then run npx tsc in there.

Investigating...

from simplewebauthn.

MasterKale avatar MasterKale commented on May 23, 2024

I'm proposing fixing this issue by replacing use of cbor-x another library, tiny-cbor. @mat813 @sualko @mmv08 if you're feeling daring enough you can trying building and installing from the fix/513-cbor-x-type-issues branch to see if this fixes your issues. In my testing I think this is the solution, but extra confirmation couldn't hurt.

from simplewebauthn.

MasterKale avatar MasterKale commented on May 23, 2024

@mat813 @sualko @mmv08 This issue should be fixed in the newly published @simplewebauthn/[email protected]

from simplewebauthn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.