react-component / react-component/tree

Getting TS Error 2604 with package.json type="module"

Open
#739 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.3k
Forks
490
Avg merge
3d 17h
Merged PRs (30d)
5

Description

My code is

import React from "react";
import Tree from "rc-tree";
export function S() {
    return <Tree>
    </Tree>
}

My package.json is

{
  "type": "module",
  "dependencies": {
    "@commander-js/extra-typings": "^10.0.3",
    "@types/react": "^18.2.5",
    "minimist2": "^1.0.2",
    "rc-tree": "^5.7.3",
    "react": "^18.2.0",
    "ts-command-line-args": "^2.5.0",
    "yargs": "^17.7.1"
  },
  "devDependencies": {
    "@types/node": "^18.15.11",
    "@types/yargs": "^17.0.24"
  }
}

I am getting a TS Error 2604, when I compile this. If I change type in package.json to "commonjs" or leave it out, the code compiles fine. How can I make it error free when using type="module" - which I need for other reasons.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the package.json shown in the issue and the minimal React component importing rc-tree. Reproduce the TS 2604 error with type="module", then compare it with the working commonjs or omitted setting. Done means the example compiles without the error while retaining type="module".

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.