Skip to contentSlop Block

no-inline-properties-type

Warning

Declare component properties as a named type. Do not write an object type literal in the parameter.

function TextLink(properties: { href: string; children: JSX.Element }) {Move the inline properties type of $NAME into a named type	return <a href={properties.href}>{properties.children}</a>;}
export function SeverityLabel(properties: { severity: Severity }) {Move the inline properties type of $NAME into a named type	return <span>{properties.severity}</span>;}
export default function Page(properties?: { title: string }) {Move the inline properties type of $NAME into a named type	return <h1>{properties?.title}</h1>;}
export const Card = ({ title }: { title: string }) => <div>{title}</div>;Move the inline properties type of $NAME into a named type
const Card = function (properties: { title: string }) {Move the inline properties type of $NAME into a named type	return <div>{properties.title}</div>;};
const Card = memo(function Card(properties: { title: string }) {Move the inline properties type of $NAME into a named type	return <div>{properties.title}</div>;});
export function Link(properties: HTMLArkProps<"a"> & { external: boolean }) {Move the inline properties type of $NAME into a named type	return <a {...properties} />;}
function Base(properties: PropsWithChildren<{ preview: string }>) {Move the inline properties type of $NAME into a named type	return <main title={properties.preview}>{properties.children}</main>;}
function List<T>(properties: { items: T[] }) {Move the inline properties type of $NAME into a named type	return <ul>{properties.items.map(String)}</ul>;}
// ast-grep-ignore: no-inline-properties-type-typescript

How to fix

Declare the object type with type next to the component and annotate the parameter with it: type TextLinkProperties = { href: string } and function TextLink(properties: TextLinkProperties). The rule does not check the alias name.

This applies to destructured parameters and to object literals inside intersections, unions and type arguments, as in Base & { extra: string }; move the whole type into the alias. Generic components declare a generic alias, as in type ListProperties<T> = { items: T[] }.

The rule checks functions with an upper-case name that contain JSX. It skips overload signatures and arrow functions passed to a call, such as memo((properties) => ...).