2016-12-23 22:31:38 +03:00
|
|
|
exports[`test main.js 1`] = `
|
|
|
|
"// @flow
|
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
var React = require(\'react\');
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
class CustomComponent extends React.Component {
|
|
|
|
props: {
|
|
|
|
prop: string
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
var a: React.Element<{prop: string}> = <CustomComponent prop=\"asdf\" />;
|
|
|
|
var b: React.Element<{prop1: string}> = <CustomComponent prop=\"asdf\" />; // Error: Props<{prop}> ~> Props<{prop1}>
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
// Since intrinsics are typed as \`any\` out of the box, we can pass any
|
|
|
|
// attributes to intrinsics!
|
2016-12-30 19:56:42 +03:00
|
|
|
var c: React.Element<any> = <div not_a_real_attr=\"asdf\" />;
|
|
|
|
// However, we don\'t allow such elements to be viewed as React elements with
|
2016-12-23 22:31:38 +03:00
|
|
|
// different attributes.
|
2016-12-30 19:56:42 +03:00
|
|
|
var d: React.Element<{doesntmatch: string}> = <div not_a_real_attr=\"asdf\" />;
|
2016-12-23 22:31:38 +03:00
|
|
|
// No error as long as expectations are consistent, though.
|
2016-12-30 19:56:42 +03:00
|
|
|
var e: React.Element<{not_a_real_attr: string}> = <div not_a_real_attr=\"asdf\" />;
|
2016-12-23 22:31:38 +03:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2016-12-27 21:29:31 +03:00
|
|
|
// @flow
|
2017-01-10 05:49:06 +03:00
|
|
|
|
|
|
|
var React = require(\"react\");
|
|
|
|
|
|
|
|
class CustomComponent extends React.Component {
|
|
|
|
props: { prop: string };
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: React.Element<{ prop: string }> = <CustomComponent prop=\"asdf\" />;
|
2017-01-26 22:57:43 +03:00
|
|
|
var b: React.Element<{ prop1: string }> = <CustomComponent prop=\"asdf\" />; // Error: Props<{prop}> ~> Props<{prop1}>
|
2016-12-27 21:29:31 +03:00
|
|
|
// Since intrinsics are typed as \`any\` out of the box, we can pass any
|
|
|
|
// attributes to intrinsics!
|
2017-01-10 05:49:06 +03:00
|
|
|
var c: React.Element<any> = <div not_a_real_attr=\"asdf\" />;
|
2016-12-30 19:56:42 +03:00
|
|
|
// However, we don\'t allow such elements to be viewed as React elements with
|
2016-12-27 21:29:31 +03:00
|
|
|
// different attributes.
|
2017-01-10 05:49:06 +03:00
|
|
|
var d: React.Element<{ doesntmatch: string }> = <div not_a_real_attr=\"asdf\" />;
|
2016-12-27 21:29:31 +03:00
|
|
|
// No error as long as expectations are consistent, though.
|
2017-01-12 02:15:12 +03:00
|
|
|
var e: React.Element<{ not_a_real_attr: string }> = (
|
|
|
|
<div not_a_real_attr=\"asdf\" />
|
|
|
|
);
|
2017-01-11 18:16:38 +03:00
|
|
|
"
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`test strings.js 1`] = `
|
|
|
|
"/* @flow */
|
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
var React = require(\'react\');
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
// The builtin $JSXIntrinsics should allow any string
|
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
var Div = \'div\';
|
|
|
|
var Bad = \'bad\';
|
|
|
|
var Str: string = \'str\';
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
<Div />; // This is fine
|
|
|
|
<Bad />; // This is fine
|
|
|
|
<Str />; // This is fine
|
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
React.createElement(\'div\', {}); // This is fine
|
|
|
|
React.createElement(\'bad\', {}); // This is fine
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
<Div id={42} />; // This is fine
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
/* @flow */
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
var React = require(\"react\");
|
2017-01-10 05:49:06 +03:00
|
|
|
|
|
|
|
// The builtin $JSXIntrinsics should allow any string
|
2016-12-30 19:56:42 +03:00
|
|
|
var Div = \"div\";
|
|
|
|
var Bad = \"bad\";
|
|
|
|
var Str: string = \"str\";
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2017-01-26 22:57:43 +03:00
|
|
|
<Div />; /* This is fine*/
|
|
|
|
<Bad />; /* This is fine*/
|
|
|
|
<Str />; // This is fine
|
|
|
|
React.createElement(\"div\", {}); // This is fine
|
|
|
|
React.createElement(\"bad\", {}); /* This is fine*/
|
2017-01-11 18:16:38 +03:00
|
|
|
<Div id={42} />; // This is fine
|
|
|
|
"
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|