Skip to content

Commit 1a0299d

Browse files
committed
Missed some baseline files; address CR feedback
1 parent 3426aa6 commit 1a0299d

3 files changed

Lines changed: 44 additions & 29 deletions

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ namespace ts {
202202

203203
let jsxElementType: ObjectType;
204204
/** Things we lazy load from the JSX namespace */
205-
const jsxTypes: {[name: string]: ObjectType} = {};
205+
const jsxTypes: Map<ObjectType> = {};
206206
const JsxNames = {
207207
JSX: "JSX",
208208
IntrinsicElements: "IntrinsicElements",
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
22
tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(20,16): error TS2339: Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
33
tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(26,42): error TS2339: Property 'subtr' does not exist on type 'string'.
4-
tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(28,5): error TS2451: Cannot redeclare block-scoped variable 'f'.
54
tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(28,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
6-
tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(31,5): error TS2451: Cannot redeclare block-scoped variable 'f'.
5+
tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(36,26): error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.
76

87

9-
==== tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx (6 errors) ====
8+
==== tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx (5 errors) ====
109

1110
import React = require('react');
1211
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -25,28 +24,33 @@ tests/cases/conformance/jsx/tsxStatelessFunctionComponents2.tsx(31,5): error TS2
2524

2625
// OK
2726
let a = <Greet />;
28-
// OK
27+
// OK - always valid to specify 'key'
2928
let b = <Greet key="k" />;
30-
// Error
29+
// Error - not allowed to specify 'ref' on SFCs
3130
let c = <Greet ref="myRef" />;
3231
~~~
3332
!!! error TS2339: Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
3433

3534

36-
// OK
35+
// OK - ref is valid for classes
3736
let d = <BigGreeter ref={x => x.greeting.substr(10)} />;
38-
// Error ('subtr')
37+
// Error ('subtr' not on string)
3938
let e = <BigGreeter ref={x => x.greeting.subtr(10)} />;
4039
~~~~~
4140
!!! error TS2339: Property 'subtr' does not exist on type 'string'.
42-
// Error
41+
// Error (ref callback is contextually typed)
4342
let f = <BigGreeter ref={x => x.notARealProperty} />;
44-
~
45-
!!! error TS2451: Cannot redeclare block-scoped variable 'f'.
4643
~~~~~~~~~~~~~~~~
4744
!!! error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
4845

49-
// OK
50-
let f = <BigGreeter key={100} />;
51-
~
52-
!!! error TS2451: Cannot redeclare block-scoped variable 'f'.
46+
// OK - key is always valid
47+
let g = <BigGreeter key={100} />;
48+
49+
// OK - contextually typed intrinsic ref callback parameter
50+
let h = <div ref={x => x.innerText} />;
51+
// Error - property not on ontextually typed intrinsic ref callback parameter
52+
let i = <div ref={x => x.propertyNotOnHtmlDivElement} />;
53+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
54+
!!! error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.
55+
56+

tests/baselines/reference/tsxStatelessFunctionComponents2.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,28 @@ class BigGreeter extends React.Component<{ name?: string }, {}> {
1515

1616
// OK
1717
let a = <Greet />;
18-
// OK
18+
// OK - always valid to specify 'key'
1919
let b = <Greet key="k" />;
20-
// Error
20+
// Error - not allowed to specify 'ref' on SFCs
2121
let c = <Greet ref="myRef" />;
2222

2323

24-
// OK
24+
// OK - ref is valid for classes
2525
let d = <BigGreeter ref={x => x.greeting.substr(10)} />;
26-
// Error ('subtr')
26+
// Error ('subtr' not on string)
2727
let e = <BigGreeter ref={x => x.greeting.subtr(10)} />;
28-
// Error
28+
// Error (ref callback is contextually typed)
2929
let f = <BigGreeter ref={x => x.notARealProperty} />;
3030

31-
// OK
32-
let f = <BigGreeter key={100} />;
31+
// OK - key is always valid
32+
let g = <BigGreeter key={100} />;
33+
34+
// OK - contextually typed intrinsic ref callback parameter
35+
let h = <div ref={x => x.innerText} />;
36+
// Error - property not on ontextually typed intrinsic ref callback parameter
37+
let i = <div ref={x => x.propertyNotOnHtmlDivElement} />;
38+
39+
3340

3441
//// [tsxStatelessFunctionComponents2.jsx]
3542
var __extends = (this && this.__extends) || function (d, b) {
@@ -53,15 +60,19 @@ var BigGreeter = (function (_super) {
5360
})(React.Component);
5461
// OK
5562
var a = <Greet />;
56-
// OK
63+
// OK - always valid to specify 'key'
5764
var b = <Greet key="k"/>;
58-
// Error
65+
// Error - not allowed to specify 'ref' on SFCs
5966
var c = <Greet ref="myRef"/>;
60-
// OK
67+
// OK - ref is valid for classes
6168
var d = <BigGreeter ref={function (x) { return x.greeting.substr(10); }}/>;
62-
// Error ('subtr')
69+
// Error ('subtr' not on string)
6370
var e = <BigGreeter ref={function (x) { return x.greeting.subtr(10); }}/>;
64-
// Error
71+
// Error (ref callback is contextually typed)
6572
var f = <BigGreeter ref={function (x) { return x.notARealProperty; }}/>;
66-
// OK
67-
var f = <BigGreeter key={100}/>;
73+
// OK - key is always valid
74+
var g = <BigGreeter key={100}/>;
75+
// OK - contextually typed intrinsic ref callback parameter
76+
var h = <div ref={function (x) { return x.innerText; }}/>;
77+
// Error - property not on ontextually typed intrinsic ref callback parameter
78+
var i = <div ref={function (x) { return x.propertyNotOnHtmlDivElement; }}/>;

0 commit comments

Comments
 (0)