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

react.dev: Compat with React 19 types #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"@types/mdx-js__react": "^1.5.2",
"@types/node": "^14.6.4",
"@types/parse-numeric-range": "^0.0.1",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"@types/react": "npm:types-react@19.0.0",
"@types/react-dom": "npm:types-react-dom@19.0.0",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"asyncro": "^3.0.0",
Expand Down Expand Up @@ -96,6 +96,11 @@
"unist-util-visit": "^2.0.3",
"webpack-bundle-analyzer": "^4.5.0"
},
"resolutions": {
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]",
"@types/react-is": "npm:[email protected]"
},
"engines": {
"node": "^16.8.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {JSX} from 'react';
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconArrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';
import cn from 'classnames';

export const IconArrow = memo<
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconArrowSmall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';
import cn from 'classnames';

export const IconArrowSmall = memo<
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconCanary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconCanary = memo<JSX.IntrinsicElements['svg'] & {title?: string}>(
function IconCanary({className, title}) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconChevron.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';
import cn from 'classnames';

export const IconChevron = memo<
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconClose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconClose = memo<JSX.IntrinsicElements['svg']>(function IconClose(
props
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconCodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconCodeBlock = memo<JSX.IntrinsicElements['svg']>(
function IconCodeBlock({className}) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconCopy = memo<JSX.IntrinsicElements['svg']>(function IconCopy({
className,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconDeepDive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconDeepDive = memo<JSX.IntrinsicElements['svg']>(
function IconDeepDive({className}) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconDownload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconDownload = memo<JSX.IntrinsicElements['svg']>(
function IconDownload({className}) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconError = memo<JSX.IntrinsicElements['svg']>(function IconError({
className,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconFacebookCircle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconFacebookCircle = memo<JSX.IntrinsicElements['svg']>(
function IconFacebookCircle(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconGitHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconGitHub = memo<JSX.IntrinsicElements['svg']>(
function IconGitHub(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconHamburger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconHamburger = memo<JSX.IntrinsicElements['svg']>(
function IconHamburger(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconHint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';
import cn from 'classnames';

export const IconHint = memo<JSX.IntrinsicElements['svg']>(function IconHint({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconInstagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconInstagram = memo<JSX.IntrinsicElements['svg']>(
function IconInstagram(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconLink = memo<JSX.IntrinsicElements['svg']>(function IconLink(
props
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconNavArrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';
import cn from 'classnames';

export const IconNavArrow = memo<
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconNewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconNewPage = memo<JSX.IntrinsicElements['svg']>(
function IconNewPage(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconNote = memo<JSX.IntrinsicElements['svg']>(function IconNote({
className,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconPitfall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconPitfall = memo<JSX.IntrinsicElements['svg']>(
function IconPitfall({className}) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconRestart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconRestart = memo<JSX.IntrinsicElements['svg']>(
function IconRestart({className}) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconRss.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconRss = memo<JSX.IntrinsicElements['svg']>(function IconRss(
props
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconSearch = memo<JSX.IntrinsicElements['svg']>(
function IconSearch(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconSolution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';
import cn from 'classnames';

export const IconSolution = memo<JSX.IntrinsicElements['svg']>(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconTerminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconTerminal = memo<JSX.IntrinsicElements['svg']>(
function IconTerminal({className}) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconThreads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconThreads = memo<JSX.IntrinsicElements['svg']>(
function IconThreads(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconTwitter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconTwitter = memo<JSX.IntrinsicElements['svg']>(
function IconTwitter(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/IconWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {memo} from 'react';
import {memo, type JSX} from 'react';

export const IconWarning = memo<JSX.IntrinsicElements['svg']>(
function IconWarning({className}) {
Expand Down
1 change: 1 addition & 0 deletions src/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {JSX} from 'react';
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Challenges/Challenges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface ChallengeContents {
}

const parseChallengeContents = (
children: React.ReactElement[]
children: React.ReactElement<any>[]
): ChallengeContents[] => {
const contents: ChallengeContents[] = [];

Expand Down
4 changes: 2 additions & 2 deletions src/components/MDX/CodeBlock/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function getSyntaxHighlight(theme: any): HighlightStyle {

function getLineDecorators(
code: string,
meta: string
meta: string | undefined
): Array<{
line: number;
className: string;
Expand All @@ -309,7 +309,7 @@ function getLineDecorators(

function getInlineDecorators(
code: string,
meta: string
meta: string | undefined
): Array<{
step: number;
line: number;
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/ConsoleBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
if (typeof children === 'string') {
message = children;
} else if (isValidElement(children)) {
message = children.props.children;
message = (children as React.ReactElement<any>).props.children;
}

return (
Expand Down
2 changes: 2 additions & 0 deletions src/components/MDX/InlineCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import cn from 'classnames';

import type {JSX} from 'react';

interface InlineCodeProps {
isLink?: boolean;
meta?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {Children, useContext, useMemo} from 'react';
import {Children, useContext, useMemo, type JSX} from 'react';
import * as React from 'react';
import cn from 'classnames';

Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Sandpack/LoadingOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useState} from 'react';
import {useState, type JSX} from 'react';

import {
LoadingOverlayState,
Expand Down
5 changes: 4 additions & 1 deletion src/components/MDX/Sandpack/createFileMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export const SUPPORTED_FILES = [AppJSPath, StylesCSSPath];

export const createFileMap = (codeSnippets: any) => {
return codeSnippets.reduce(
(result: Record<string, SandpackFile>, codeSnippet: React.ReactElement) => {
(
result: Record<string, SandpackFile>,
codeSnippet: React.ReactElement<any>
) => {
if (
(codeSnippet.type as any).mdxName !== 'pre' &&
codeSnippet.type !== 'pre'
Expand Down
4 changes: 2 additions & 2 deletions src/components/MDX/TerminalBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function TerminalBlock({level = 'info', children}: TerminalBlockProps) {
message = children;
} else if (
isValidElement(children) &&
typeof children.props.children === 'string'
typeof (children.props as any).children === 'string'
) {
message = children.props.children;
message = (children.props as any).children;
} else {
throw Error('Expected TerminalBlock children to be a plain string.');
}
Expand Down
5 changes: 0 additions & 5 deletions src/utils/forwardRefWithAs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ export interface ComponentWithAs<ComponentType extends As, ComponentProps> {
): React.ReactElement | null;

displayName?: string;
propTypes?: React.WeakValidationMap<
PropsWithAs<ComponentType, ComponentProps>
>;
contextTypes?: React.ValidationMap<any>;
defaultProps?: Partial<PropsWithAs<ComponentType, ComponentProps>>;
}

/**
Expand Down
Loading
Loading