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

perspective-viewer-datagrid and perspective-viewer-d3fc have invalid typescript exports #2863

Closed
arslan-charyyev opened this issue Dec 1, 2024 · 1 comment

Comments

@arslan-charyyev
Copy link

arslan-charyyev commented Dec 1, 2024

Bug Report

Perspective version: 3.1.7 (older versions are likely to be affected as well)

Steps to Reproduce:

  1. Add "@finos/perspective-viewer-d3fc": "^3.1.7" and "@finos/perspective-viewer-datagrid": "^3.1.7" to your package.json dependencies
  2. Try to import them in any typescript file

Expected Result:

No import errors

Actual Result:

perspective-viewer-datagrid

In the case of @finos/perspective-viewer-datagrid the following error:

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

My suggestion - amend the package.json "exports" in the following manner that is consistent with base @finos/perspective package:

"exports": {
    ".": {
      "types": "./index.d.ts",
      "default": "./dist/esm/perspective-viewer-datagrid.js"
    },
    "./dist/*": "./dist/*",
    "./package.json": "./package.json"
  },

This change fixes the error in my local environment.

perspective-viewer-d3fc

In the case of @finos/perspective-viewer-d3fc the following error:

TS7016: Could not find a declaration file for module '@finos/perspective-viewer-d3fc'. '/project/node_modules/@finos/perspective-viewer-d3fc/dist/esm/perspective-viewer-d3fc.js' implicitly has an 'any' type.
Try npm i --save-dev @types/finos__perspective-viewer-d3fc if it exists or add a new declaration (.d.ts) file containing declare module '@finos/perspective-viewer-d3fc';

My suggestion is the same - amend the package.json "exports" in the following manner:

"exports": {
    ".": {
      "types": "./dist/esm/types.d.ts", // or perhaps "./dist/esm/index.d.ts"? Idk, just guessing
      "default": "./dist/esm/perspective-viewer-d3fc.js"
    },
    ...

This change fixes the error in my local environment as well.

Environment:

Node: v23.1.0
OS: Manjaro Linux rolling

Additional Context:

  • package manager: npm
  • vite: v6
@timkpaine
Copy link
Member

dupe: #2824

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

2 participants