XenonStack

XenonStack Insights React PropTypes and TypeScript: Typechecking in React 19

and | Published | Updated

React PropTypes to TypeScript: stack from React 19 ignoring propTypes, codemod migration and TypeScript interfaces to typed props in the build

Key takeaway

  • React 19 no longer checks propTypes. Learn what PropTypes did, what changed, and how to move to TypeScript with the official codemod and typed props.

What is typechecking in React, and does PropTypes still work?

Typechecking means catching a wrong kind of value, such as a string where a number is expected, before it reaches your users. In React, props are the values a parent passes to a child component, so a wrong prop type is one of the most common sources of silent bugs. For years the built-in answer was propTypes. That answer has changed: React 19 no longer checks propTypes, and the React team recommends migrating to TypeScript or another type-checking solution.

This guide explains what PropTypes did, why it was useful, what React 19 changed, and how to move to TypeScript. If your team is on React 18 or earlier, PropTypes still behaves as described below, so you can read it as a reference for existing code. For the wider testing picture, see our guide to API testing workflow, tools and best practices.

What is PropTypes?

PropTypes is a small library that lets a component declare the type of each prop it expects. When a component receives a value of the wrong type, a warning appears in the browser console. It was originally exposed as part of the React core module, and it is now published as the separate prop-types package, which its README says is compatible with React 15.3.0 and higher.

To use it, install the package and import it:

npm install --save prop-types

import PropTypes from 'prop-types';

function Profile({ name, age }) {
  return <p>{name}, {age}</p>;
}

Profile.propTypes = {
  name: PropTypes.string.isRequired,
  age: PropTypes.number,
};

Each key is a prop name and each value is a validator such as PropTypes.string, PropTypes.number or PropTypes.bool. Adding .isRequired makes the warning fire when the prop is missing.

Why did teams use PropTypes?

  • It checks values at runtime, while the application is running, so it can catch data that arrives from outside your code.
  • It needed no build step or new language, so the learning curve was low.
  • It documented a component's props in one place, which helps the next developer who uses the component.
  • It surfaced mistakes early in development, with a console message that names the component and the prop.

Its limits were just as clear. It only warned, it did not stop the build, and it could not check your whole programme the way a static type checker can. The README also says the validators are not meant to be called directly in your own code, and that you can strip their implementations to reduce bundle size.

What changed in React 19?

The React 19 upgrade guide is direct: "In React 19, we're removing the propType checks from the React package, and using them will be silently ignored." React 19 became stable on 5 December 2024, according to the React team's release post. The same guide also removes defaultProps from function components in favour of ES6 default parameters, while class components keep defaultProps.

FeatureReact 18 and earlierReact 19
propTypes on componentsChecked at runtime, with console warningsSilently ignored; React no longer runs the checks
defaultProps on function componentsSupportedRemoved; use ES6 default parameters
defaultProps on class componentsSupportedStill supported, as there is no ES6 alternative
Recommended typecheckingpropTypes, Flow or TypeScriptTypeScript or another type-checking solution

The prop-types package itself is still available, and its documentation says PropTypes.checkPropTypes(...) is safe to call in production. Its GitHub repository is, however, marked as archived, so do not plan a new codebase around it.

How do PropTypes and TypeScript compare?

The two tools answer the same question at different moments. PropTypes checks values while the app runs. TypeScript checks the types of your code before it runs, and the types are removed at compile time. The table below shows when each fits.

Two-column diagram mapping PropTypes, isRequired validators, defaultProps and manual conversion to TypeScript interfaces, typed props, ES6 default parameters and the official codemod.
QuestionPropTypesTypeScript
When does it check?At runtime, in the browserBefore the code runs, in the editor and the build
What happens on a mistake?A console warning, if the version of React still runs the checkA compile error you can fail the build on
Does it cover more than props?NoYes: state, hooks, functions and API responses
Status with React 19Ignored by ReactRecommended by the React team
Best fitLegacy React 18 and earlier code you are not ready to migrateNew code and migrations

How do I typecheck props with TypeScript?

The React documentation says you can get full React Web support in TypeScript by adding @types/react and @types/react-dom, and that every file containing JSX must use the .tsx extension. You then describe props with an interface or type. The React upgrade guide shows the migration for a function component:

// Before
Heading.propTypes = { text: PropTypes.string };
Heading.defaultProps = { text: 'Hello, world!' };

// After
interface Props {
  text?: string;
}

function Heading({ text = 'Hello, world!' }: Props) {
  return <h1>{text}</h1>;
}

To convert many files at once, the upgrade guide offers a codemod: npx codemod@latest react/prop-types-typescript. Review its output rather than accepting it blindly.

Because TypeScript does not check data at runtime, keep validation at the edges of your app, for example where an API response enters the system. Types you write by hand can still disagree with what a server actually sends.

What should a team do next?

  1. Check which React version each app runs. PropTypes warnings only appear in React 18 and earlier.
  2. Add TypeScript to one app or package first, with @types/react and @types/react-dom.
  3. Run the codemod on a branch and review the generated interfaces.
  4. Replace defaultProps on function components with default parameters.
  5. Fail the build on type errors, so the check does not depend on someone reading the console.
  6. Validate external data at the boundary, because compile-time types do not check runtime input.

Typed props also give automated tools a clear contract. When AI coding agents write or change components, a typed interface and a build that fails on type errors act as a first guardrail. ElixirClaw describes itself as an agentic OS platform to build, orchestrate and govern AI agents and automation workflows while keeping humans in control, and AgentQA describes itself as quality assurance for agent workflows, outputs and regression risk.

Type checking is one layer of quality. For a sibling topic on keeping layouts stable, read CSS size adjust for font face and fluid typography with CSS clamp.

To map one code-review or release decision your agents should make, and the context and policy it depends on, book a Context Workshop. See what happens in the workshop.

Frequently asked questions

Does React 19 still check propTypes?

No. The React team states that in React 19 it is removing the propType checks from the React package, and that using them will be silently ignored. Your code will not crash, but you will no longer see the console warnings.

Do I need the prop-types package in React 19?

Not for checking. The package is still published and can be called by hand with PropTypes.checkPropTypes, but React itself no longer runs the checks. New code should use TypeScript or another type-checking solution.

Does defaultProps still work?

On function components, no. React 19 removes defaultProps from function components in favour of ES6 default parameters. Class components keep defaultProps, because there is no ES6 alternative for them.

Is TypeScript a replacement for runtime validation?

Only partly. TypeScript checks types before the code runs, and the types are removed at compile time. Data that arrives from an API or a user at runtime still needs validation at the boundary where it enters your app.

How do I migrate an existing codebase?

The React team provides a codemod, npx codemod@latest react/prop-types-typescript, that converts propTypes to TypeScript. Run it on a branch, review the generated interfaces, and add @types/react and @types/react-dom to the project.

Table of Contents

navdeep-singh-gill

Navdeep Singh Gill

Global CEO and Founder of XenonStack

LinkedIn profile

Navdeep Singh Gill is serving as Chief Executive Officer and Product Architect at XenonStack. He holds expertise in building SaaS Platform for Decentralised Big Data management and Governance, AI Marketplace for Operationalising and Scaling. His incredible experience in AI Technologies and Big Data Engineering thrills him to write about different use cases and its approach to solutions.

Get the latest articles in your inbox

Subscribe Now

Related Articles

Interested in Solving your Challenges with XenonStack Team
Get Started

Get Started with your requirements and primary focus, that will help us to make your solution

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Proceed Next