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

Could not find a declaration file for module #876

Open
jayeshbhole opened this issue Jun 21, 2024 · 3 comments
Open

Could not find a declaration file for module #876

jayeshbhole opened this issue Jun 21, 2024 · 3 comments
Assignees

Comments

@jayeshbhole
Copy link

Describe the bug
Hey. I am working on a simple setup to write a package. After importing @solana-mobile/wallet-adapter-mobile the following error is thrown while building the project

Could not find a declaration file for module '@solana-mobile/wallet-adapter-mobile'. '/Users/.../Documents/GitHub/Work/solana-react/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_utf-8-vali_zmsbdydrbudvytyku74jwk3dfa/node_modules/@solana-mobile/wallet-adapter-mobile/lib/esm/index.js' implicitly has an 'any' type.
  There are types at '/Users/.../Documents/GitHub/Work/solana-react/node_modules/@solana-mobile/wallet-adapter-mobile/lib/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@solana-mobile/wallet-adapter-mobile' library may need to update its package.json or typings.ts(7016)

To Reproduce
Steps to reproduce the behavior:

  1. Setup a bare react project with pnpm v9.4.0 and node v20.15.0. I'm using the following configs:
.eslintrc.cjs
-------------

module.exports = {
  root: true,
  env: { browser: true, es2020: true },
  extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
  ignorePatterns: ['dist', '.eslintrc.cjs'],
  parser: '@typescript-eslint/parser',
  plugins: ['react-refresh'],
  rules: {
    'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
    '@typescript-eslint/no-explicit-any': 'warn',
  },
};
tsconfig.json
-------------

{
  "compilerOptions": {
    "composite": true,
    "declaration": true,
    "noEmit": false,
    "sourceMap": true,
    "outDir": "dist/_esm",
    "rootDir": "./src",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "allowJs": false,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": false,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "noFallthroughCasesInSwitch": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "ES2020"
  },
  "include": ["./src/**/*", "./src/**/*.json"],
  "exclude": ["**/.*/", "**/build", "**/dist", "node_modules", ".yarn"]
}
package.json
------------

{
  "name": "...",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "watch": "tsc -w -p ./tsconfig.json",
    "build": "tsc --build"
  },
  "dependencies": {
    "@solana-mobile/wallet-adapter-mobile": "^2.1.3",
    "@solana/wallet-adapter-base": "^0.9.23",
    "@solana/wallet-standard-wallet-adapter-react": "^1.1.2",
    "@solana/web3.js": "^1.91.2",
    "@tanstack/react-query": "^5.44.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "zustand": "^4.5.2"
  },
  "devDependencies": {
    "@types/react": "^18.2.66",
    "@types/react-dom": "^18.2.22",
    "@typescript-eslint/eslint-plugin": "^7.2.0",
    "@typescript-eslint/parser": "^7.2.0",
    "eslint": "^8.57.0",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.6",
    "prettier-plugin-organize-imports": "^3.2.4",
    "typescript": "^5.2.2"
  },
  "peerDependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}
  1. Import a few things from the package.
import {
  createDefaultAddressSelector,
  createDefaultAuthorizationResultCache,
  createDefaultWalletNotFoundHandler,
  SolanaMobileWalletAdapter,
  SolanaMobileWalletAdapterWalletName,
} from '@solana-mobile/wallet-adapter-mobile';
  1. Run pnpm build.

Environment:

  • pnpm: v9.4.0
  • node: v20.15.0
@sdlaver
Copy link
Contributor

sdlaver commented Jun 21, 2024

@Funkatronics would you mind taking a look at this?

@ryoid
Copy link
Contributor

ryoid commented Jun 29, 2024

Might be related to #841, you can try to patch the package.json locally while waiting for npm release.

@jayeshbhole
Copy link
Author

Gotcha, thanks. This works for now

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

4 participants