File: tsxStatelessFunctionComponents2.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (53 lines) | stat: -rw-r--r-- 2,292 bytes parent folder | download | duplicates (2)
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
tests/cases/conformance/jsx/file.tsx(20,16): error TS2339: Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
tests/cases/conformance/jsx/file.tsx(26,42): error TS2339: Property 'subtr' does not exist on type 'string'.
tests/cases/conformance/jsx/file.tsx(28,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
tests/cases/conformance/jsx/file.tsx(36,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 TS2339: 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 TS2339: Property 'subtr' does not exist on type 'string'.
    // 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'.