Repository navigation
Replies: 1 comment
|
I couldn't find a built-in prop-exclusion option in the Using the import {
createLink,
type AnyRouter,
type LinkComponentProps,
type RegisteredRouter,
} from '@tanstack/react-router';
import type { ReactElement } from 'react';
const RouterAriaLink = createLink(BaseButtonLink);
type AriaDisabledLink = <
TRouter extends AnyRouter = RegisteredRouter,
const TFrom extends string = string,
const TTo extends string | undefined = undefined,
const TMaskFrom extends string = TFrom,
const TMaskTo extends string = '',
>(
props: LinkComponentProps<
typeof BaseButtonLink,
TRouter,
TFrom,
TTo,
TMaskFrom,
TMaskTo
> & { disabled?: never },
) => ReactElement;
export const ButtonLink: AriaDisabledLink = (props) => (
<RouterAriaLink {...props} disabled={props.isDisabled ?? false} />
);I added the The public signature rejects a boolean <ButtonLink to="/" isDisabled>Home</ButtonLink>; // OK
<ButtonLink to="/" disabled>Home</ButtonLink>; // Type error
<ButtonLink to="/" {...{ disabled: true }}>Home</ButtonLink>; // Type errorI checked the wrapper itself with The restriction is at the TypeScript boundary; it is not runtime input validation. With Reference: custom links and React Aria integration. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Integrating with component libraries like React Aria Components this is confusing which use
isDisabledinstead ofdisabledExpected output:
However, even when custom link components explicitly omit
disabledfrom their props interface, createLink() still injects it into the final component type, making it impossible to prevent at the TypeScript level.Does library have solutions to support my case ?
All reactions