Skip to content

Typescript Import issue with NodeNext #1327

Open
@aphex

Description

@aphex

Reporting a bug?

When setting "moduleResolution": "NodeNext", in tsconfig.json and trying to use this package will result in a error in VSCode Could not find a declaration file for module 'vue-i18n'. However everything runs fine, I think this has to do with how exports are being interpreted

Changing the package.json exports to look like this seems to resolve the issue. Just adding types here as well. Is this a change that would be acceptable?

"exports": {
    ".": {
      "import": {
        "node": "./index.mjs",
        "default": "./dist/vue-i18n.esm-bundler.js"
      },
      "require": "./index.js",
      "types": "./dist/vue-i18n.d.ts"
    },
    "./dist/*": "./dist/*",
    "./index.mjs": "./index.mjs",
    "./package.json": "./package.json"
  },

Expected behavior

Package should not show dev time TS errors when using NodeNext moduleResolution

Reproduction

Quickest reproduction is to just create a TS vue app using Vite, and add vue-i8n to the project and update the tsconfig.json with "moduleResolution": "NodeNext",

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 25.84 GB / 31.31 GB
    Container: Yes
    Shell: 3.2.2 - /usr/bin/fish
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.1.3 - ~/.nvm/versions/node/v16.17.0/bin/npm
  Browsers:
    Chrome: 102.0.5005.61
  npmPackages:
    @intlify/unplugin-vue-i18n: ^0.8.1 => 0.8.1
    @vitejs/plugin-vue: ^4.0.0 => 4.0.0
    vite: ^4.1.1 => 4.1.1
    vue: ^3.2.47 => 3.2.47
    vue-i18n: ^9.2.2 => 9.2.2
    vue-router: ^4.1.6 => 4.1.6
    vue-tsc: ^1.0.24 => 1.0.24

Screenshot

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions