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

instructions for TSConfig adjustments don't seem to work #8

Open
achou11 opened this issue Sep 26, 2023 · 2 comments
Open

instructions for TSConfig adjustments don't seem to work #8

achou11 opened this issue Sep 26, 2023 · 2 comments

Comments

@achou11
Copy link
Member

achou11 commented Sep 26, 2023

Using Typescript v5.2.2

The instructions currently state that you have to update you tsconfig file as follows:

{
  "compilerOptions": {
+    "typeRoots": ["node_modules/@digidem/types/vendor", "node_modules/@types"]
  }
}

however, this seems to work:

{
  "compilerOptions": {
+    "paths": {
+      "*": ["./node_modules/@digidem/types/vendor/*/index.d.ts"]
+      }
  }
}

Example tsconfig I'm using:

{
  "compilerOptions": {
    "target": "es2022",
    "lib": [
      "es2023"
    ],
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "allowJs": true,
    "checkJs": true,
    "noEmit": true,
    "declaration": false,
    "typeRoots": [
      "node_modules/@types",
      "node_modules/@digidem/types/vendor",
    ]
  },
  "include": [
    "src/**/*",
    "tests/**/*"
  ],
  "exclude": [
    "node_modules",
  ]
}
@achou11
Copy link
Member Author

achou11 commented Oct 16, 2023

additional helpful info:

Could not find a declaration file for module 'random-access-memory'. '/Users/andrewchou/GitHub/digidem/comapeo-mobile/src/backend/node_modules/random-access-memory/index.js' implicitly has an 'any' type.

There are types at '/Users/andrewchou/GitHub/digidem/comapeo-mobile/src/backend/node_modules/@digidem/types/vendor/random-access-memory/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'random-access-memory' library may need to update its package.json or typings.ts(7016)

@achou11
Copy link
Member Author

achou11 commented Oct 16, 2023

seems like we should be using the exports field in package.json for pointing to the type defs

https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing

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

No branches or pull requests

1 participant