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

TypeScript5.0+ moduleResolution bundler breaks types import #64

Open
jamessawyer opened this issue Jun 6, 2023 · 2 comments
Open

TypeScript5.0+ moduleResolution bundler breaks types import #64

jamessawyer opened this issue Jun 6, 2023 · 2 comments

Comments

@jamessawyer
Copy link

I created a new vue-ts project using pnpm create vite@latest my-app --template vue-ts, then I add pinia & pinia-plugin-persist deps。I set up typescript config by the doc, when i import pinia-plugin-persist, vscode will raise an error:

Could not find a delaration file for module pinia-plugin-persist.
There are types at '/xxx/my-app/node_modules/.pnpm/pinia-plugin-persist/dist/index.d.ts', but this result could not be resolved when respectiong package.json "exports". The 'pinia-plugin-persist' library may need to update its package.json or typings.

Here is my tsconfig.json file:

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,

    "types": ["pinia-plugin-persist"]
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

To fix this bug, I have to change the config:

--     "moduleResolution": "bundler",
++    "moduleResolution": "node",

Please support typescript 5.0+!

May be this link clarifies the problem more clean: Add the types condition to the package.json#exports

@Tricker39
Copy link

I encountered the same problem,then I use 'pinia-plugin-persistedstate' instead

@jamessawyer
Copy link
Author

I encountered the same problem,then I use 'pinia-plugin-persistedstate' instead

If I mitigate to 'pinia-plugin-persistedstate' lib, anything should pay attention to? @Tricker39

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