Fix the emit when jsx attribute expression is empty

Fixes #12994
This commit is contained in:
Sheetal Nandi
2017-01-03 10:59:31 -08:00
parent 32cec588ff
commit f412e10310
4 changed files with 59 additions and 0 deletions

View File

@@ -150,6 +150,9 @@ namespace ts {
return decoded ? createLiteral(decoded, /*location*/ node) : node;
}
else if (node.kind === SyntaxKind.JsxExpression) {
if (node.expression === undefined) {
return createLiteral(true);
}
return visitJsxExpression(<JsxExpression>node);
}
else {

View File

@@ -0,0 +1,33 @@
tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(3,2): error TS2304: Cannot find name 'View'.
tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(4,6): error TS2304: Cannot find name 'ListView'.
tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(5,10): error TS2304: Cannot find name 'RefreshControl'.
tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(5,35): error TS17000: JSX attributes must only be assigned a non-empty 'expression'.
tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(6,44): error TS17000: JSX attributes must only be assigned a non-empty 'expression'.
tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(7,7): error TS2304: Cannot find name 'ListView'.
tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(8,3): error TS2304: Cannot find name 'View'.
==== tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx (7 errors) ====
declare var React: any;
<View>
~~~~
!!! error TS2304: Cannot find name 'View'.
<ListView refreshControl={
~~~~~~~~
!!! error TS2304: Cannot find name 'ListView'.
<RefreshControl onRefresh={} refreshing={} />
~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'RefreshControl'.
~~
!!! error TS17000: JSX attributes must only be assigned a non-empty 'expression'.
} dataSource={this.state.ds} renderRow={}>
~~
!!! error TS17000: JSX attributes must only be assigned a non-empty 'expression'.
</ListView>
~~~~~~~~
!!! error TS2304: Cannot find name 'ListView'.
</View>
~~~~
!!! error TS2304: Cannot find name 'View'.

View File

@@ -0,0 +1,14 @@
//// [jsxAttributeWithoutExpressionReact.tsx]
declare var React: any;
<View>
<ListView refreshControl={
<RefreshControl onRefresh={} refreshing={} />
} dataSource={this.state.ds} renderRow={}>
</ListView>
</View>
//// [jsxAttributeWithoutExpressionReact.js]
React.createElement(View, null,
React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true }));

View File

@@ -0,0 +1,9 @@
//@jsx: react
declare var React: any;
<View>
<ListView refreshControl={
<RefreshControl onRefresh={} refreshing={} />
} dataSource={this.state.ds} renderRow={}>
</ListView>
</View>