Skip to content

Fix type definitions with moduleResolutions nodenext #2213

Open
@ZachHaber

Description

@ZachHaber

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Typescript with nodenext resolution ignores the "typings" property completely when "exports" is specified, which causes typescript to complain that it can't find any type definitions for this package.

microsoft/TypeScript#49160 (comment)

This should work fine on both v3 and v4, since both have the same issue with typescript and the exports object.

Here is the diff that solved my problem:

diff --git a/node_modules/vuex/package.json b/node_modules/vuex/package.json
index e8a851e..4cd1fce 100644
--- a/node_modules/vuex/package.json
+++ b/node_modules/vuex/package.json
@@ -7,7 +7,8 @@
     ".": {
       "module": "./dist/vuex.esm.js",
       "require": "./dist/vuex.common.js",
-      "import": "./dist/vuex.mjs"
+      "import": "./dist/vuex.mjs",
+      "types": "./types/index.d.ts"
     },
     "./": "./"
   },

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions