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

[Bug] Typescript setting module to "NodeNext" cannot obtain type prompt #19992

Open
eavidy opened this issue May 31, 2024 · 1 comment
Open
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.

Comments

@eavidy
Copy link

eavidy commented May 31, 2024

Version

5.5.0

Link to Minimal Reproduction

https://github.com/eavidy/test_case/tree/echart-1

Steps to Reproduce

  1. Clone Repository git clone -b echart-1 git@github.com:eavidy/test_case.git
    This example mainly includes two files
    tsconfig.json:
{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true
  },
  "exclude": ["node_modules"]
}

main.mts :

Import {init} from "echarts/core";
  1. Execute commands in the project directory
    npm install
    tsc --noEmit

Current Behavior

tsc --noEmit output:

main.mts:1:10 - error TS2305: Module '"echarts/core"' has no exported member 'init'.

1 import { init } from "echarts/core";
           ~~~~

node_modules/echarts/core.d.ts:20:15 - error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

20 export * from './types/dist/core';
                 ~~~~~~~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  main.mts:1
     1  node_modules/echarts/core.d.ts:20

vscode:
image

Expected Behavior

Setting module and moduleResolution to CommonJs and node respectively can work properly

{
  "compilerOptions": {
    "module": "CommonJS",
    "moduleResolution": "Node",
    "strict": true
  },
  "exclude": ["node_modules"]
}

image

Can the NodeNext module for Typescript be supported?

Environment

- OS: Mac OS
- Browser:
- Framework:
- typescript: 5.4.5

Any additional comments?

No response

@eavidy eavidy added the bug label May 31, 2024
@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels May 31, 2024
@echarts-bot echarts-bot bot changed the title [Bug] Typescript setting module to "NodeNext" cannot obtain type prompt [Bug] Typescript setting module to "NodeNext" cannot obtain type prompt May 31, 2024
@BTMuli
Copy link

BTMuli commented Oct 25, 2024

Facing new problem.

To solve type err I try to use import xx from "echarts/types/xx.js",however it throw Failed to resolve import "echarts/types/xx.js"

And to solve the exist file,use import xx from "echarts/xx" throw "Module 'echarts/xx' has no exported member xx".

Is there any workaround for nodenext?😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.
Projects
None yet
Development

No branches or pull requests

2 participants