Skip to content

JSX Fragments are in-properly typed when not using React.FragmentΒ #50429

Closed
@gkemp94

Description

@gkemp94

Bug Report

πŸ”Ž Search Terms

React Fragment

πŸ•— Version & Regression Information

I believe this is a new inconsistency due to changes in React.

⏯ Playground Link

https://github.com/gkemp94/test-typescript-fragment

Code

import React from "react";

const test = () => "asd";

// No Errors
const jsxWithJsxFragment = <>{test}</>;

// Type '() => string' is not assignable to type 'ReactNode'.
const jsxWithReactFragment = <React.Fragment>{test}</React.Fragment>;

πŸ™ Actual behavior

When using <> vs <React.Fragment> the children are not properly type checked

πŸ™‚ Expected behavior

When jsx: react is specified, to type check <> the same as React.Fragment

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions