Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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) ====
Expand All @@ -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>'.
Expand Down
4 changes: 0 additions & 4 deletions tests/baselines/reference/jsxExcessPropsAndAssignability.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} />;
};

Expand All @@ -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 }));
};
Original file line number Diff line number Diff line change
Expand Up @@ -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, 13, 32))
>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 12, 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))
>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 13, 32))

};

Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -28,15 +28,13 @@ 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>
>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>
Expand Down
2 changes: 0 additions & 2 deletions tests/cases/compiler/jsxExcessPropsAndAssignability.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />;
};