fix confused comment (#49094)

This commit is contained in:
Oleksandr T 2022-05-17 01:26:26 +03:00 committed by GitHub
parent 0df9462a96
commit 755d5ccad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 21 deletions

View File

@ -1,7 +1,7 @@
tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(14,27): error TS2698: Spread types may only be created from object types.
tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(16,6): error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<WrapperComponentProps, any, any>> & Readonly<{ children?: ReactNode; }> & Readonly<WrapperComponentProps>'.
tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(13,27): error TS2698: Spread types may only be created from object types.
tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(14,6): error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<WrapperComponentProps, any, any>> & Readonly<{ children?: ReactNode; }> & Readonly<WrapperComponentProps>'.
Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'Readonly<WrapperComponentProps>'.
tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(16,27): error TS2698: Spread types may only be created from object types.
tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(14,27): error TS2698: Spread types may only be created from object types.
==== tests/cases/compiler/jsxExcessPropsAndAssignability.tsx (3 errors) ====
@ -17,11 +17,9 @@ tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(16,27): error TS2698: Sp
const props: ComposedComponentProps = null as any;
// Expected no error, got none - good
<WrapperComponent {...props} myProp={'1000000'} />;
~~~~~
!!! error TS2698: Spread types may only be created from object types.
// Expected error, but got none - bad!
<WrapperComponent {...props} myProp={1000000} />;
~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<WrapperComponentProps, any, any>> & Readonly<{ children?: ReactNode; }> & Readonly<WrapperComponentProps>'.

View File

@ -11,9 +11,7 @@ const myHoc = <ComposedComponentProps extends 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} />;
};
@ -37,8 +35,6 @@ var React = require("react");
var myHoc = function (ComposedComponent) {
var WrapperComponent = null;
var props = null;
// Expected no error, got none - good
React.createElement(WrapperComponent, __assign({}, props, { myProp: '1000000' }));
// Expected error, but got none - bad!
React.createElement(WrapperComponent, __assign({}, props, { myProp: 1000000 }));
};

View File

@ -30,17 +30,15 @@ const myHoc = <ComposedComponentProps extends any>(
>props : Symbol(props, Decl(jsxExcessPropsAndAssignability.tsx, 10, 9))
>ComposedComponentProps : Symbol(ComposedComponentProps, Decl(jsxExcessPropsAndAssignability.tsx, 4, 15))
// Expected no error, got none - good
<WrapperComponent {...props} myProp={'1000000'} />;
>WrapperComponent : Symbol(WrapperComponent, Decl(jsxExcessPropsAndAssignability.tsx, 8, 9))
>props : Symbol(props, Decl(jsxExcessPropsAndAssignability.tsx, 10, 9))
>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 12, 32))
<WrapperComponent {...props} myProp={1000000} />;
>WrapperComponent : Symbol(WrapperComponent, Decl(jsxExcessPropsAndAssignability.tsx, 8, 9))
>props : Symbol(props, Decl(jsxExcessPropsAndAssignability.tsx, 10, 9))
>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 13, 32))
// Expected error, but got none - bad!
<WrapperComponent {...props} myProp={1000000} />;
>WrapperComponent : Symbol(WrapperComponent, Decl(jsxExcessPropsAndAssignability.tsx, 8, 9))
>props : Symbol(props, Decl(jsxExcessPropsAndAssignability.tsx, 10, 9))
>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 15, 32))
};

View File

@ -6,7 +6,7 @@ import * as React from '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
><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; <WrapperComponent {...props} myProp={'1000000'} />; <WrapperComponent {...props} myProp={1000000} />;} : <ComposedComponentProps extends unknown>(ComposedComponent: React.ComponentClass<ComposedComponentProps, any>) => void
ComposedComponent: React.ComponentClass<ComposedComponentProps>,
>ComposedComponent : React.ComponentClass<ComposedComponentProps, any>
@ -28,7 +28,6 @@ const myHoc = <ComposedComponentProps extends any>(
>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>
@ -36,7 +35,6 @@ const myHoc = <ComposedComponentProps extends any>(
>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>

View File

@ -12,8 +12,6 @@ const myHoc = <ComposedComponentProps extends 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} />;
};