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
10 changes: 5 additions & 5 deletions internal/checker/relater.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,11 +1052,11 @@ func (c *Checker) findMatchingDiscriminantType(source *Type, target *Type, isRel
if match := c.getMatchingUnionConstituentForType(target, source); match != nil {
return match
}
discriminantProperties := c.findDiscriminantProperties(c.getPropertiesOfType(source), target)
discriminator := &TypeDiscriminator{c: c, props: discriminantProperties, isRelatedTo: isRelatedTo}
discriminated := c.discriminateTypeByDiscriminableItems(target, discriminator)
if discriminated != target {
return discriminated
if discriminantProperties := c.findDiscriminantProperties(c.getPropertiesOfType(source), target); len(discriminantProperties) != 0 {
discriminator := &TypeDiscriminator{c: c, props: discriminantProperties, isRelatedTo: isRelatedTo}
if discriminated := c.discriminateTypeByDiscriminableItems(target, discriminator); discriminated != target {
return discriminated
}
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ jsxElementType.tsx(78,1): error TS2339: Property 'boop' does not exist on type '
jsxElementType.tsx(79,1): error TS2339: Property 'my-undeclared-custom-element' does not exist on type 'JSX.IntrinsicElements'.
jsxElementType.tsx(91,2): error TS2786: 'ReactNativeFlatList' cannot be used as a JSX component.
Its type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not a valid JSX element type.
Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '((props: any) => React18ReactNode) | (new (props: any) => Component<any, any, any>)'.
Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
jsxElementType.tsx(95,11): error TS2322: Type '{}' is not assignable to type 'LibraryManagedAttributes<T, {}>'.
jsxElementType.tsx(98,2): error TS2304: Cannot find name 'Unresolved'.
jsxElementType.tsx(99,2): error TS2304: Cannot find name 'Unresolved'.
Expand Down Expand Up @@ -177,9 +176,8 @@ jsxElementType.tsx(111,19): error TS2322: Type '{ a: string; b: string; }' is no
~~~~~~~~~~~~~~~~~~~
!!! error TS2786: 'ReactNativeFlatList' cannot be used as a JSX component.
!!! error TS2786: Its type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not a valid JSX element type.
!!! error TS2786: Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '((props: any) => React18ReactNode) | (new (props: any) => Component<any, any, any>)'.
!!! error TS2786: Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
!!! error TS2786: Target signature provides too few arguments. Expected 2 or more, but got 1.
!!! error TS2786: Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
!!! error TS2786: Target signature provides too few arguments. Expected 2 or more, but got 1.

// testing higher-order component compat
function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,7 @@
Type '{ excessProp: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<RenderStringClass> & Readonly<{ children?: ReactNode; }> & Readonly<{ title: string; }>'.
Property 'excessProp' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<RenderStringClass> & Readonly<{ children?: ReactNode; }> & Readonly<{ title: string; }>'.
jsxElementType.tsx(78,1): error TS2339: Property 'boop' does not exist on type 'JSX.IntrinsicElements'.
jsxElementType.tsx(79,1): error TS2339: Property 'my-undeclared-custom-element' does not exist on type 'JSX.IntrinsicElements'.
jsxElementType.tsx(91,2): error TS2786: 'ReactNativeFlatList' cannot be used as a JSX component.
Its type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not a valid JSX element type.
- Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
- Target signature provides too few arguments. Expected 2 or more, but got 1.
+ Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '((props: any) => React18ReactNode) | (new (props: any) => Component<any, any, any>)'.
+ Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
+ Target signature provides too few arguments. Expected 2 or more, but got 1.
jsxElementType.tsx(95,11): error TS2322: Type '{}' is not assignable to type 'LibraryManagedAttributes<T, {}>'.
jsxElementType.tsx(98,2): error TS2304: Cannot find name 'Unresolved'.
jsxElementType.tsx(99,2): error TS2304: Cannot find name 'Unresolved'.
@@= skipped -129, +125 lines =@@
@@= skipped -129, +124 lines =@@
<RenderStringClass />;
~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
Expand Down Expand Up @@ -59,16 +48,4 @@
+!!! related TS2771 react16.d.ts:357:13: The last overload is declared here.

// Host element types still work
<div />;
@@= skipped -42, +38 lines =@@
~~~~~~~~~~~~~~~~~~~
!!! error TS2786: 'ReactNativeFlatList' cannot be used as a JSX component.
!!! error TS2786: Its type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not a valid JSX element type.
-!!! error TS2786: Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
-!!! error TS2786: Target signature provides too few arguments. Expected 2 or more, but got 1.
+!!! error TS2786: Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '((props: any) => React18ReactNode) | (new (props: any) => Component<any, any, any>)'.
+!!! error TS2786: Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
+!!! error TS2786: Target signature provides too few arguments. Expected 2 or more, but got 1.

// testing higher-order component compat
function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
<div />;
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
a.tsx(6,28): error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'.
Types of property 'children' are incompatible.
Type '() => string' is not assignable to type 'ReactNode'.
Type '() => string' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal'.
a.tsx(7,47): error TS2322: Type '() => string' is not assignable to type 'ReactNode'.
Type '() => string' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal'.


==== a.tsx (2 errors) ====
Expand All @@ -17,10 +15,8 @@ a.tsx(7,47): error TS2322: Type '() => string' is not assignable to type 'ReactN
!!! error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'.
!!! error TS2322: Types of property 'children' are incompatible.
!!! error TS2322: Type '() => string' is not assignable to type 'ReactNode'.
!!! error TS2322: Type '() => string' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal'.
const jsxWithReactFragment = <React.Fragment>{test}</React.Fragment>;
~~~~
!!! error TS2322: Type '() => string' is not assignable to type 'ReactNode'.
!!! error TS2322: Type '() => string' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal'.
!!! related TS6212 a.tsx:7:47: Did you mean to call this expression?

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,20 @@ potentiallyUncalledDecorators.ts(35,1): error TS1329: 'noArgs' accepts too few a
potentiallyUncalledDecorators.ts(37,5): error TS1329: 'noArgs' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@noArgs()'?
potentiallyUncalledDecorators.ts(38,5): error TS1329: 'noArgs' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@noArgs()'?
potentiallyUncalledDecorators.ts(41,2): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof B'.
Type 'OmniDecorator' is not assignable to type 'typeof B'.
Type 'OmniDecorator' provides no match for the signature 'new (): B'.
potentiallyUncalledDecorators.ts(43,6): error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
potentiallyUncalledDecorators.ts(44,6): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.
potentiallyUncalledDecorators.ts(47,2): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof C'.
Type 'OmniDecorator' is not assignable to type 'typeof C'.
Type 'OmniDecorator' provides no match for the signature 'new (): C'.
potentiallyUncalledDecorators.ts(49,5): error TS1329: 'oneOptional' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@oneOptional()'?
potentiallyUncalledDecorators.ts(50,5): error TS1329: 'oneOptional' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@oneOptional()'?
potentiallyUncalledDecorators.ts(53,2): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof D'.
Type 'OmniDecorator' is not assignable to type 'typeof D'.
Type 'OmniDecorator' provides no match for the signature 'new (): D'.
potentiallyUncalledDecorators.ts(55,6): error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
potentiallyUncalledDecorators.ts(56,6): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.
potentiallyUncalledDecorators.ts(59,2): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof E'.
Type 'OmniDecorator' is not assignable to type 'typeof E'.
Type 'OmniDecorator' provides no match for the signature 'new (): E'.
potentiallyUncalledDecorators.ts(61,6): error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
potentiallyUncalledDecorators.ts(62,6): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.
potentiallyUncalledDecorators.ts(65,2): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof F'.
Type 'OmniDecorator' is not assignable to type 'typeof F'.
Type 'OmniDecorator' provides no match for the signature 'new (): F'.
potentiallyUncalledDecorators.ts(67,6): error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
potentiallyUncalledDecorators.ts(68,6): error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.


==== potentiallyUncalledDecorators.ts (19 errors) ====
Expand Down Expand Up @@ -85,23 +71,18 @@ potentiallyUncalledDecorators.ts(68,6): error TS1270: Decorator function return
@allRest
~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof B'.
!!! error TS1270: Type 'OmniDecorator' is not assignable to type 'typeof B'.
!!! error TS1270: Type 'OmniDecorator' provides no match for the signature 'new (): B'.
class B {
@allRest foo: any;
~~~~~~~
!!! error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
@allRest bar() { }
~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
!!! error TS1270: Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.
}

@oneOptional
~~~~~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof C'.
!!! error TS1270: Type 'OmniDecorator' is not assignable to type 'typeof C'.
!!! error TS1270: Type 'OmniDecorator' provides no match for the signature 'new (): C'.
class C {
@oneOptional foo: any;
~~~~~~~~~~~~
Expand All @@ -114,46 +95,37 @@ potentiallyUncalledDecorators.ts(68,6): error TS1270: Decorator function return
@twoOptional
~~~~~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof D'.
!!! error TS1270: Type 'OmniDecorator' is not assignable to type 'typeof D'.
!!! error TS1270: Type 'OmniDecorator' provides no match for the signature 'new (): D'.
class D {
@twoOptional foo: any;
~~~~~~~~~~~
!!! error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
@twoOptional bar() { }
~~~~~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
!!! error TS1270: Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.
}

@threeOptional
~~~~~~~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof E'.
!!! error TS1270: Type 'OmniDecorator' is not assignable to type 'typeof E'.
!!! error TS1270: Type 'OmniDecorator' provides no match for the signature 'new (): E'.
class E {
@threeOptional foo: any;
~~~~~~~~~~~~~
!!! error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
@threeOptional bar() { }
~~~~~~~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
!!! error TS1270: Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.
}

@oneOptionalWithRest
~~~~~~~~~~~~~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | typeof F'.
!!! error TS1270: Type 'OmniDecorator' is not assignable to type 'typeof F'.
!!! error TS1270: Type 'OmniDecorator' provides no match for the signature 'new (): F'.
class F {
@oneOptionalWithRest foo: any;
~~~~~~~~~~~~~~~~~~~
!!! error TS1271: Decorator function return type is 'OmniDecorator' but is expected to be 'void' or 'any'.
@oneOptionalWithRest bar() { }
~~~~~~~~~~~~~~~~~~~
!!! error TS1270: Decorator function return type 'OmniDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => void>'.
!!! error TS1270: Type 'OmniDecorator' has no properties in common with type 'TypedPropertyDescriptor<() => void>'.
}

@anyDec
Expand Down
Loading