File: tsxStatelessFunctionComponents2.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (55 lines) | stat: -rw-r--r-- 2,609 bytes parent folder | download
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
tests/cases/conformance/jsx/file.tsx(19,10): error TS2322: Type '{ ref: string; }' is not assignable to type 'IntrinsicAttributes & { name?: string; }'.
  Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
tests/cases/conformance/jsx/file.tsx(25,42): error TS2551: Property 'subtr' does not exist on type 'string'. Did you mean 'substr'?
tests/cases/conformance/jsx/file.tsx(27,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
tests/cases/conformance/jsx/file.tsx(35,26): error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.


==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
    import React = require('react');
    
    function Greet(x: {name?: string}) {
    	return <div>Hello, {x}</div>;
    }
    
    class BigGreeter extends React.Component<{ name?: string }, {}> {
    	render() {
    		return <div></div>;
    	}
    	greeting: string;
    }
    
    // OK
    let a = <Greet />;
    // OK - always valid to specify 'key'
    let b = <Greet key="k" />;
    // Error - not allowed to specify 'ref' on SFCs
    let c = <Greet ref="myRef" />;
             ~~~~~
!!! error TS2322: Type '{ ref: string; }' is not assignable to type 'IntrinsicAttributes & { name?: string; }'.
!!! error TS2322:   Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
    
    
    // OK - ref is valid for classes
    let d = <BigGreeter ref={x => x.greeting.substr(10)} />;
    // Error ('subtr' not on string)
    let e = <BigGreeter ref={x => x.greeting.subtr(10)} />;
                                             ~~~~~
!!! error TS2551: Property 'subtr' does not exist on type 'string'. Did you mean 'substr'?
!!! related TS2728 /.lib/lib.d.ts:438:5: 'substr' is declared here.
    // Error (ref callback is contextually typed)
    let f = <BigGreeter ref={x => x.notARealProperty} />;
                                    ~~~~~~~~~~~~~~~~
!!! error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
    
    // OK - key is always valid
    let g = <BigGreeter key={100} />;
    
    // OK - contextually typed intrinsic ref callback parameter
    let h = <div ref={x => x.innerText} />;
    // Error - property not on ontextually typed intrinsic ref callback parameter
    let i = <div ref={x => x.propertyNotOnHtmlDivElement} />;
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.