forked from prettier/prettier
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsfmt.spec.js.snap
84 lines (68 loc) · 2.36 KB
/
jsfmt.spec.js.snap
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
exports[`test 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}>
<div id=\"asdf\" />;
<div id={42} />; // Error: (\`id\` prop) number ~> string
var c: React.Element<{id: string}> = <div id=\"asdf\" />;
var d: React.Element<{id: number}> = <div id=\"asdf\" />; // Error: Props<{id:string}> ~> Props<{id:number}>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @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}>*/
<div id=\"asdf\" />;
<div id={42} />;
// Error: (\`id\` prop) number ~> string
var c: React.Element<{ id: string }> = <div id=\"asdf\" />;
var d: React.Element<{ id: number }> = (
<div id=\"asdf\" />
); // Error: Props<{id:string}> ~> Props<{id:number}>
"
`;
exports[`test strings.js 1`] = `
"/* @flow */
var React = require(\'react\');
var Div = \'div\';
var Bad = \'bad\';
var Str: string = \'str\';
<Div />; // This is fine
<Bad />; // Error: \'bad\' not in JSXIntrinsics
<Str />; // Error: string ~> keys of JSXIntrinsics
React.createElement(\'div\', {}); // This is fine
React.createElement(\'bad\', {}); // Error: \'bad\' not in JSXIntrinsics
React.createElement(Str, {}); // Error: string ~> keys of JSXIntrinsics
// TODO: Make this an error
<Div id={42} />; // Not an error but should be eventually
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var React = require(\"react\");
var Div = \"div\";
var Bad = \"bad\";
var Str: string = \"str\";
<Div />;
/* This is fine*/
<Bad />;
/* Error: \'bad\' not in JSXIntrinsics*/
<Str />;
// Error: string ~> keys of JSXIntrinsics
React.createElement(\"div\", {});
// This is fine
React.createElement(\"bad\", {});
// Error: \'bad\' not in JSXIntrinsics
React.createElement(Str, {});
/* Error: string ~> keys of JSXIntrinsics*/
/* TODO: Make this an error*/
<Div id={42} />; // Not an error but should be eventually
"
`;