GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JSX Fragments are in-properly typed when not using `React.Fragment` · Issue #50429 · microsoft/TypeScript

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

New issue
Copy link
New issue
Copy link
Closed
#59933
Closed
JSX Fragments are in-properly typed when not using React.Fragment#50429
#59933
Copy link
Assignees
iisaduan
Labels
BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone
Milestone
TypeScript 5.7.0

Description

@gkemp94
George Kemp (gkemp94)
opened on Aug 24, 2022
Issue body actions

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

Activity

  1. MartinJohns commented on Aug 24, 2022

    @MartinJohns
    Martin Johns (MartinJohns)
    on Aug 24, 2022
    Contributor
    More actions

    Playground link

  2. Ryan Cavanaugh (RyanCavanaugh)
    added
    BugA bug in TypeScript
    on Aug 26, 2022
  3. Ryan Cavanaugh (RyanCavanaugh)
    assigned
    navya9singh
    on Aug 26, 2022
  4. Ryan Cavanaugh (RyanCavanaugh)
    added this to the TypeScript 4.9.0 milestone on Aug 26, 2022
  5. Ryan Cavanaugh (RyanCavanaugh)
    assigned
    Isabel Duan (iisaduan)
    and unassigned
    navya9singh
    on Aug 26, 2022
  6. a-tarasyuk commented on Aug 29, 2022

    @a-tarasyuk
    Oleksandr Tarasiuk (a-tarasyuk)
    on Aug 29, 2022
    Contributor
    More actions

    Ryan Cavanaugh (@RyanCavanaugh) Should JsxOpeningFragment be part of CallLikeExpression?

    TypeScript/src/compiler/types.ts

    Lines 2802 to 2808 in ed6889c

    export type CallLikeExpression =
    | CallExpression
    | NewExpression
    | TaggedTemplateExpression
    | Decorator
    | JsxOpeningLikeElement
    ;

    It does not have tagName (which we use in JsxOpeningLikeElement to resolve call) and other common CallLikeExpression properties - attributes, typeArguments, etc.

    Or do we need to make a special kind of fragment factory (with a synthetic name) call resolving?

  7. DanielRosenwasser commented on Nov 2, 2022

    @DanielRosenwasser
    Daniel Rosenwasser (DanielRosenwasser)
    on Nov 2, 2022
    Member
    More actions

    It sounds like the answer is "yes it should be a call-like expression", but also you will need to virtualize a target. I don't know if we still do that, but we have helpers like getEffective____ for getting the arguments we should check against.

  8. Ryan Cavanaugh (RyanCavanaugh)
    added
    RescheduledThis issue was previously scheduled to an earlier milestone
    on Feb 1, 2023
  9. Ryan Cavanaugh (RyanCavanaugh)
    modified the milestones: TypeScript 4.9.0, TypeScript 5.1.0 on Feb 1, 2023
  10. Donny/강동윤 (kdy1)
    added a commit that references this issue on Apr 8, 2023

    feat: Use `any` for JSX fragments (#973)

    508b2ba
  11. merrywhether commented on Sep 12, 2023

    @merrywhether
    Risto Keravuori (merrywhether)
    on Sep 12, 2023
    More actions

    Could this be solved in a similar manner to #51328? Libraries/types could define something like JSX.FragmentType in addition to JSX.ElementType and have full control over their JSX.

  12. Ryan Cavanaugh (RyanCavanaugh)
    modified the milestones: TypeScript 5.1.0, TypeScript 5.5.0 on Mar 4, 2024
  13. Ryan Cavanaugh (RyanCavanaugh)
    modified the milestones: TypeScript 5.5.0, TypeScript 5.7.0 on Jul 26, 2024
  14. TypeScript Bot (typescript-bot)
    added
    Fix AvailableA PR has been opened for this issue
    on Sep 10, 2024
  15. Isabel Duan (iisaduan)
    closed this as completedin #59933on Sep 27, 2024
  16. microsoft
    locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @iisaduan
    Isabel Duan (iisaduan)

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

    Milestone

    • TypeScript 5.7.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.