prettier/tests/flow/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap

92 lines
2.6 KiB
Plaintext
Raw Normal View History

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`main.js 1`] = `
"// @flow
var React = require('react');
class CustomComponent extends React.Component {
props: {
prop: string
};
}
var a: React.Element<{prop: string}> = <CustomComponent prop=\\"asdf\\" />;
var b: React.Element<{prop1: string}> = <CustomComponent prop=\\"asdf\\" />; // Error: Props<{prop}> ~> Props<{prop1}>
// Since intrinsics are typed as \`any\` out of the box, we can pass any
// attributes to intrinsics!
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
// different attributes.
var d: React.Element<{doesntmatch: string}> = <div not_a_real_attr=\\"asdf\\" />;
// No error as long as expectations are consistent, though.
var e: React.Element<{not_a_real_attr: string}> = <div not_a_real_attr=\\"asdf\\" />;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2016-12-27 21:29:31 +03:00
// @flow
var React = require(\\"react\\");
class CustomComponent extends React.Component {
props: {
prop: string
};
}
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-27 21:29:31 +03:00
// Since intrinsics are typed as \`any\` out of the box, we can pass any
// attributes to intrinsics!
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-27 21:29:31 +03:00
// different attributes.
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.
var e: React.Element<{ not_a_real_attr: string }> = (
<div not_a_real_attr=\\"asdf\\" />
);
2017-01-11 18:16:38 +03:00
"
`;
exports[`strings.js 1`] = `
"/* @flow */
var React = require('react');
// The builtin $JSXIntrinsics should allow any string
var Div = 'div';
var Bad = 'bad';
var Str: string = 'str';
<Div />; // This is fine
<Bad />; // This is fine
<Str />; // This is fine
React.createElement('div', {}); // This is fine
React.createElement('bad', {}); // This is fine
<Div id={42} />; // This is fine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var React = require(\\"react\\");
// The builtin $JSXIntrinsics should allow any string
var Div = \\"div\\";
var Bad = \\"bad\\";
var Str: string = \\"str\\";
<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
"
`;