js icon indicating copy to clipboard operation
js copied to clipboard

Update typing for node ESM

Open nathandem opened this issue 1 year ago • 0 comments

I added @metaplex-foundation/js to my project, I'm seeing the following error in Visual Studio Code.

Could not find a declaration file for module '@metaplex-foundation/js'. '/Users/XXX/project/node_modules/@metaplex-foundation/js/dist/esm/index.mjs' implicitly has an 'any' type.
  There are types at '/Users/XXX/project/node_modules/@metaplex-foundation/js/dist/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@metaplex-foundation/js' library may need to update its package.json or typings.

I could fix this by doing some tweaks in tsconfig.json but would be better if it works well out of the box.

Here's my tsconfig.json:

{
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
  "compilerOptions": {
    // key target params
    "target": "ES2020",
    "module": "node16",
    "moduleResolution": "node16",
    // conf
    "strict": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "forceConsistentCasingInFileNames": true,
    // output dir
    "outDir": "dist"
  },
  "ts-node": {
    "esm": true
  }
}

nathandem avatar Apr 28 '23 07:04 nathandem