apache / apache/echarts

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

Open
#19,992 5 comments 8 reactions 0 assignees View on GitHub
bug en pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### 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:
```json
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true
},
"exclude": ["node_modules"]
}

```

main.mts :
```
Import {init} from "echarts/core";
```
2. 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](https://github.com/apache/echarts/assets/73151139/1b8534a1-da1f-4d4c-a5d8-17b63e7e054d)

### Expected Behavior

Setting module and moduleResolution to CommonJs and node respectively can work properly
```ts
{
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"strict": true
},
"exclude": ["node_modules"]
}

```
![image](https://github.com/apache/echarts/assets/73151139/920686ce-78e4-4470-9243-6225d0831202)

Can the NodeNext module for Typescript be supported?

### Environment

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

### Any additional comments?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.