Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if outdated JSX transform is detected #28781

Merged
merged 1 commit into from
Apr 9, 2024

Commits on Apr 9, 2024

  1. Warn if outdated JSX transform is detected

    We want to warn if we detect that an app is using an outdated JSX
    transform. We can't just warn if `createElement` is called because we
    still support `createElement` when it's called manually. We only want
    to warn if `createElement` is output by the compiler.
    
    The heuristic is to check for a `__self` prop, which is an optional,
    internal prop that older transforms used to pass to `createElement` for
    better debugging in development mode.
    
    If `__self` is present, we `console.warn` once with advice to upgrade
    to the modern JSX transform. Subsequent elements will not warn.
    
    There's a special case we have to account for: when a static "key" prop
    is defined _after_ a spread, the modern JSX transform outputs
    `createElement` instead of `jsx`. (This is because with `jsx`, a spread
    key always takes precedence over a static key, regardless of the order,
    whereas `createElement` respects the order.) To avoid a false positive
    warning, we skip the warning whenever a `key` prop is present.
    acdlite committed Apr 9, 2024
    Configuration menu
    Copy the full SHA
    ec134f7 View commit details
    Browse the repository at this point in the history