forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjsxExcessPropsAndAssignability.types
48 lines (38 loc) · 2.3 KB
/
jsxExcessPropsAndAssignability.types
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
=== tests/cases/compiler/jsxExcessPropsAndAssignability.tsx ===
/// <reference path="react16.d.ts" />
import * as React from 'react';
>React : typeof React
const myHoc = <ComposedComponentProps extends any>(
>myHoc : <ComposedComponentProps extends unknown>(ComposedComponent: React.ComponentClass<ComposedComponentProps, any>) => void
><ComposedComponentProps extends any>( ComposedComponent: React.ComponentClass<ComposedComponentProps>,) => { type WrapperComponentProps = ComposedComponentProps & { myProp: string }; const WrapperComponent: React.ComponentClass<WrapperComponentProps> = null as any; const props: ComposedComponentProps = null as any; // Expected no error, got none - good <WrapperComponent {...props} myProp={'1000000'} />; // Expected error, but got none - bad! <WrapperComponent {...props} myProp={1000000} />;} : <ComposedComponentProps extends unknown>(ComposedComponent: React.ComponentClass<ComposedComponentProps, any>) => void
ComposedComponent: React.ComponentClass<ComposedComponentProps>,
>ComposedComponent : React.ComponentClass<ComposedComponentProps, any>
>React : any
) => {
type WrapperComponentProps = ComposedComponentProps & { myProp: string };
>WrapperComponentProps : ComposedComponentProps & { myProp: string; }
>myProp : string
const WrapperComponent: React.ComponentClass<WrapperComponentProps> = null as any;
>WrapperComponent : React.ComponentClass<ComposedComponentProps & { myProp: string; }, any>
>React : any
>null as any : any
>null : null
const props: ComposedComponentProps = null as any;
>props : ComposedComponentProps
>null as any : any
>null : null
// Expected no error, got none - good
<WrapperComponent {...props} myProp={'1000000'} />;
><WrapperComponent {...props} myProp={'1000000'} /> : JSX.Element
>WrapperComponent : React.ComponentClass<ComposedComponentProps & { myProp: string; }, any>
>props : ComposedComponentProps
>myProp : "1000000"
>'1000000' : "1000000"
// Expected error, but got none - bad!
<WrapperComponent {...props} myProp={1000000} />;
><WrapperComponent {...props} myProp={1000000} /> : JSX.Element
>WrapperComponent : React.ComponentClass<ComposedComponentProps & { myProp: string; }, any>
>props : ComposedComponentProps
>myProp : number
>1000000 : 1000000
};