File: reactDefaultPropsInferenceSuccess.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (120 lines) | stat: -rw-r--r-- 8,891 bytes parent folder | download | duplicates (3)
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
tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(27,36): error TS2769: No overload matches this call.
  Overload 1 of 2, '(props: Readonly<Props>): FieldFeedback<Props>', gave the following error.
    Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
      Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
        Type 'void' is not assignable to type 'boolean'.
  Overload 2 of 2, '(props: Props, context?: any): FieldFeedback<Props>', gave the following error.
    Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(43,41): error TS2769: No overload matches this call.
  Overload 1 of 2, '(props: Readonly<Props>): FieldFeedbackBeta<Props>', gave the following error.
    Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
      Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
        Type 'void' is not assignable to type 'boolean'.
  Overload 2 of 2, '(props: Props, context?: any): FieldFeedbackBeta<Props>', gave the following error.
    Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,37): error TS2769: No overload matches this call.
  Overload 1 of 2, '(props: Readonly<MyPropsProps>): FieldFeedback2<MyPropsProps>', gave the following error.
    Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
      Type 'void' is not assignable to type 'boolean'.
  Overload 2 of 2, '(props: MyPropsProps, context?: any): FieldFeedback2<MyPropsProps>', gave the following error.
    Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.


==== tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx (3 errors) ====
    /// <reference path="/.lib/react16.d.ts" />
    
    import React from 'react';
    
    interface BaseProps {
      when?: ((value: string) => boolean) | "a" | "b";
      error?: boolean;
    }
    
    interface Props extends BaseProps {
    }
    
    class FieldFeedback<P extends Props = BaseProps> extends React.Component<P> {
      static defaultProps = {
        when: () => true
      };
    
      render() {
        return <div>Hello</div>;
      }
    }
    
    // OK
    const Test1 = () => <FieldFeedback when={value => !!value} />;
    
    // Error: Void not assignable to boolean
    const Test2 = () => <FieldFeedback when={value => console.log(value)} />;
                                       ~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 2, '(props: Readonly<Props>): FieldFeedback<Props>', gave the following error.
!!! error TS2769:     Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
!!! error TS2769:       Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
!!! error TS2769:         Type 'void' is not assignable to type 'boolean'.
!!! error TS2769:   Overload 2 of 2, '(props: Props, context?: any): FieldFeedback<Props>', gave the following error.
!!! error TS2769:     Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedback<Props>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "children" | "error"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "when">> & Partial<Pick<{ when: () => boolean; }, never>>'
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedback<Props>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "children" | "error"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "when">> & Partial<Pick<{ when: () => boolean; }, never>>'
    
    class FieldFeedbackBeta<P extends Props = BaseProps> extends React.Component<P> {
      static defaultProps: BaseProps = {
        when: () => true
      };
    
      render() {
        return <div>Hello</div>;
      }
    }
    
    // OK
    const Test1a = () => <FieldFeedbackBeta when={value => !!value} error>Hah</FieldFeedbackBeta>;
    
    // Error: Void not assignable to boolean
    const Test2a = () => <FieldFeedbackBeta when={value => console.log(value)} error>Hah</FieldFeedbackBeta>;
                                            ~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 2, '(props: Readonly<Props>): FieldFeedbackBeta<Props>', gave the following error.
!!! error TS2769:     Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
!!! error TS2769:       Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
!!! error TS2769:         Type 'void' is not assignable to type 'boolean'.
!!! error TS2769:   Overload 2 of 2, '(props: Props, context?: any): FieldFeedbackBeta<Props>', gave the following error.
!!! error TS2769:     Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedbackBeta<Props>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "children"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, keyof Props>> & Partial<Pick<BaseProps, never>>'
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedbackBeta<Props>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "children"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, keyof Props>> & Partial<Pick<BaseProps, never>>'
    
    interface MyPropsProps extends Props {
      when: (value: string) => boolean;
    }
    
    class FieldFeedback2<P extends MyPropsProps = MyPropsProps> extends FieldFeedback<P> {
      static defaultProps = {
        when: () => true
      };
    
      render() {
        this.props.when("now"); // OK, always defined
        return <div>Hello</div>;
      }
    }
    
    // OK
    const Test3 = () => <FieldFeedback2 when={value => !!value} />;
    
    // Error: Void not assignable to boolean
    const Test4 = () => <FieldFeedback2 when={value => console.log(value)} />;
                                        ~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 2, '(props: Readonly<MyPropsProps>): FieldFeedback2<MyPropsProps>', gave the following error.
!!! error TS2769:     Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
!!! error TS2769:       Type 'void' is not assignable to type 'boolean'.
!!! error TS2769:   Overload 2 of 2, '(props: MyPropsProps, context?: any): FieldFeedback2<MyPropsProps>', gave the following error.
!!! error TS2769:     Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:46:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedback2<MyPropsProps>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<MyPropsProps>, "children" | "error"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<MyPropsProps>, "when">> & Partial<Pick<{ when: () => boolean; }, never>>'
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:46:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedback2<MyPropsProps>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<MyPropsProps>, "children" | "error"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<MyPropsProps>, "when">> & Partial<Pick<{ when: () => boolean; }, never>>'
    
    // OK
    const Test5 = () => <FieldFeedback2 />;