Skip to content

TS2604 and TS2786 for "rc-field-form" under moduleResolution node16 and package.json#type = "module" #56935

Closed
@thynson

Description

@thynson

🔎 Search Terms

moduleResolution node16, "rc-field-form"

🕗 Version & Regression Information

When trying to upgrading to latest typescript, due to #54567, the moduleResolution has to be changed to "moduleResolution": "node16", but blocked by the bug that "rc-field-form" does not work under "moduleResolution": "node16" and package.json#type = "module", while it's accepted under "moduleResolution": "node" prior to Typescript 5.1

⏯ Playground Link

No response

💻 Code

The following code compiles under "moduleResolution": "node" but rejected under "moduleResolution": "node16".

import React from 'react';
import RcForm from 'rc-field-form';

export default function () {
	const [form] = RcForm.useForm();

	return <RcForm form={form}>
		</RcForm>;
}

with tsconfig:

{
	"compilerOptions": {
		"module": "node16",
		"moduleResolution": "node16",
		"esModuleInterop": true,
		"target": "es2022",
		"lib":["es2022"],
		"jsx":"react"
	},
	"includes": [
		"src/**/*.ts",
		"src/**/*.tsx"
	]
}

and package.json:

{
  "name": "module-resolution-node16",
  "type":"module",
  "main": "index.js",
  "devDependencies": {
    "typescript": "^5.3.3"
  },
  "dependencies": {
    "@types/react": "^18.2.46",
    "@types/react-dom": "^18.2.18",
    "rc-field-form": "^1.41.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}

🙁 Actual behavior

src/index.tsx:7:10 - error TS2604: JSX element type 'RcForm' does not have any construct or call signatures.

7  return <RcForm form={form}>
           ~~~~~~

src/index.tsx:7:10 - error TS2786: 'RcForm' cannot be used as a JSX component.
  Its type 'typeof import("/path/to/node_modules/rc-field-form/es/index")' is not a valid JSX element type.

7  return <RcForm form={form}>
           ~~~~~~


Found 2 errors in the same file, starting at: src/index.tsx:7

🙂 Expected behavior

It's expected to be accepted by tsc.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions