1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
|
=== tests/cases/compiler/styledComponentsInstantiaionLimitNotReached.ts ===
/// <reference path="react16.d.ts" />
import * as React from "react";
>React : typeof React
interface REACT_STATICS {
childContextTypes: true;
>childContextTypes : true
>true : true
contextType: true;
>contextType : true
>true : true
contextTypes: true;
>contextTypes : true
>true : true
defaultProps: true;
>defaultProps : true
>true : true
displayName: true;
>displayName : true
>true : true
getDefaultProps: true;
>getDefaultProps : true
>true : true
getDerivedStateFromError: true;
>getDerivedStateFromError : true
>true : true
getDerivedStateFromProps: true;
>getDerivedStateFromProps : true
>true : true
mixins: true;
>mixins : true
>true : true
propTypes: true;
>propTypes : true
>true : true
type: true;
>type : true
>true : true
}
interface KNOWN_STATICS {
name: true;
>name : true
>true : true
length: true;
>length : true
>true : true
prototype: true;
>prototype : true
>true : true
caller: true;
>caller : true
>true : true
callee: true;
>callee : true
>true : true
arguments: true;
>arguments : true
>true : true
arity: true;
>arity : true
>true : true
}
interface MEMO_STATICS {
'$$typeof': true;
>'$$typeof' : true
>true : true
compare: true;
>compare : true
>true : true
defaultProps: true;
>defaultProps : true
>true : true
displayName: true;
>displayName : true
>true : true
propTypes: true;
>propTypes : true
>true : true
type: true;
>type : true
>true : true
}
interface FORWARD_REF_STATICS {
'$$typeof': true;
>'$$typeof' : true
>true : true
render: true;
>render : true
>true : true
defaultProps: true;
>defaultProps : true
>true : true
displayName: true;
>displayName : true
>true : true
propTypes: true;
>propTypes : true
>true : true
}
type NonReactStatics<
>NonReactStatics : NonReactStatics<S, C>
S extends React.ComponentType<any>,
>React : any
C extends {
[key: string]: true
>key : string
>true : true
} = {}
> = {
[key in Exclude<
keyof S,
S extends React.MemoExoticComponent<any>
>React : any
? keyof MEMO_STATICS | keyof C
: S extends React.ForwardRefExoticComponent<any>
>React : any
? keyof FORWARD_REF_STATICS | keyof C
: keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C
>]: S[key]
};
export type AnyStyledComponent = StyledComponent<any, any, any, any> | StyledComponent<any, any, any>;
>AnyStyledComponent : StyledComponent<any, any, any, any> | StyledComponent<any, any, any, never>
export type StyledComponent<
>StyledComponent : StyledComponent<C, T, O, A>
C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
>JSX : any
>React : any
T extends object,
O extends object = {},
A extends keyof any = never
> = // the "string" allows this to be used as an object key
// I really want to avoid this if possible but it's the only way to use nesting with object styles...
string &
StyledComponentBase<C, T, O, A> &
NonReactStatics<C extends React.ComponentType<any> ? C : never>;
>React : any
export type StyledComponentProps<
>StyledComponentProps : StyledComponentProps<C, T, O, A>
// The Component from whose props are derived
C extends string | React.ComponentType<any>,
>React : any
// The Theme from the current context
T extends object,
// The other props added by the template
O extends object,
// The props that are made optional by .attrs
A extends keyof any
> =
// Distribute O if O is a union type
O extends object
? WithOptionalTheme<
Omit<
ReactDefaultizedProps<
C,
React.ComponentPropsWithRef<
>React : any
C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never
>React : any
>
> &
O,
A
> &
Partial<
Pick<
React.ComponentPropsWithRef<
>React : any
C extends IntrinsicElementsKeys | React.ComponentType<any> ? C : never
>React : any
> &
O,
A
>
>,
T
> &
WithChildrenIfReactComponentClass<C>
: never;
type Defaultize<P, D> = P extends any
>Defaultize : Defaultize<P, D>
? string extends keyof P
? P
: Pick<P, Exclude<keyof P, keyof D>> &
Partial<Pick<P, Extract<keyof P, keyof D>>> &
Partial<Pick<D, Exclude<keyof D, keyof P>>>
: never;
type ReactDefaultizedProps<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D> : P;
>ReactDefaultizedProps : ReactDefaultizedProps<C, P>
>defaultProps : D
type WithChildrenIfReactComponentClass<C extends string | React.ComponentType<any>> = C extends React.ComponentClass<
>WithChildrenIfReactComponentClass : WithChildrenIfReactComponentClass<C>
>React : any
>React : any
any
>
? { children?: React.ReactNode }
>children : React.ReactNode
>React : any
: {};
export type IntrinsicElementsKeys = keyof JSX.IntrinsicElements;
>IntrinsicElementsKeys : keyof JSX.IntrinsicElements
>JSX : any
type WithOptionalTheme<P extends { theme?: T }, T> = Omit<P, 'theme'> & {
>WithOptionalTheme : WithOptionalTheme<P, T>
>theme : T
theme?: T;
>theme : T
};
type ForwardRefExoticBase<P> = Pick<React.ForwardRefExoticComponent<P>, keyof React.ForwardRefExoticComponent<any>>;
>ForwardRefExoticBase : ForwardRefExoticBase<P>
>React : any
>React : any
type StyledComponentPropsWithAs<
>StyledComponentPropsWithAs : StyledComponentPropsWithAs<C, T, O, A, F>
C extends string | React.ComponentType<any>,
>React : any
T extends object,
O extends object,
A extends keyof any,
F extends string | React.ComponentType<any> = C
>React : any
> = StyledComponentProps<C, T, O, A> & { as?: C; forwardedAs?: F };
>as : C
>forwardedAs : F
export type StyledComponentInnerOtherProps<C extends AnyStyledComponent> = C extends StyledComponent<
>StyledComponentInnerOtherProps : StyledComponentInnerOtherProps<C>
any,
any,
infer O,
any
>
? O
: C extends StyledComponent<any, any, infer O>
? O
: never;
export type StyledComponentInnerAttrs<C extends AnyStyledComponent> = C extends StyledComponent<any, any, any, infer A>
>StyledComponentInnerAttrs : StyledComponentInnerAttrs<C>
? A
: never;
export interface StyledComponentBase<
C extends string | React.ComponentType<any>,
>React : any
T extends object,
O extends object = {},
A extends keyof any = never
> extends ForwardRefExoticBase<StyledComponentProps<C, T, O, A>> {
// add our own fake call signature to implement the polymorphic 'as' prop
(props: StyledComponentProps<C, T, O, A> & { as?: never; forwardedAs?: never }): React.ReactElement<
>props : StyledComponentProps<C, T, O, A> & { as?: never; forwardedAs?: never; }
>as : never
>forwardedAs : never
>React : any
StyledComponentProps<C, T, O, A>
>;
<AsC extends string | React.ComponentType<any> = C, FAsC extends string | React.ComponentType<any> = AsC>(
>React : any
>React : any
props: StyledComponentPropsWithAs<AsC, T, O, A, FAsC>,
>props : StyledComponentPropsWithAs<AsC, T, O, A, FAsC>
): React.ReactElement<StyledComponentPropsWithAs<AsC, T, O, A, FAsC>>;
>React : any
withComponent<WithC extends AnyStyledComponent>(
>withComponent : { <WithC extends AnyStyledComponent>(component: WithC): StyledComponent<StyledComponentInnerComponent<WithC>, T, O & StyledComponentInnerOtherProps<WithC>, A | StyledComponentInnerAttrs<WithC>>; <WithC extends keyof JSX.IntrinsicElements | React.ComponentType<any>>(component: WithC): StyledComponent<WithC, T, O, A>; }
component: WithC,
>component : WithC
): StyledComponent<
StyledComponentInnerComponent<WithC>,
T,
O & StyledComponentInnerOtherProps<WithC>,
A | StyledComponentInnerAttrs<WithC>
>;
withComponent<WithC extends keyof JSX.IntrinsicElements | React.ComponentType<any>>(
>withComponent : { <WithC extends AnyStyledComponent>(component: WithC): StyledComponent<StyledComponentInnerComponent<WithC>, T, O & StyledComponentInnerOtherProps<WithC>, A | StyledComponentInnerAttrs<WithC>>; <WithC extends keyof JSX.IntrinsicElements | React.ComponentType<any>>(component: WithC): StyledComponent<WithC, T, O, A>; }
>JSX : any
>React : any
component: WithC,
>component : WithC
): StyledComponent<WithC, T, O, A>;
}
export type StyledComponentInnerComponent<C extends React.ComponentType<any>> = C extends StyledComponent<
>StyledComponentInnerComponent : StyledComponentInnerComponent<C>
>React : any
infer I,
any,
any,
any
>
? I
: C extends StyledComponent<infer I, any, any>
? I
: C;
export type StyledComponentPropsWithRef<
>StyledComponentPropsWithRef : StyledComponentPropsWithRef<C>
C extends keyof JSX.IntrinsicElements | React.ComponentType<any>
>JSX : any
>React : any
> = C extends AnyStyledComponent
? React.ComponentPropsWithRef<StyledComponentInnerComponent<C>> // shouldn't have an instantiation limit error
>React : any
: React.ComponentPropsWithRef<C>;
>React : any
|