Comments (3)
I've gotten this far but we need to cut our losses trying to reduce Route
and its twenty-one type parameters down to something that can be investigated.
import { Route } from '@tanstack/react-router';
import React from 'react';
export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
}
export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
types: {
children: infer TChildren;
};
} ? TChildren extends Array<unknown> ? ParseRoute<TChildren[number], TAcc | TChildren[number]> : TAcc : TAcc;
export type RoutesByPath<TRouteTree extends AnyRoute> = {
[K in ParseRoute<TRouteTree> as K['fullPath']]: K;
} & Record<'.' | '..', ParseRoute<TRouteTree>>;
export type RouteByPath<TRouteTree extends AnyRoute, TPath> = (string extends TPath ? ParseRoute<TRouteTree> : RoutesByPath<TRouteTree>[TPath]);
export type CheckPath<TRouteTree extends AnyRoute> =
RouteByPath<TRouteTree, `${string}/`> extends never ? { to: string } : {};
export type ActiveLinkOptions<TRouteTree extends AnyRoute> = {
to: string;
} & CheckPath<TRouteTree>;
export type WithComponentOverride<P, T extends React.ElementType> = P & InferProps<T> & {
component: T;
};
export type InferProps<T extends React.ElementType> =
T extends React.ComponentType<infer P> ? P : {};
declare const Link2: LinkComponent;
type Orig_TanstackLinkProps = Parameters<typeof Link2>[0];
const Link = <T extends React.ElementType>(
props: WithComponentOverride<Orig_TanstackLinkProps, T>
) => {
const p: keyof typeof props = 'component';
const Component = props.component; // TS2339: Property component does not exist on type <...blabla...>
// ...
return <Component {...props} />;
};
export type LinkComponent = <TRouteTree extends AnyRoute>(props: ActiveLinkOptions<TRouteTree>) => React.ReactElement;
We need someone to provide a minimal self-contained repro here; the tanstack types are beyond comprehension.
from typescript.
It's not the size; using a very very large props type as the base doesn't reproduce the problem
type BaseProps = Record<`${'a' | 'b' | 'c' | 'd'}${'a' | 'b' | 'c' | 'd'}${'a' | 'b' | 'c' | 'd'}${'a' | 'b' | 'c' | 'd'}${'a' | 'b' | 'c' | 'd'}`, string>;
const Link = <T extends React.ElementType>(
props: WithComponentOverride<BaseProps, T>
) => {
const Component = props.component; // ok
return <Component {...props} />;
};
Need to figure out what's weird about TanstackLinkProps
but it's a tangled web
from typescript.
Marking off some progress here...
import React from 'react';
import { RouteByPath, } from "@tanstack/react-router";
import { AnyRoute } from "@tanstack/react-router";
export type CheckPath<TRouteTree extends AnyRoute> =
RouteByPath<TRouteTree, `${string}/`> extends never ? { to: string } : {};
export type ActiveLinkOptions<TRouteTree extends AnyRoute> = {
to: string;
} & CheckPath<TRouteTree>;
export type WithComponentOverride<P, T extends React.ElementType> = P & InferProps<T> & {
component: T;
};
export type InferProps<T extends React.ElementType> =
T extends React.ComponentType<infer P> ? P : {};
declare const Link2: LinkComponent;
type Orig_TanstackLinkProps = Parameters<typeof Link2>[0];
const Link = <T extends React.ElementType>(
props: WithComponentOverride<Orig_TanstackLinkProps, T>
) => {
const p: keyof typeof props = 'component';
const Component = props.component; // TS2339: Property component does not exist on type <...blabla...>
// ...
return <Component {...props} />;
};
export type LinkComponent = <TRouteTree extends AnyRoute>(props: ActiveLinkOptions<TRouteTree>) => React.ReactElement;
from typescript.
Related Issues (20)
- [isolatedDeclarations][5.5] Autofix does not work when JSX prop contains a dash `-`
- Subtracting Date objects shows a TypeScript error, but actually works. HOT 4
- Problem with typing a NestKey type
- type inference issue with dynamic template literals HOT 1
- Unable to type nested fields in a Node.js module. HOT 5
- Scope confusion with reused signatures
- Declaration references expanded type paramater
- Design Meeting Notes, 3/29/2024
- Design Meeting Notes, 4/12/2024
- Design Meeting Notes, 4/16/2024
- Design Meeting Notes, 4/23/2024
- Design Meeting Notes, 4/26/2024 HOT 1
- Design Meeting Notes, 4/30/2024 HOT 1
- tsc --init update 2024 HOT 4
- [transpileDeclaration API][5.5] Type containing enum values is incorrectly emitted HOT 3
- 5.5 Beta - Error assigning const string to enum from another file HOT 3
- `export default` generates JavaScript and declaration file incompatible HOT 2
- Issues with `isolatedDeclarations` and the associated fixes in editor HOT 1
- Incremental Builds are not Reliable v5.4.5 HOT 2
- Design Meeting Notes, 5/3/2024 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.