Set trailingComma default value to es5 (#6963)

* Set `trailingComma` default value to `es5`

* Update `options` documentation

* Update tests

* style

* fix js code style

* change options order

* update tests_integration snap

* disable es5 for __ng_interpolation

* fix angular tests

* fix scss test

* fix `css_trailing_comma` snap

* fix css_scss snapshot
This commit is contained in:
fisker Cheung authored and Lipis committed 2019-11-18 11:39:12 +01:00
1 parent eac6fba2c3
commit 791996df7b
205 files changed
+2933 -2932

No files matched your search

+4 -4
View File
@@ -97,13 +97,13 @@ Print trailing commas wherever possible when multi-line. (A single-line array, f
Valid options:
- `"none"` - No trailing commas.
- `"es5"` - Trailing commas where valid in ES5 (objects, arrays, etc.)
- `"none"` - No trailing commas.
- `"all"` - Trailing commas wherever possible (including function arguments). This requires node 8 or a [transform](https://babeljs.io/docs/plugins/syntax-trailing-function-commas/).
| Default | CLI Override | API Override |
| -------- | ------------------------------------------------------ | ------------------------------------------------------ |
| `"none"` | <code>--trailing-comma <none&#124;es5&#124;all></code> | <code>trailingComma: "<none&#124;es5&#124;all>"</code> |
| Default | CLI Override | API Override |
| ------- | ------------------------------------------------------ | ------------------------------------------------------ |
| `"es5"` | <code>--trailing-comma <es5&#124;none&#124;all></code> | <code>trailingComma: "<es5&#124;none&#124;all>"</code> |
## Bracket Spacing
+3 -2
View File
@@ -76,16 +76,17 @@ module.exports = {
type: "choice",
default: [
{ since: "0.0.0", value: false },
{ since: "0.19.0", value: "none" }
{ since: "0.19.0", value: "none" },
{ since: "2.0.0", value: "es5" }
],
description: "Print trailing commas wherever possible when multi-line.",
choices: [
{ value: "none", description: "No trailing commas." },
{
value: "es5",
description:
"Trailing commas where valid in ES5 (objects, arrays, etc.)"
},
{ value: "none", description: "No trailing commas." },
{
value: "all",
description:
@@ -4,6 +4,7 @@ exports[`test.component.ts 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
@Component({
@@ -52,7 +53,6 @@ exports[`test.component.ts 2`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
@Component({
@@ -1,2 +1,2 @@
run_spec(__dirname, ["typescript"], { trailingComma: "none" });
run_spec(__dirname, ["typescript"]);
run_spec(__dirname, ["typescript"], { trailingComma: "es5" });
@@ -4,6 +4,7 @@ exports[`logical-expression.ng 1`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
[
@@ -24,7 +25,6 @@ exports[`logical-expression.ng 2`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
[
@@ -66,6 +66,7 @@ exports[`pipe-expression.ng 1`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
[
@@ -132,7 +133,6 @@ exports[`pipe-expression.ng 2`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
[
+1 -1
View File
@@ -1,3 +1,3 @@
run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "none" });
run_spec(__dirname, ["__ng_interpolation"]);
run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "es5" });
run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "all" });
@@ -110,17 +110,17 @@ printWidth: 80
[
[0, 1],
[0, 1],
[0, 1]
[0, 1],
];
[[], [1, 2, 3]];
[[1], [1]];
[
[1, 2],
[1, 2, 3]
[1, 2, 3],
];
[
[1, 0],
[1, 0]
[1, 0],
];
[{}];
[{}, {}];
@@ -138,11 +138,11 @@ printWidth: 80
[{ a, b }, { a }, { a }];
[
{ a, b },
{ a, b }
{ a, b },
];
[
{ a, b },
{ a, b, c }
{ a, b, c },
];
================================================================================
+132 -132
View File
@@ -609,7 +609,7 @@ Seq(typeDef.interface.groups).forEach(group =>
Seq(group.members).forEach((member, memberName) =>
markdownDoc(member.doc, {
typePath: typePath.concat(memberName.slice(1)),
signatures: member.signatures
signatures: member.signatures,
})
)
);
@@ -640,7 +640,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
)
),
})
}
/>
@@ -656,7 +656,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
)
),
})
}
/>
@@ -672,7 +672,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
)
),
})
}
/>
@@ -698,7 +698,7 @@ foo(
({
a,
b
b,
}) => {}
);
@@ -711,7 +711,7 @@ foo(
({
a,
b
b,
}) => {}
);
@@ -719,7 +719,7 @@ foo(
({
a,
b
b,
}) => a
);
@@ -732,8 +732,8 @@ foo(
a: {
a,
b
}
b,
},
}) => {}
);
@@ -743,9 +743,9 @@ foo(
b: {
c,
d
}
}
d,
},
},
}) => {}
);
@@ -756,10 +756,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}) => {}
);
@@ -768,8 +768,8 @@ foo(
a: {
a,
b
}
b,
},
}) => a
);
@@ -779,9 +779,9 @@ foo(
b: {
c,
d
}
}
d,
},
},
}) => a
);
@@ -792,10 +792,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}) => a
);
@@ -807,11 +807,11 @@ foo(
c: {
d,
e
}
}
}
}
e,
},
},
},
},
]) => {}
);
@@ -823,10 +823,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}
]) => {}
);
@@ -839,10 +839,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}
) => {}
);
@@ -853,9 +853,9 @@ foo(
{
a,
b
}
]
b,
},
],
}) => {}
);
@@ -865,8 +865,8 @@ foo(
{
a,
b
}
b,
},
]
) => a
);
@@ -877,9 +877,9 @@ foo(
{
a,
b
}
]
b,
},
],
]) => {}
);
@@ -895,13 +895,13 @@ foo(
d: {
e,
f
}
}
}
]
]
]
f,
},
},
},
],
],
],
]) => {}
);
@@ -910,7 +910,7 @@ foo(
...{
a,
b
b,
}
) => {}
);
@@ -921,8 +921,8 @@ foo(
{
a,
b
}
b,
},
]
) => {}
);
@@ -933,8 +933,8 @@ foo(
{
a,
b
}
b,
},
]
]) => {}
);
@@ -945,8 +945,8 @@ foo(
{
a,
b
}
b,
},
]
) => {}
);
@@ -956,7 +956,7 @@ foo(
a = (({
a,
b
b,
}) => {})()
) => {}
);
@@ -966,7 +966,7 @@ foo(
a = f({
a,
b
b,
})
) => {}
);
@@ -976,7 +976,7 @@ foo(
a = ({
a,
b
b,
}) => {}
) => {}
);
@@ -987,7 +987,7 @@ foo(
f({
a,
b
b,
})
) => {}
);
@@ -1406,7 +1406,7 @@ Seq(typeDef.interface.groups).forEach((group) =>
Seq(group.members).forEach((member, memberName) =>
markdownDoc(member.doc, {
typePath: typePath.concat(memberName.slice(1)),
signatures: member.signatures
signatures: member.signatures,
})
)
);
@@ -1437,7 +1437,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
)
),
})
}
/>
@@ -1453,7 +1453,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
)
),
})
}
/>
@@ -1469,7 +1469,7 @@ function render() {
this.setState({
progress: Math.round(
(100 * e.nativeEvent.loaded) / e.nativeEvent.total
)
),
})
}
/>
@@ -1495,7 +1495,7 @@ foo(
({
a,
b
b,
}) => {}
);
@@ -1508,7 +1508,7 @@ foo(
({
a,
b
b,
}) => {}
);
@@ -1516,7 +1516,7 @@ foo(
({
a,
b
b,
}) => a
);
@@ -1529,8 +1529,8 @@ foo(
a: {
a,
b
}
b,
},
}) => {}
);
@@ -1540,9 +1540,9 @@ foo(
b: {
c,
d
}
}
d,
},
},
}) => {}
);
@@ -1553,10 +1553,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}) => {}
);
@@ -1565,8 +1565,8 @@ foo(
a: {
a,
b
}
b,
},
}) => a
);
@@ -1576,9 +1576,9 @@ foo(
b: {
c,
d
}
}
d,
},
},
}) => a
);
@@ -1589,10 +1589,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}) => a
);
@@ -1604,11 +1604,11 @@ foo(
c: {
d,
e
}
}
}
}
e,
},
},
},
},
]) => {}
);
@@ -1620,10 +1620,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}
]) => {}
);
@@ -1636,10 +1636,10 @@ foo(
c: {
d,
e
}
}
}
e,
},
},
},
}
) => {}
);
@@ -1650,9 +1650,9 @@ foo(
{
a,
b
}
]
b,
},
],
}) => {}
);
@@ -1662,8 +1662,8 @@ foo(
{
a,
b
}
b,
},
]
) => a
);
@@ -1674,9 +1674,9 @@ foo(
{
a,
b
}
]
b,
},
],
]) => {}
);
@@ -1692,13 +1692,13 @@ foo(
d: {
e,
f
}
}
}
]
]
]
f,
},
},
},
],
],
],
]) => {}
);
@@ -1707,7 +1707,7 @@ foo(
...{
a,
b
b,
}
) => {}
);
@@ -1718,8 +1718,8 @@ foo(
{
a,
b
}
b,
},
]
) => {}
);
@@ -1730,8 +1730,8 @@ foo(
{
a,
b
}
b,
},
]
]) => {}
);
@@ -1742,8 +1742,8 @@ foo(
{
a,
b
}
b,
},
]
) => {}
);
@@ -1753,7 +1753,7 @@ foo(
a = (({
a,
b
b,
}) => {})()
) => {}
);
@@ -1763,7 +1763,7 @@ foo(
a = f({
a,
b
b,
})
) => {}
);
@@ -1773,7 +1773,7 @@ foo(
a = ({
a,
b
b,
}) => {}
) => {}
);
@@ -1784,7 +1784,7 @@ foo(
f({
a,
b
b,
})
) => {}
);
@@ -1852,7 +1852,7 @@ export const bem = block =>
".",
css(block),
element ? \`__\${css(element)}\` : "",
modifier ? \`--\${css(modifier)}\` : ""
modifier ? \`--\${css(modifier)}\` : "",
].join("");
<FlatList
@@ -1925,7 +1925,7 @@ export const bem = (block) =>
".",
css(block),
element ? \`__\${css(element)}\` : "",
modifier ? \`--\${css(modifier)}\` : ""
modifier ? \`--\${css(modifier)}\` : "",
].join("");
<FlatList
@@ -2085,7 +2085,7 @@ const foo = () => {
message: "test",
messageType: "SMS",
status: "Unknown",
created: "11/01/2017 13:36"
created: "11/01/2017 13:36",
});
};
@@ -2109,7 +2109,7 @@ const foo = () => {
message: "test",
messageType: "SMS",
status: "Unknown",
created: "11/01/2017 13:36"
created: "11/01/2017 13:36",
});
};
@@ -51,14 +51,14 @@ let {
bottom: offsetBottom,
left: offsetLeft,
right: offsetRight,
top: offsetTop
top: offsetTop,
} = getPressRectOffset == null ? DEFAULT_PRESS_RECT : getPressRectOffset();
const {
accessibilityModule: FooAccessibilityModule,
accessibilityModule: FooAccessibilityModule2,
accessibilityModule: FooAccessibilityModule3,
accessibilityModule: FooAccessibilityModule4
accessibilityModule: FooAccessibilityModule4,
} = foo || {};
({ prop: toAssign = "default" } = { prop: "propval" });
@@ -38,7 +38,7 @@ function f() {
entity.isInstallAvailable() &&
!entity.isQueue() &&
entity.isDisabled() && {
id: entity.id
id: entity.id,
}
);
}
@@ -459,7 +459,7 @@ prevState = prevState || {
loadState: LOADED,
opened: false,
searchQuery: "",
selectedCatalog: null
selectedCatalog: null,
};
prevState = prevState ||
@@ -468,7 +468,7 @@ prevState = prevState ||
loadState: LOADED,
opened: false,
searchQuery: "",
selectedCatalog: null
selectedCatalog: null,
};
prevState =
@@ -478,7 +478,7 @@ prevState =
loadState: LOADED,
opened: false,
searchQuery: "",
selectedCatalog: null
selectedCatalog: null,
});
prevState = prevState ||
@@ -487,14 +487,14 @@ prevState = prevState ||
loadState: LOADED,
opened: false,
searchQuery: "",
selectedCatalog: null
selectedCatalog: null,
};
this.steps = steps || [
{
name: "mock-module",
path: "/nux/mock-module"
}
path: "/nux/mock-module",
},
];
this.steps =
@@ -502,15 +502,15 @@ this.steps =
(checkStep && [
{
name: "mock-module",
path: "/nux/mock-module"
}
path: "/nux/mock-module",
},
]);
this.steps = (steps && checkStep) || [
{
name: "mock-module",
path: "/nux/mock-module"
}
path: "/nux/mock-module",
},
];
const create = () => {
@@ -520,7 +520,7 @@ const create = () => {
result.ok && {
status: "ok",
createdAt: result.createdAt,
updatedAt: result.updatedAt
updatedAt: result.updatedAt,
}
);
};
@@ -531,7 +531,7 @@ const create = () => {
(shouldReturn && result.ok && result) || {
status: "ok",
createdAt: result.createdAt,
updatedAt: result.updatedAt
updatedAt: result.updatedAt,
}
);
};
@@ -540,12 +540,12 @@ const obj = {
state: shouldHaveState &&
stateIsOK && {
loadState: LOADED,
opened: false
opened: false,
},
loadNext: (stateIsOK && hasNext) || {
skipNext: true
skipNext: true,
},
loaded: true
loaded: true,
};
================================================================================
@@ -611,7 +611,7 @@ printWidth: 80
!isJellyfishEnabled &&
diffUpdateMessageInput && {
fontSize: 14,
color: "#fff"
color: "#fff",
}
}
/>;
@@ -189,7 +189,7 @@ function helloWorld() {
props.value,
props.value,
props.value,
props.value
props.value,
]);
}
@@ -210,7 +210,7 @@ function helloWorldWithReact() {
props.value,
props.value,
props.value,
props.value
props.value,
]);
}
@@ -88,7 +88,7 @@ class InMemoryAppender extends log4javascript.Appender
implements ICachedLogMessageProvider {}
class Foo extends Immutable.Record({
ipaddress: ""
ipaddress: "",
}) {
ipaddress: string;
}
@@ -197,7 +197,7 @@ class C {
}
({
name /*comment*/() {}
name /*comment*/() {},
});
================================================================================
@@ -258,7 +258,7 @@ class B {
this.props.foofoofoofoofoofoo && this.props.barbarbarbar;
someInstanceProperty2 = {
foo: this.props.foofoofoofoofoofoo && this.props.barbarbarbar
foo: this.props.foofoofoofoofoofoo && this.props.barbarbarbar,
};
someInstanceProperty3 = "foo";
+24 -24
View File
@@ -37,7 +37,7 @@ const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
let {
d = b //comment
d = b, //comment
} = c;
================================================================================
@@ -61,7 +61,7 @@ const foo = {
a: "a" /* comment for this line */,
/* Section B */
b: "b"
b: "b",
};
================================================================================
@@ -527,20 +527,20 @@ export /* comment */{};
const foo = "";
export {
foo // comment
foo, // comment
};
const bar = "";
export {
// comment
bar
bar,
};
const fooo = "";
const barr = "";
export {
fooo, // comment
barr // comment
barr, // comment
};
================================================================================
@@ -702,7 +702,7 @@ const obj = {
f1 /* f */() {},
f2(/* args */) {},
f3() /* returns */ {},
f4 /* f */(/* args */) /* returns */ {}
f4 /* f */(/* args */) /* returns */ {},
};
(function f /* f */() {})();
@@ -1022,7 +1022,7 @@ function f(
// not one before and one after.
throw new ProcessSystemError({
code: acc.error.code, // Alias of errno
originalError: acc.error // Just in case.
originalError: acc.error, // Just in case.
});
// Adding a comment stops the pretty printing process and everything is
@@ -1030,30 +1030,30 @@ throw new ProcessSystemError({
export type BuckWebSocketMessage =
| {
// Not actually from Buck - this is to let the receiver know that the socket is connected.
type: "SocketConnected"
type: "SocketConnected",
}
| {
type: "BuildProgressUpdated",
progressValue: number
progressValue: number,
}
| {
type: "BuildFinished",
exitCode: number
exitCode: number,
}
| {
type: "BuildStarted"
type: "BuildStarted",
}
| {
type: "ParseStarted"
type: "ParseStarted",
}
| {
type: "ParseFinished"
type: "ParseFinished",
}
| {
type: "RunStarted"
type: "RunStarted",
}
| {
type: "RunComplete"
type: "RunComplete",
};
// Missing one level of indentation because of the comment
@@ -1069,7 +1069,7 @@ const rootEpic = (actions, store) =>
export type AsyncExecuteOptions = child_process$execFileOpts & {
// The contents to write to stdin.
stdin?: ?string,
dontLogInNuclide?: ?boolean
dontLogInNuclide?: ?boolean,
};
// optional trailing comma gets moved all the way to the beginning
@@ -1571,7 +1571,7 @@ var x = {
sectionMetaData: SectionMetaData
/* $FlowFixMe This error was exposed while converting keyMirror
* to keyMirrorRecursive */
): $Enum<SectionMode> {}
): $Enum<SectionMode> {},
};
class X2 {
@@ -2231,7 +2231,7 @@ const CONNECTION_STATUS = (exports.CONNECTION_STATUS = {
CLOSED: Object.freeze({ kind: "CLOSED" }),
CONNECTED: Object.freeze({ kind: "CONNECTED" }),
CONNECTING: Object.freeze({ kind: "CONNECTING" }),
NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" })
NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" }),
});
/* A comment */
@@ -2374,23 +2374,23 @@ const foo3 = 123
let obj1 =
// Comment
{
key: "val"
key: "val",
};
let obj2 =
// Comment
{
key: "val"
key: "val",
};
let obj3 = {
// Comment
key: "val"
key: "val",
};
let obj4 = {
// Comment
key: "val"
key: "val",
};
let obj5 =
@@ -2403,12 +2403,12 @@ let obj6 =
let obj7 = [
// Comment
"val"
"val",
];
let obj8 = [
// Comment
"val"
"val",
];
let obj9 =
@@ -86,7 +86,7 @@ let inlineComment = /* some comment */ someReallyLongFunctionCall(
);
let object = {
key: /* some comment */ someReallyLongFunctionCall(withLots, ofArguments)
key: /* some comment */ someReallyLongFunctionCall(withLots, ofArguments),
};
// preserve parens only for type casts
@@ -138,7 +138,7 @@ const style = /** @type {{
}} */ ({
width,
height,
...margins
...margins,
});
const style2 = /**
@@ -146,7 +146,7 @@ const style2 = /**
* width: number,
* }}
*/ ({
width
width,
});
// Spaces aren't necessary
@@ -2584,29 +2584,20 @@ a {
@include section-type-1(
$header: (
margin: 0 0 $margin-base,
text-align: left
text-align: left,
),
$decoration: (
type: base,
margin: 0 auto -1px 0,
primary-color: $brand-primary,
secondary-color: $gray-light
secondary-color: $gray-light,
),
$title: (
margin: 0 0 $margin-small,
color: false,
font-size: $font-size-h3,
font-weight: false,
line-height: $line-height-h3
)
);
}
a {
@include item-spotlight-properties-transition(
"-title",
(
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15)
line-height: $line-height-h3,
)
);
}
@@ -2616,7 +2607,16 @@ a {
"-title",
(
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15),
border-color: $brand-primary
)
);
}
a {
@include item-spotlight-properties-transition(
"-title",
(
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15),
border-color: $brand-primary,
)
);
}
@@ -2627,7 +2627,7 @@ a {
(
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15),
border-color:
$very-very-very-very-very-very-very-very-very-very-very-very-very-long-value
$very-very-very-very-very-very-very-very-very-very-very-very-very-long-value,
)
);
}
@@ -4,6 +4,7 @@ exports[`import_comma.scss 1`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
@import "rounded-corners", "text-shadow";
@@ -18,7 +19,6 @@ exports[`import_comma.scss 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
@import "rounded-corners", "text-shadow";
@@ -33,6 +33,7 @@ exports[`scss.scss 1`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
@media #{$g-breakpoint-tiny} {}
@@ -2055,7 +2056,6 @@ exports[`scss.scss 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
@media #{$g-breakpoint-tiny} {}
+1 -1
View File
@@ -1,2 +1,2 @@
run_spec(__dirname, ["scss"], { trailingComma: "none" });
run_spec(__dirname, ["scss"]);
run_spec(__dirname, ["scss"], { trailingComma: "es5" });
@@ -4,6 +4,7 @@ exports[`at-rules.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
a {
@@ -79,7 +80,6 @@ exports[`at-rules.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
a {
@@ -155,6 +155,7 @@ exports[`declaration.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
a {
@@ -173,7 +174,6 @@ exports[`declaration.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
a {
@@ -192,6 +192,7 @@ exports[`list.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
$colors: hotpink deepskyblue firebrick,;
@@ -297,7 +298,6 @@ exports[`list.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
$colors: hotpink deepskyblue firebrick,;
@@ -403,6 +403,7 @@ exports[`map.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
$map: (
@@ -447,7 +448,6 @@ exports[`map.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
$map: (
@@ -492,6 +492,7 @@ exports[`selector_list.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
asdasldaskdhjkashdahsdkjahskdjhakjsdkjahsdhkasdhkajsdhakjsdhkajsdhjkahskjdkjahsjkdjkakjsdm,
@@ -523,7 +524,6 @@ exports[`selector_list.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
asdasldaskdhjkashdahsdkjahskdjhakjsdkjahsdhkasdhkajsdhakjsdhkajsdhjkahskjdkjahsjkdjkakjsdm,
@@ -555,6 +555,7 @@ exports[`variable.css 1`] = `
====================================options=====================================
parsers: ["css"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
$test: 1,;
@@ -572,7 +573,6 @@ exports[`variable.css 2`] = `
====================================options=====================================
parsers: ["scss"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
$test: 1,;
+2 -2
View File
@@ -1,2 +1,2 @@
run_spec(__dirname, ["css"]);
run_spec(__dirname, ["scss"], { trailingComma: "es5" });
run_spec(__dirname, ["css"], { trailingComma: "none" });
run_spec(__dirname, ["scss"]);
@@ -68,7 +68,7 @@ export class HeroButtonComponent {
selector: "toh-hero-button",
template: \`
<button>{{ label }}</button>
\`
\`,
})
export class HeroButtonComponent {
@Output() change = new EventEmitter<any>();
@@ -91,7 +91,7 @@ var x = 100;
@Hello({
a: "a", // Comment is in the wrong place
// test
b: "2"
b: "2",
})
class X {}
@@ -103,8 +103,8 @@ class X {}
// App modules.
CoreModule,
SharedModule
]
SharedModule,
],
})
export class AppModule {}
@@ -324,14 +324,14 @@ const dog = {
@readonly
@nonenumerable
@doubledValue
eyes: 2
eyes: 2,
};
const foo = {
@multipleDecorators
@inline
@theyWontAllFitInOneline
aVeryLongPropName: "A very long string as value"
aVeryLongPropName: "A very long string as value",
};
================================================================================
@@ -58,14 +58,14 @@ a = ([s = 1]) => 1;
const { children, ...props } = this.props;
const {
user: { firstName, lastName }
user: { firstName, lastName },
} = this.props;
const {
name: { first, last },
organisation: {
address: { street: orgStreetAddress, postcode: orgPostcode }
}
address: { street: orgStreetAddress, postcode: orgPostcode },
},
} = user;
function f({ data: { name } }) {}
@@ -73,8 +73,8 @@ function f({ data: { name } }) {}
const UserComponent = function({
name: { first, last },
organisation: {
address: { street: orgStreetAddress, postcode: orgPostcode }
}
address: { street: orgStreetAddress, postcode: orgPostcode },
},
}) {
return;
};
@@ -83,7 +83,7 @@ const {
a,
b,
c,
d: { e }
d: { e },
} = someObject;
try {
@@ -96,8 +96,8 @@ try {
// code
} catch ({
data: {
message: { errors }
}
message: { errors },
},
}) {
// code
}
@@ -105,7 +105,7 @@ try {
const obj = {
func(id, { blog: { title } }) {
return id + title;
}
},
};
class A {
+1 -1
View File
@@ -66,7 +66,7 @@ const envSpecific = {
domain: do {
if (env === "production") "https://abc.mno.com/";
else if (env === "development") "http://localhost:4000";
}
},
};
let x = do {
@@ -69,7 +69,7 @@ const obj = {
f(/* ... */) {},
f: (/* ... */) => {},
f: function(/* ... */) {},
f: function f(/* ... */) {}
f: function f(/* ... */) {},
};
class Foo {
@@ -27,7 +27,7 @@ export {
itGo,
multiLine,
andMore,
soWeCanGetItTo80Columns
soWeCanGetItTo80Columns,
};
export { fitsIn, oneLine };
@@ -62,7 +62,7 @@ export {
itGo,
multiLine,
andMore,
soWeCanGetItTo80Columns
soWeCanGetItTo80Columns,
};
export {fitsIn, oneLine};
@@ -23,11 +23,11 @@ export c, { foo } from "mod";
export * as d, { bar } from "mod";
export { fooooooooooooooooooooooooooooooooooooooooooooooooo } from "fooooooooooooooooooooooooooooo";
export Bar, {
barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr,
} from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr";
export {
foooooooooooooooooooooooooooooooooooooooooooooo,
fooooooooooooooooooooooooooooooooooooooooooooooo
fooooooooooooooooooooooooooooooooooooooooooooooo,
} from "fooooooooooooooooooooooooooooo";
================================================================================
@@ -22,7 +22,7 @@ export {
value2 as value2_renamed,
value3,
value4 as value4_renamed,
value5
value5,
} from "exports";
export a, { b } from "./baz";
@@ -80,7 +80,7 @@ var qux = function(str: string, i: number): number {
var obj: { str: string, i: number, j: boolean } = {
str: "...",
i: "...",
k: false
k: false,
};
var arr: Array<number> = [1, 2, "..."];
@@ -90,7 +90,7 @@ var array: number[] = [1, 2, "..."];
var matrix: number[][] = [
[1, 2],
[3, 4]
[3, 4],
];
var matrix_parens: number[][] = matrix;
@@ -101,7 +101,7 @@ var array_of_nullable: (?number)[] = [null, 3];
var array_of_tuple: [number, string][] = [
[0, "foo"],
[1, "bar"]
[1, "bar"],
];
var array_of_tuple_parens: [number, string][] = array_of_tuple;
@@ -127,7 +127,7 @@ function param_anno2(
return {
method: request.method,
params: request.params,
relative_url: request.path
relative_url: request.path,
};
});
// ...
@@ -187,7 +187,7 @@ let tests = [
(x + z: empty); // error, string ~> empty
(z + x: empty); // error, string ~> empty
}
},
];
================================================================================
@@ -365,7 +365,7 @@ let tests = [
function(x: any, y: number, z: string) {
x > y;
x > z;
}
},
];
================================================================================
@@ -111,7 +111,7 @@ function reduce_test() {
var flattened = [
[0, 1],
[2, 3],
[4, 5]
[4, 5],
].reduce(function(a, b) {
return a.concat(b);
});
@@ -81,7 +81,7 @@ var abig2: Array<{ x: number, y: number }> = [
{ x: 0, y: 0, a: true },
{ x: 0, y: 0, b: "hey" },
{ x: 0, y: 0, c: 1 },
{ x: 0, y: 0, c: "hey" }
{ x: 0, y: 0, c: "hey" },
];
module.exports = "arrays";
@@ -559,17 +559,17 @@ var n = new (async function() {
var o = {
async m() {
await 1;
}
},
};
var ot = {
async m<T>(a: T) {
await 1;
}
},
};
var oz = {
async async(async) {
await async;
}
},
};
var x = { await: 5 };
@@ -117,7 +117,7 @@ let tests = [
function(x: Object, y: mixed) {
"foo" in x; // ok
"foo" in y; // error
}
},
];
================================================================================
@@ -20,7 +20,7 @@ function f(x) {
=====================================output=====================================
type F = {
(x: string): number,
p?: string
p?: string,
};
function f(x) {
@@ -76,7 +76,7 @@ icall(0); // error, number ~> string
icall.call(null, 0); // error, number ~> string
type Callable = {
(x: string): void
(x: string): void,
};
declare var callable: Callable;
@@ -132,7 +132,7 @@ module.exports = {
B: B,
C: C,
D: D,
E: E
E: E,
};
================================================================================
@@ -149,7 +149,7 @@ type Foo = {
a: string, // exists in TestClass
b: string, // doesn't exist
c?: ?string, // exists in TestClass, optional
d?: number // doesn't exist
d?: number, // doesn't exist
};
class TestClass {
@@ -142,7 +142,7 @@ var global_o = {
f: function() {},
g: function() {
global_y = 42;
}
},
};
global_o.f();
@@ -163,7 +163,7 @@ function local_meth() {
f: function() {},
g: function() {
local_y = 42;
}
},
};
local_o.f();
@@ -34,19 +34,19 @@ module.exports = { ColorId, ColorNumber };
var ColorId = {
RED: "R",
GREEN: "G",
BLUE: "B"
BLUE: "B",
};
var ColorNumber = {
RED: "ff0000",
GREEN: "00ff00",
BLUE: "0000ff"
BLUE: "0000ff",
};
var ColorIdToNumber = {
[ColorId.RED]: ColorNumber.RED,
[ColorId.GREEN]: ColorNumber.GREEN,
[ColorId.BLUE]: ColorNumber.BLUE
[ColorId.BLUE]: ColorNumber.BLUE,
};
(ColorIdToNumber[ColorId.RED]: "ffffff"); // oops
@@ -80,7 +80,7 @@ var { ColorId, ColorNumber } = require("./test");
var ColorIdToNumber = {
[ColorId.RED]: ColorNumber.RED,
[ColorId.GREEN]: ColorNumber.GREEN,
[ColorId.BLUE]: ColorNumber.BLUE
[ColorId.BLUE]: ColorNumber.BLUE,
};
(ColorIdToNumber[ColorId.GREEN]: "ffffff"); // oops
@@ -144,7 +144,7 @@ var dummy = require("./test");
module.exports = {
...dummy,
[hello]: "world",
...dummy
...dummy,
};
================================================================================
@@ -183,14 +183,14 @@ var obj = {
x: 0,
m() {
return this.x;
}
},
};
var x: string = obj["m"](); // error, number ~> string
var arr = [
function() {
return this.length;
}
},
];
var y: string = arr[0](); // error: number ~> string
@@ -60,7 +60,7 @@ module.exports = {
*/
module.exports = {
numVal: 42
numVal: 42,
};
================================================================================
@@ -78,7 +78,7 @@ module.exports = {
/* @flow */
module.exports = {
numVal: 42
numVal: 42,
};
================================================================================
@@ -37,7 +37,7 @@ Foo.y = 0; // has static property y
Foo.prototype = {
m() {
return 0;
}
},
};
// exporting Foo directly doesn't work
@@ -90,7 +90,7 @@ let tests = [
Boolean(NaN);
Boolean(undefined);
Boolean("");
}
},
];
================================================================================
@@ -166,7 +166,7 @@ let tests = [
function(x: Map<string, number>) {
(x.get("foo"): boolean); // error, string | void
x.get(123); // error, wrong key type
}
},
];
================================================================================
@@ -236,7 +236,7 @@ let tests = [
function() {
RegExp("foo", "z"); // error
new RegExp("foo", "z"); // error
}
},
];
================================================================================
@@ -21,7 +21,7 @@ declare class _C {
foo(): number;
}
declare var _module: {
C: Class<_C>
C: Class<_C>,
};
declare class D extends _module.C {
foo(): string;
@@ -126,7 +126,7 @@ module.exports = {
numberValue2: 2,
numberValue3: 3,
numberValue4: 4,
numberValue5: 5
numberValue5: 5,
};
================================================================================
@@ -484,7 +484,7 @@ declare export {
declare export {
numberValue1,
numberValue2 as numberValue2_renamed
numberValue2 as numberValue2_renamed,
} from "ES6_ExportFrom_Source1";
================================================================================
@@ -514,7 +514,7 @@ declare export {
declare export {
numberValue1,
numberValue2 as numberValue2_renamed2
numberValue2 as numberValue2_renamed2,
} from "ES6_ExportFrom_Source2";
================================================================================
@@ -734,7 +734,7 @@ module.exports = {
*/
module.exports = {
numberValue: 42
numberValue: 42,
};
================================================================================
@@ -1365,7 +1365,7 @@ import { specifierNumber } from "ES6_Named1"; // Error: Did you mean \`specifier
///////////////////////////////////////////////////
import {
numberValue1 as numberValue8,
numberValue2 as numberValue9
numberValue2 as numberValue9,
} from "./ES6_ExportAllFromMulti";
var at1: number = numberValue8;
@@ -69,7 +69,7 @@ declare module "foo" {
declare type Id<T> = T;
declare var exports: {
(a: number, b: number): number
(a: number, b: number): number,
};
}
@@ -201,22 +201,22 @@ obj_rest({ p: { q: 0, r: null } });
function obj_prop_annot(
{
p = true // error: boolean ~> string
p = true, // error: boolean ~> string
}: {
p: string
p: string,
} = {
p: 0 // error: number ~> string
p: 0, // error: number ~> string
}
) {
(p: void); // error: string ~> void
}
var {
p = true // error: boolean ~> string
p = true, // error: boolean ~> string
}: {
p: string
p: string,
} = {
p: 0 // error: number ~> string
p: 0, // error: number ~> string
};
(p: void); // error: string ~> void
@@ -620,7 +620,7 @@ function bar() {
// @flow
var { x } = {
x: { foo: "foo" }
x: { foo: "foo" },
};
function bar() {
@@ -57,7 +57,7 @@ function foo0(
}
function foo2(x: {
[key: string]: number
[key: string]: number,
}): { [key: string]: number, +toString: () => string } {
// x's prototype has a toString method
return x;
@@ -469,7 +469,7 @@ function mix_with_declared_props(o: { [k: number]: X, p: Y }, x: X, y: Y) {
// Indeed, dict types are still Objects and have Object.prototype stuff
function object_prototype(o: {
[k: string]: number
[k: string]: number,
}): { [k: string]: number, +toString: () => string } {
(o.toString(): boolean); // error: string ~> boolean
return o; // ok
@@ -480,7 +480,7 @@ function object_prototype(o: {
// write into a declared prop unsoundly.
function unsound_string_conversion_alias_declared_prop(o: {
[k: number]: any,
"0": X
"0": X,
}) {
o[0] = "not-x"; // a["0"] no longer X
}
@@ -509,19 +509,19 @@ function subtype_dict_values_fresh_exception() {
let a: { [k: string]: A } = {
a: new A(), // ok, A == A
b: new B(), // ok, B <: A
c: new C() // ok, C <: A
c: new C(), // ok, C <: A
};
let b: { [k: string]: B } = {
a: new A(), // error, A not <: B
b: new B(), // ok, B == B
c: new C() // ok, C <: A
c: new C(), // ok, C <: A
};
let c: { [k: string]: C } = {
a: new A(), // error, A not <: C
b: new B(), // error, A not <: C
c: new C() // ok, C == C
c: new C(), // ok, C == C
};
}
@@ -777,7 +777,7 @@ function foo3(x: { [key: string]: number }): { foo: number } {
// error: foo can't exist in x
function foo4(x: {
[key: string]: number
[key: string]: number,
}): { [key: string]: number, foo: string } {
return x;
}
@@ -890,7 +890,7 @@ type QueryFunction = (params: Params) => string;
var o: { foo: QueryFunction } = {
foo(params) {
return params.count; // error, number ~/~ string
}
},
};
module.exports = o;
@@ -105,7 +105,7 @@ export type Pos = {
firstLine: number,
firstColumn: number,
lastLine: number,
lastColumn: number
lastColumn: number,
};
export type TypedBinaryOpNode = {
@@ -115,7 +115,7 @@ export type TypedBinaryOpNode = {
rhs: TypedNode,
pos: Pos,
exprType: InferredType,
typed: true
typed: true,
};
export type TypedUnaryMinusNode = {
@@ -123,7 +123,7 @@ export type TypedUnaryMinusNode = {
op: TypedNode,
pos: Pos,
exprType: InferredType,
typed: true
typed: true,
};
export type TypedNumberNode = {
@@ -131,7 +131,7 @@ export type TypedNumberNode = {
value: number,
pos: Pos,
exprType: "number",
typed: true
typed: true,
};
export type TypedStringLiteralNode = {
@@ -139,7 +139,7 @@ export type TypedStringLiteralNode = {
value: string,
pos: Pos,
exprType: "string",
typed: true
typed: true,
};
export type TypedVariableNode = {
@@ -147,7 +147,7 @@ export type TypedVariableNode = {
name: string,
pos: Pos,
exprType: InferredType,
typed: true
typed: true,
};
export type TypedFunctionInvocationNode = {
@@ -156,7 +156,7 @@ export type TypedFunctionInvocationNode = {
parameters: TypedNode[],
pos: Pos,
exprType: "error" | "string",
typed: true
typed: true,
};
export type TypedNode =
@@ -961,18 +961,18 @@ export type Comment = {
loc: ?SourceLocation,
value: string,
leading: boolean,
trailing: boolean
trailing: boolean,
};
export type SourceLocation = {
start: SourcePosition,
end: SourcePosition,
source: ?string
source: ?string,
};
export type SourcePosition = {
line: number,
column: number
column: number,
};
export type File = {
@@ -981,7 +981,7 @@ export type File = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "File",
program: Program
program: Program,
};
export type Program = {
@@ -990,7 +990,7 @@ export type Program = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "Program",
body: Statement[]
body: Statement[],
};
export type BinaryOperator =
@@ -1098,7 +1098,7 @@ export type EmptyStatement = {
start: SourcePosition,
end: SourcePosition,
comments: ?Array<Comment>,
type: "EmptyStatement"
type: "EmptyStatement",
};
export type BlockStatement = {
@@ -1107,7 +1107,7 @@ export type BlockStatement = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "BlockStatement",
body: Statement[]
body: Statement[],
};
export type ExpressionStatement = {
@@ -1116,7 +1116,7 @@ export type ExpressionStatement = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "ExpressionStatement",
expression: Expression
expression: Expression,
};
export type IfStatement = {
@@ -1127,7 +1127,7 @@ export type IfStatement = {
type: "IfStatement",
test: Expression,
consequent: Statement,
alternate: ?Statement
alternate: ?Statement,
};
export type BreakStatement = {
@@ -1136,7 +1136,7 @@ export type BreakStatement = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "BreakStatement",
label: ?Identifier
label: ?Identifier,
};
export type ContinueStatement = {
@@ -1145,7 +1145,7 @@ export type ContinueStatement = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "ContinueStatement",
label: ?Identifier
label: ?Identifier,
};
export type ReturnStatement = {
@@ -1154,7 +1154,7 @@ export type ReturnStatement = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "ReturnStatement",
argument: ?Expression
argument: ?Expression,
};
export type ThrowStatement = {
@@ -1163,7 +1163,7 @@ export type ThrowStatement = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "ThrowStatement",
argument: ?Expression
argument: ?Expression,
};
export type WhileStatement = {
@@ -1173,7 +1173,7 @@ export type WhileStatement = {
comments: ?Array<Comment>,
type: "WhileStatement",
test: Expression,
body: Statement
body: Statement,
};
export type ForStatement = {
@@ -1185,7 +1185,7 @@ export type ForStatement = {
init: ?(VariableDeclaration | Expression),
test: ?Expression,
update: ?Expression,
body: Statement
body: Statement,
};
export type ForInStatement = {
@@ -1196,7 +1196,7 @@ export type ForInStatement = {
type: "ForInStatement",
left: VariableDeclaration | Expression,
right: Expression,
body: Statement
body: Statement,
};
export type TryStatement = {
@@ -1208,7 +1208,7 @@ export type TryStatement = {
block: BlockStatement,
handler: ?CatchClause,
handlers: CatchClause[],
finalizer: ?BlockStatement
finalizer: ?BlockStatement,
};
export type CatchClause = {
@@ -1219,7 +1219,7 @@ export type CatchClause = {
type: "CatchClause",
param: Pattern,
guard: ?Expression,
body: BlockStatement
body: BlockStatement,
};
export type Expression =
@@ -1245,7 +1245,7 @@ export type Identifier = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "Identifier",
name: string
name: string,
};
export type Literal = {
@@ -1255,7 +1255,7 @@ export type Literal = {
comments: ?Array<Comment>,
type: "Literal",
value: ?(string | boolean | number | RegExp),
regex: ?{ pattern: string, flags: string }
regex: ?{ pattern: string, flags: string },
};
export type ThisExpression = {
@@ -1263,7 +1263,7 @@ export type ThisExpression = {
start: SourcePosition,
end: SourcePosition,
comments: ?Array<Comment>,
type: "ThisExpression"
type: "ThisExpression",
};
export type ArrayExpression = {
@@ -1272,7 +1272,7 @@ export type ArrayExpression = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "ArrayExpression",
elements: Expression[]
elements: Expression[],
};
export type ObjectExpreession = {
@@ -1281,7 +1281,7 @@ export type ObjectExpreession = {
end: SourcePosition,
comments: ?Array<Comment>,
type: "ObjectExpression",
properties: Property[]
properties: Property[],
};
export type Property = {
@@ -1292,7 +1292,7 @@ export type Property = {
type: "Property",
kind: "init" | "get" | "set",
key: Literal | Identifier,
value: Expression
value: Expression,
};
export type FunctionExpression = {
@@ -1303,7 +1303,7 @@ export type FunctionExpression = {
type: "FunctionExpression",
id: ?Identifier,
params: Pattern[],
body: BlockStatement
body: BlockStatement,
};
export type BinaryExpression = {
@@ -1314,7 +1314,7 @@ export type BinaryExpression = {
type: "BinaryExpression",
operator: BinaryOperator,
left: Expression,
right: Expression
right: Expression,
};
export type UnaryExpression = {
@@ -1325,7 +1325,7 @@ export type UnaryExpression = {
type: "UnaryExpression",
operator: UnaryOperator,
argument: Expression,
prefix: boolean
prefix: boolean,
};
export type AssignmentExpression = {
@@ -1336,7 +1336,7 @@ export type AssignmentExpression = {
type: "AssignmentExpression",
operator: AssignmentOperator,
left: Pattern,
right: Expression
right: Expression,
};
export type UpdateExpression = {
@@ -1347,7 +1347,7 @@ export type UpdateExpression = {
type: "UpdateExpression",
operator: UpdateOperator,
argument: Expression,
prefix: boolean
prefix: boolean,
};
export type LogicalExpression = {
@@ -1358,7 +1358,7 @@ export type LogicalExpression = {
type: "LogicalExpression",
operator: LogicalOperator,
left: Expression,
right: Expression
right: Expression,
};
export type ConditionalExpression = {
@@ -1369,7 +1369,7 @@ export type ConditionalExpression = {
type: "ConditionalExpression",
test: Expression,
consequent: Expression,
alternate: Expression
alternate: Expression,
};
export type NewExpression = {
@@ -1379,7 +1379,7 @@ export type NewExpression = {
comments: ?Array<Comment>,
type: "NewExpression",
callee: Expression,
arguments: Expression[]
arguments: Expression[],
};
export type CallExpression = {
@@ -1389,7 +1389,7 @@ export type CallExpression = {
comments: ?Array<Comment>,
type: "CallExpression",
callee: Expression,
arguments: Expression[]
arguments: Expression[],
};
export type MemberExpression = {
@@ -1400,7 +1400,7 @@ export type MemberExpression = {
type: "MemberExpression",
object: Expression,
property: Identifier | Expression,
computed: boolean
computed: boolean,
};
// ast-types exports all expressions as patterns.
// That seems not like it was intended.
@@ -1415,7 +1415,7 @@ export type VariableDeclaration = {
comments: ?Array<Comment>,
type: "VariableDeclaration",
kind: "var" | "let" | "const",
declarations: VariableDeclarator[]
declarations: VariableDeclarator[],
};
export type FunctionDeclaration = {
@@ -1426,7 +1426,7 @@ export type FunctionDeclaration = {
type: "FunctionDeclaration",
id: Identifier,
body: BlockStatement,
params: Pattern[]
params: Pattern[],
};
export type VariableDeclarator = {
@@ -1436,7 +1436,7 @@ export type VariableDeclarator = {
comments: ?Array<Comment>,
type: "VariableDeclarator",
id: Pattern,
init: ?Expression
init: ?Expression,
};
const a: any = null;
@@ -1541,7 +1541,7 @@ export const builders: {
body: BlockStatement,
params: Pattern[]
): FunctionDeclaration,
variableDeclarator(id: Pattern, init?: Expression): VariableDeclarator
variableDeclarator(id: Pattern, init?: Expression): VariableDeclarator,
} = a;
================================================================================
+22 -22
View File
@@ -32,7 +32,7 @@ let tests = [
// moveTo
function(ctx: CanvasRenderingContext2D) {
ctx.moveTo("0", "1"); // error: should be numbers
}
},
];
================================================================================
@@ -62,7 +62,7 @@ let tests = [
function(document: Document) {
const event = document.createEvent("CustomEvent");
event.initCustomEvent("butts", true, false, { nice: 42 });
}
},
];
================================================================================
@@ -100,7 +100,7 @@ let tests = [
(document.createElement("select"): HTMLSelectElement);
(document.querySelector("select"): HTMLSelectElement | null);
(document.createElement("hr"): HTMLElement); // GH #3752
}
},
];
================================================================================
@@ -148,7 +148,7 @@ let tests = [
element.scrollIntoView({ behavior: "invalid" });
element.scrollIntoView({ block: "invalid" });
element.scrollIntoView(1);
}
},
];
================================================================================
@@ -176,7 +176,7 @@ let tests = [
// getContext
function(el: HTMLCanvasElement) {
(el.getContext("2d"): ?CanvasRenderingContext2D);
}
},
];
================================================================================
@@ -224,7 +224,7 @@ let tests = [
element.scrollIntoView({ behavior: "invalid" });
element.scrollIntoView({ block: "invalid" });
element.scrollIntoView(1);
}
},
];
================================================================================
@@ -260,7 +260,7 @@ let tests = [
el.setRangeText("foo", 123, 234);
el.setRangeText("foo", 123, 234, "select");
el.setRangeText("foo", 123, 234, "bogus"); // invalid value
}
},
];
================================================================================
@@ -374,7 +374,7 @@ let tests = [
window.onmessage = (event: MessageEvent) => {
(event.target: window);
};
}
},
];
================================================================================
@@ -408,7 +408,7 @@ let tests = [
(path.arcTo(0, 0, 0, 0, 10): void); // valid
(path.arcTo(0, 0, 0, 0, 10, 20, 5): void); // valid
(path.arcTo(0, 0, 0, 0, 10, "20", 5): void); // invalid
}
},
];
================================================================================
@@ -496,9 +496,9 @@ let tests = [
oldAttributeValue,
newAttributeValue,
attributeNamespace
) {}
}
})
) {},
},
}),
});
},
// or with Object.assign()
@@ -513,8 +513,8 @@ let tests = [
oldAttributeValue,
newAttributeValue,
attributeNamespace
) {}
})
) {},
}),
});
},
// should complain about invalid callback parameters
@@ -526,10 +526,10 @@ let tests = [
oldVal: string, // Error: This might be null
newVal: string, // Error: This might be null
namespace: string
) {}
}
) {},
},
});
}
},
];
================================================================================
@@ -930,10 +930,10 @@ let tests = [
); // valid
document.createNodeIterator(document.body, -1, node => "accept"); // invalid
document.createNodeIterator(document.body, -1, {
acceptNode: node => NodeFilter.FILTER_ACCEPT
acceptNode: node => NodeFilter.FILTER_ACCEPT,
}); // valid
document.createNodeIterator(document.body, -1, {
acceptNode: node => "accept"
acceptNode: node => "accept",
}); // invalid
document.createNodeIterator(document.body, -1, {}); // invalid
},
@@ -945,13 +945,13 @@ let tests = [
); // valid
document.createTreeWalker(document.body, -1, node => "accept"); // invalid
document.createTreeWalker(document.body, -1, {
acceptNode: node => NodeFilter.FILTER_ACCEPT
acceptNode: node => NodeFilter.FILTER_ACCEPT,
}); // valid
document.createTreeWalker(document.body, -1, {
acceptNode: node => "accept"
acceptNode: node => "accept",
}); // invalid
document.createTreeWalker(document.body, -1, {}); // invalid
}
},
];
================================================================================
@@ -40,8 +40,8 @@ function isActive(ad: {
state: $Keys<{
PAUSED: string,
ACTIVE: string,
DELETED: string
}>
DELETED: string,
}>,
}): boolean {
return ad.state === "ACTIVE";
}
@@ -50,7 +50,7 @@ isActive({ state: "PAUSE" });
var MyStates = {
PAUSED: "PAUSED",
ACTIVE: "ACTIVE",
DELETED: "DELETED"
DELETED: "DELETED",
};
function isActive2(ad: { state: $Keys<typeof MyStates> }): boolean {
return ad.state === MyStates.ACTIVE;
@@ -118,7 +118,7 @@ module.exports = Object.freeze({
*/
module.exports = Object.freeze({
numberValue1: 1
numberValue1: 1,
});
================================================================================
@@ -154,7 +154,7 @@ module.exports = {
numberValue2: 2,
numberValue3: 3,
numberValue4: 4,
numberValue5: 5
numberValue5: 5,
};
================================================================================
@@ -578,7 +578,7 @@ export {
export {
numberValue1,
numberValue2 as numberValue2_renamed
numberValue2 as numberValue2_renamed,
} from "ES6_ExportFrom_Source1";
================================================================================
@@ -608,7 +608,7 @@ export {
export {
numberValue1,
numberValue2 as numberValue2_renamed2
numberValue2 as numberValue2_renamed2,
} from "ES6_ExportFrom_Source2";
================================================================================
@@ -858,7 +858,7 @@ module.exports = {
*/
module.exports = {
numberValue: 42
numberValue: 42,
};
================================================================================
@@ -1518,7 +1518,7 @@ import { specifierNumber } from "ES6_Named1"; // Error: Did you mean \`specifier
///////////////////////////////////////////////////
import {
numberValue1 as numberValue8,
numberValue2 as numberValue9
numberValue2 as numberValue9,
} from "./ES6_ExportAllFromMulti";
var at1: number = numberValue8;
@@ -38,7 +38,7 @@ declare module "CJS_Clobbered" {
declare var num2: number;
declare type numType = number;
declare var exports: {
numExport: number
numExport: number,
};
}
@@ -72,7 +72,7 @@ import type {
inlinedType1,
standaloneType1,
talias1,
talias3
talias3,
} from "./types_only";
var a: inlinedType1 = 42;
@@ -78,7 +78,7 @@ let tests = [
(copyProperties(result, { foo: "a" }, { bar: 123 }): {
foo: string,
bar: number,
baz: boolean
baz: boolean,
});
},
@@ -100,7 +100,7 @@ let tests = [
function(copyProperties: Object$Assign) {
function x(cb: Function) {}
x(copyProperties);
}
},
];
================================================================================
@@ -140,7 +140,7 @@ let tests = [
let x: ?string = null;
invariant(x);
(x: string);
}
},
];
================================================================================
@@ -254,7 +254,7 @@ let tests = [
function(mergeInto: $Facebookism$MergeInto) {
function x(cb: Function) {}
x(mergeInto);
}
},
];
================================================================================
@@ -47,10 +47,10 @@ const b: Promise<string> = fetch(myRequest); // incorrect
var myInit = {
method: "GET",
headers: {
"Content-Type": "image/jpeg"
"Content-Type": "image/jpeg",
},
mode: "cors",
cache: "default"
cache: "default",
};
const c: Promise<Blob> = fetch("image.png").then(response => response.blob()); // correct
@@ -221,10 +221,10 @@ new Request(new URL("http://example.org")); // correct
const h: Request = new Request("http://example.org", {
method: "GET",
headers: {
"Content-Type": "image/jpeg"
"Content-Type": "image/jpeg",
},
mode: "cors",
cache: "default"
cache: "default",
}); // correct
var bodyUsed: boolean = h.bodyUsed;
@@ -237,34 +237,34 @@ h.arrayBuffer().then((ab: Buffer) => ab); // incorrect
const i: Request = new Request("http://example.org", {
method: "POST",
headers: {
"Content-Type": "application/octet-stream"
"Content-Type": "application/octet-stream",
},
body: new ArrayBuffer(10)
body: new ArrayBuffer(10),
}); // correct
const j: Request = new Request("http://example.org", {
method: "POST",
headers: {
"Content-Type": "application/octet-stream"
"Content-Type": "application/octet-stream",
},
body: new Uint8Array(10)
body: new Uint8Array(10),
}); // correct
const k: Request = new Request("http://example.org", {
method: "POST",
headers: {
"Content-Type": "image/jpeg"
"Content-Type": "image/jpeg",
},
body: new URLSearchParams("key=value"),
mode: "cors",
cache: "default"
cache: "default",
}); // correct
const l: Request = new Request("http://example.org", {
method: "GET",
headers: "Content-Type: image/jpeg",
mode: "cors",
cache: "default"
cache: "default",
}); // incorrect - headers is string
new Request("/", { method: "post" }); // correct
@@ -338,28 +338,28 @@ new Response("", { status: null }); // incorrect
const f: Response = new Response("responsebody", {
status: 404,
headers: "'Content-Type': 'image/jpeg'"
headers: "'Content-Type': 'image/jpeg'",
}); // incorrect
const g: Response = new Response("responsebody", {
status: 404,
headers: {
"Content-Type": "image/jpeg"
}
"Content-Type": "image/jpeg",
},
}); // correct
const h: Response = new Response("responsebody", {
status: 404,
headers: new Headers({
"Content-Type": "image/jpeg"
})
"Content-Type": "image/jpeg",
}),
}); // correct, if verbose
const i: Response = new Response({
status: 404,
headers: new Headers({
"Content-Type": "image/jpeg"
})
"Content-Type": "image/jpeg",
}),
}); // incorrect
const ok: boolean = h.ok;
@@ -173,7 +173,7 @@ let tests = [
function(x: { (a: string, b: string): void, bind(a: string): void }) {
(x.bind("foo"): void); // ok
(x.bind(123): void); // error, number !~> string
}
},
];
================================================================================
@@ -411,7 +411,7 @@ let tests = [
// Non-(Function.prototype) properties on a \`Function\` type should be \`any\`
(z.foo: number);
(z.foo: string);
}
},
];
// \`Function\` types can be bound (resulting in a \`Function\` type)
@@ -106,7 +106,7 @@ module.exports = {
bar: function(): number {
return 42;
}
},
};
================================================================================
@@ -20,7 +20,7 @@ type $JSXIntrinsic<T> = Class<$React.Component<void, T, mixed>>;
type $JSXIntrinsics = {
div: $JSXIntrinsic<{ id: string }>,
span: $JSXIntrinsic<{ id: string, class: string }>
span: $JSXIntrinsic<{ id: string, class: string }>,
};
================================================================================
@@ -54,13 +54,13 @@ var f = {
get ["d"]() {
return "foo";
},
set ["d"](x: number) {}
set ["d"](x: number) {},
};
type T = {
get a(): number,
set b(x: number): void,
c: 10
c: 10,
};
declare class Foo {
@@ -379,7 +379,7 @@ var obj = {
set [z](x: string) {},
get [z](): string {
return string;
}
},
};
// Test getting properties with getters
@@ -499,7 +499,7 @@ type T = {
set exampleOfOrderOfGetterAndSetter(x: B): void,
set exampleOfOrderOfGetterAndSetterReordered(x: B): void,
get exampleOfOrderOfGetterAndSetterReordered(): A
get exampleOfOrderOfGetterAndSetterReordered(): A,
};
function test(obj: T) {
@@ -569,8 +569,8 @@ const Example = React.createClass({
set b(x: number) {
this.c = x;
},
c: React.PropTypes.string
}
c: React.PropTypes.string,
},
});
<Example />; // error: property \`a\` not found
@@ -155,13 +155,13 @@ export function givesAFoo3Obj(): AliasFoo3 {
*/
export type AliasFoo3 = {
givesANum(): number
givesANum(): number,
};
export function givesAFoo3Obj(): AliasFoo3 {
return {
givesANum(): number {
return 42;
}
},
};
}
@@ -175,13 +175,13 @@ export function givesAFoo3Obj(): AliasFoo3 {
*/
export type AliasFoo3 = {
givesANum(): number
givesANum(): number,
};
export function givesAFoo3Obj(): AliasFoo3 {
return {
givesANum(): number {
return 42;
}
},
};
}
@@ -114,9 +114,9 @@ let tests = [
function() {
({}: {
[k1: string]: string,
[k2: number]: number // error: not supported (yet)
[k2: number]: number, // error: not supported (yet)
});
}
},
];
================================================================================
@@ -103,7 +103,7 @@ type DuplexStreamOptions = ReadableStreamOptions &
WritableStreamOptions & {
allowHalfOpen?: boolean,
readableObjectMode?: boolean,
writableObjectMode?: boolean
writableObjectMode?: boolean,
};
function hasObjectMode_bad(options: DuplexStreamOptions): boolean {
@@ -55,13 +55,13 @@ type ObjAssignT = { foo: string } & { bar: string };
type ReadableStreamOptions = {
highWaterMark?: number,
encoding?: ?string,
objectMode?: boolean
objectMode?: boolean,
};
type WritableStreamOptions = {
highWaterMark?: number,
decodeString?: boolean,
objectMode?: boolean
objectMode?: boolean,
};
// used in test_fun.js
@@ -171,7 +171,7 @@ function makeIterator(coin_flip: () => boolean): Iterator<string> {
} else {
return { done };
}
}
},
};
}
@@ -188,7 +188,7 @@ function makeIterator(coin_flip: () => boolean): Iterator<string> {
} else {
return { done }; // Error void ~> string
}
}
},
};
}
@@ -35,7 +35,7 @@ var React = require("react");
class CustomComponent extends React.Component {
props: {
prop: string
prop: string,
};
}
@@ -31,7 +31,7 @@ var React = require("react");
class CustomComponent extends React.Component {
props: {
prop: string
prop: string,
};
}
@@ -20,7 +20,7 @@ type $JSXIntrinsic<T> = Class<$React.Component<void, T, mixed>>;
type $JSXIntrinsics = {
div: $JSXIntrinsic<{ id: string }>,
span: $JSXIntrinsic<{ id: string, class: string }>
span: $JSXIntrinsic<{ id: string, class: string }>,
};
================================================================================
@@ -20,7 +20,7 @@ let tests = [
let tests = [
function(x: { [key: number]: string }) {
(x[""]: number);
}
},
];
================================================================================
@@ -97,7 +97,7 @@ const o = {
qux: 42,
qux(): string {
return "hello";
} // last wins
}, // last wins
};
// check
@@ -16,7 +16,7 @@ module.exports = APIKeys;
=====================================output=====================================
var APIKeys = {
AGE: "age",
NAME: "name"
NAME: "name",
};
module.exports = APIKeys;
@@ -916,7 +916,7 @@ function logical13(x: number): Array<{ x: string }> {
{ x: 1 && "bar" },
{ x: "foo" && "bar" },
{ x: "foo" && "bar" },
{ x: "foo" && "bar" }
{ x: "foo" && "bar" },
];
}
@@ -932,7 +932,7 @@ function logical14(x: number): Array<{ x: string }> {
{ x: 0 || "bar" },
{ x: "foo" || "bar" },
{ x: "foo" || "bar" },
{ x: "foo" || "bar" }
{ x: "foo" || "bar" },
];
}
@@ -121,24 +121,24 @@ var Foo = {
b: function(arg) {
// missing arg annotation
return {
bar: arg
bar: arg,
};
},
c: function(arg: string) {
// no return annotation required
return {
bar: arg
bar: arg,
};
},
d: function(
arg: string
): {
bar: string
bar: string,
} {
return {
bar: arg
bar: arg,
};
},
@@ -158,7 +158,7 @@ var Foo = {
// no error
return x;
};
}
},
};
var Bar = {
@@ -170,7 +170,7 @@ var Bar = {
c: Foo.c("bar"), // no annotation required
d: Foo.d("bar") // no annotation required
d: Foo.d("bar"), // no annotation required
};
(module.exports = Foo), Bar;
@@ -116,7 +116,7 @@ var App = React.createClass({
{foo(z, x)} // error, since z: number
</div>
);
}
},
});
module.exports = App;
@@ -156,7 +156,7 @@ var React = require("react");
* react classes as initialized, when the class was created with createClass().
* This would manifest as complaining that metric requires an annotation */
var App = React.createClass({
metrics: [1, 2, 3]
metrics: [1, 2, 3],
});
module.exports = App;
@@ -296,14 +296,14 @@ var React = require("React");
var C = React.createClass({
propTypes: {
title: React.PropTypes.string.isRequired
}
title: React.PropTypes.string.isRequired,
},
});
var D = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
...C.propTypes
}
...C.propTypes,
},
});
<D />; // errors: properties \`name\` and \`title\` not found
@@ -68,7 +68,7 @@ var FeedUFI = React.createClass({
className: "",
key: "",
feedback: { feedback },
permalink: ""
permalink: "",
};
var ignored = <UFILikeCount {...props} />;
return (
@@ -78,7 +78,7 @@ var FeedUFI = React.createClass({
render: function(): ?React.Element<any> {
return <div />;
}
},
});
module.exports = FeedUFI;
@@ -100,7 +100,7 @@ module.exports = {
=====================================output=====================================
/* @providesModule Mixin */
module.exports = {
success: function() {}
success: function() {},
};
================================================================================
@@ -151,12 +151,12 @@ var React = require("react");
var UFILikeCount = React.createClass({
propTypes: {
permalink: React.PropTypes.string,
feedback: React.PropTypes.object.isRequired
feedback: React.PropTypes.object.isRequired,
},
render: function(): ?React.Element<any> {
return <div />;
}
},
});
module.exports = UFILikeCount;
@@ -377,7 +377,7 @@ var FooLegacy = React.createClass({
is_mounted: (undefined: ?boolean),
propTypes: {
x: React.PropTypes.number.isRequired
x: React.PropTypes.number.isRequired,
},
getDefaultProps(): DefaultProps {
@@ -385,7 +385,7 @@ var FooLegacy = React.createClass({
},
statics: {
bar(): void {}
bar(): void {},
},
qux(): void {
@@ -404,7 +404,7 @@ var FooLegacy = React.createClass({
componentWillReceiveProps(nextProps: Object, nextContext: any): void {
this.qux();
}
},
});
FooLegacy.defaultProps = 0;
@@ -512,7 +512,7 @@ var C = React.createClass({
propTypes: {
x: React.PropTypes.string.isRequired,
y: React.PropTypes.array,
z: React.PropTypes.number
z: React.PropTypes.number,
},
replaceProps(props: {}) {},
@@ -531,7 +531,7 @@ var C = React.createClass({
var len: number = this.props.x.length;
this.success();
return <div />;
}
},
});
var element = <C x={0} />;
@@ -579,17 +579,17 @@ var C = React.createClass({
statistics: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
value: PropTypes.number
value: PropTypes.number,
})
).isRequired
}
).isRequired,
},
});
<C statistics={[{}, { label: "", value: undefined }]} />; // error (label is required, value not required)
var props: Array<{ label: string, value?: number }> = [
{},
{ label: "", value: undefined }
{ label: "", value: undefined },
]; // error (same as ^)
================================================================================
@@ -634,7 +634,7 @@ var React = require("react");
var TestProps = React.createClass({
propTypes: {
x: React.PropTypes.string,
z: React.PropTypes.number
z: React.PropTypes.number,
},
getDefaultProps: function() {
@@ -645,7 +645,7 @@ var TestProps = React.createClass({
var a: number = this.props.x; // error
var b: string = this.props.y; // error
var c: string = this.props.z; // error
}
},
});
var element = <TestProps x={false} y={false} z={false} />; // 3 errors
@@ -653,7 +653,7 @@ var element = <TestProps x={false} y={false} z={false} />; // 3 errors
(element: $jsx<*>);
(element: $jsx<TestProps>);
var FooProps = React.createClass({
propTypes: { w: React.PropTypes.string.isRequired }
propTypes: { w: React.PropTypes.string.isRequired },
});
(element: $jsx<FooProps>);
@@ -689,8 +689,8 @@ var React = require("react");
var C = React.createClass({
propTypes: {
foo: React.PropTypes.string.isRequired,
bar: React.PropTypes.string.isRequired
}
bar: React.PropTypes.string.isRequired,
},
});
var D = React.createClass({
getInitialState: function(): { bar: number } {
@@ -700,7 +700,7 @@ var D = React.createClass({
var obj = { bar: 0 };
var s: string = this.state.bar;
return <C {...this.state} foo={0} />;
}
},
});
================================================================================
@@ -800,25 +800,25 @@ var TestProps = React.createClass({
oneOf_rec: React.PropTypes.oneOf(["yes", "no"]).isRequired,
oneOfType: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
React.PropTypes.number,
]),
oneOfType_rec: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
React.PropTypes.number,
]).isRequired,
shape: React.PropTypes.shape({
foo: React.PropTypes.string,
bar: React.PropTypes.number
bar: React.PropTypes.number,
}),
shape_rec: React.PropTypes.shape({
foo: React.PropTypes.string,
bar: React.PropTypes.number
bar: React.PropTypes.number,
}).isRequired,
// And do something bad here
bad_one: React.PropTypes.imaginaryType,
bad_two: React.PropTypes.string.inRequired
}
bad_two: React.PropTypes.string.inRequired,
},
});
================================================================================
@@ -865,7 +865,7 @@ import React from "React";
class JDiv extends React.Component {
// static defaultProps: { };
props: {
id: string
id: string,
};
}
@@ -907,7 +907,7 @@ var React = require("React");
var C = React.createClass({
getDefaultProps: function() {
return { x: 0 };
}
},
});
module.exports = C;
@@ -951,7 +951,7 @@ var ReactClass = React.createClass({
var React = require("react");
type State = {
bar: ?{ qux: string }
bar: ?{ qux: string },
};
var ReactClass = React.createClass({
@@ -963,7 +963,7 @@ var ReactClass = React.createClass({
// Any state access here seems to make state any
this.state;
return <div>{this.state.bar.qux}</div>;
}
},
});
================================================================================
@@ -999,15 +999,15 @@ module.exports = Comp;
var React = require("react");
type FooState = {
key: ?Object
key: ?Object,
};
var Comp = React.createClass({
getInitialState: function(): FooState {
return {
key: null // this used to cause a missing annotation error
key: null, // this used to cause a missing annotation error
};
}
},
});
module.exports = Comp;
@@ -1045,7 +1045,7 @@ var React = require("react");
var TestState = React.createClass({
getInitialState: function(): { x: string } {
return {
x: ""
x: "",
};
},
@@ -1053,9 +1053,9 @@ var TestState = React.createClass({
var a: number = this.state.x; // error
this.setState({
x: false // error
x: false, // error
});
}
},
});
================================================================================
@@ -1092,7 +1092,7 @@ var C = React.createClass({
render() {
this.setState({ y: 0 });
return <div>{this.state.z}</div>;
}
},
});
================================================================================
@@ -85,7 +85,7 @@ let tests = [
(hmac.digest(): Buffer);
(hmac.digest("hex"): void); // 1 error
(hmac.digest(): void); // 1 error
}
},
];
================================================================================
@@ -16,7 +16,7 @@ module.exports = {
// @flow
module.exports = {
foo: 123
foo: 123,
};
================================================================================
@@ -68,7 +68,7 @@ module.exports = id(
const id = require("./id");
export type ObjectType = {
+m: () => void
+m: () => void,
};
function methodCaller(x: ObjectType) {
@@ -113,11 +113,11 @@ function f() {
var a = {
p: 0,
f
f,
};
var b = {
f
f,
};
a.f(); // okey-dokie
@@ -89,7 +89,7 @@ var export_ = Object.assign(
{
foo: function(param) {
return param;
}
},
}
);
@@ -179,7 +179,7 @@ let tests = [
function() {
const x = new Bar();
(Object.getPrototypeOf(x): Foo);
}
},
];
================================================================================
@@ -281,7 +281,7 @@ let tests = [
let tests = [
function() {
Object.doesNotExist();
}
},
];
================================================================================
@@ -474,7 +474,7 @@ var c = {
foo: "bar",
toString: function(): number {
return 123;
}
},
};
var d: { [key: string]: string } = { foo: "bar" };
var x = new Date();
@@ -44,7 +44,7 @@ var EventEmitter = require("events").EventEmitter;
var Bad = Object.assign({}, EventEmitter.prototype, {
foo: function(): string {
return "hi";
}
},
});
// Calling Bad.foo() in the same file doesn't error
@@ -55,14 +55,14 @@ class MyEventEmitter extends events$EventEmitter {}
var Good = Object.assign({}, MyEventEmitter.prototype, {
foo: function(): string {
return "hi";
}
},
});
// Calling Good.foo() in the same file doesn't error
var good: number = Good.foo();
module.exports = {
Bad: Bad,
Good: Good
Good: Good,
};
================================================================================
@@ -129,7 +129,7 @@ printWidth: 80
(Object.assign.apply(null, [{}, { a: 1 }, { b: "foo" }]): {
a: number,
b: string
b: string,
});
================================================================================
@@ -193,7 +193,7 @@ declare var tup: [{ foo: string }, { bar: number }];
(Object.assign({}, ...[{ a: 1 }, { b: "foo" }], ...[{ c: true }]): {
a: number,
b: true,
c: boolean
c: boolean,
}); // Error: 'foo' => true
================================================================================
@@ -232,11 +232,11 @@ class MyReactThing extends React.Component {
var React = require("react");
type DefaultProps = {
foo: number
foo: number,
};
type Props = {
foo: number
foo: number,
};
class MyReactThing extends React.Component {
@@ -64,7 +64,7 @@ let tests = [
function(x: { x: { -foo: string } }, y: { x: { -foo: number } }) {
x = y; // 2 errors: string !~> number; number !~> string
}
},
];
================================================================================
@@ -31,7 +31,7 @@ declare function keyMirror<O>(o: O): $ObjMapi<O, <K>(k: K) => K>;
var o = keyMirror({
FOO: null,
BAR: null
BAR: null,
});
(o.FOO: "FOO"); // ok
@@ -39,7 +39,7 @@ var o = keyMirror({
promiseAllByKey({
foo: Promise.resolve(0),
bar: "bar"
bar: "bar",
}).then(o => {
(o.foo: string); // error, number ~> string
(o.bar: "bar"); // ok
@@ -28,7 +28,7 @@ var y = 5 / x;
var z: {
type: number,
y: string
y: string,
} = { type: 1, y: "hey" };
================================================================================
@@ -124,7 +124,7 @@ declare type Box<T> = {
map2<U>(f: (x: T) => U): Box<U>,
map3<U>(f: (x: T) => U): Box<U>,
map4<U>(f: (x: T) => U): Box<U>,
map5<U>(f: (x: T) => U): Box<U>
map5<U>(f: (x: T) => U): Box<U>,
};
declare var bool: Box<boolean>;
@@ -174,11 +174,11 @@ function bar<S>(foo: Foo<S>, y: S): Foo<S> {
}
var P = {
bar: bar
bar: bar,
};
declare var Q: {
bar<S>(foo: Foo<S>, y: S): Foo<S>
bar<S>(foo: Foo<S>, y: S): Foo<S>,
};
var foo = new Foo(0);
@@ -285,11 +285,11 @@ function f(_this: { m: ?Meeting }): string {
type Meeting = {
organizer: ?Invitee,
es: Array<Invitee>
es: Array<Invitee>,
};
type Invitee = {
fbid: number
fbid: number,
};
function f(_this: { m: ?Meeting }): string {
@@ -55,7 +55,7 @@ declare var pnum: Promise<number>;
Promise.all([
pstr,
pnum,
true // non-Promise values passed through
true, // non-Promise values passed through
]).then(xs => {
// tuple information is preserved
let [a, b, c] = xs;
+122 -122
View File
@@ -26,7 +26,7 @@ var React = require("react");
var AudienceInsightsContainer = React.createClass({
renderComponent(AudienceInsights: ReactClass<*>) {
return <AudienceInsights />;
}
},
});
module.exports = AudienceInsightsContainer;
@@ -224,7 +224,7 @@ const A = React.createClass({
m() {
(this.props.foo: empty); // error: string ~> empty
(this.props.bar: empty); // error: number ~> empty
}
},
});
const B = React.createClass({
@@ -234,7 +234,7 @@ const B = React.createClass({
},
mm() {
this.m.apply(null); // OK: this.m is autobound, so \`this.p\` will always be found
}
},
});
const C = React.createClass({
@@ -243,7 +243,7 @@ const C = React.createClass({
},
m() {
this.state.foo; // OK: state is unknown
}
},
});
const D = React.createClass({
@@ -251,15 +251,15 @@ const D = React.createClass({
{
getInitialState(): Object {
return { foo: 0 };
}
}
},
},
],
getInitialState() {
return { bar: 0 };
},
m() {
this.state.foo; // OK: state is unknown (due to unknown mixin)
}
},
});
const E = React.createClass({
@@ -270,7 +270,7 @@ const E = React.createClass({
mm() {
var props: { m(): void } = { m: this.m };
props.m(); // OK: this.m is autobound, so \`this.foo\` will always be found
}
},
});
const F = React.createClass({
@@ -280,7 +280,7 @@ const F = React.createClass({
m() {
this.state.foo;
this.state.bar;
}
},
});
const G = React.createClass({
@@ -291,7 +291,7 @@ const G = React.createClass({
(this.mixins: mixed); // error: property \`mixins\` not found
(this.autobind: mixed); // error: property \`autobind\` not found
(this.statics: mixed); // error: property \`statics\` not found
}
},
});
const H = React.createClass({
@@ -299,14 +299,14 @@ const H = React.createClass({
getDefaultProps() {
(this.q: empty); // error: number ~> empty
return {};
}
},
});
const I = React.createClass({
propTypes: ({}: { [string]: any }),
m() {
(this.props.foo: empty); // OK
}
},
});
const J = React.createClass({
@@ -314,22 +314,22 @@ const J = React.createClass({
{
getInitialState() {
return this.constructor.calculateState();
}
}
},
},
],
statics: {
calculateState() {
return { foo: 0 };
}
},
},
m() {
(this.state.foo: empty); // number ~> empty
}
},
});
const K = React.createClass({
propTypes: {
foo: React.PropTypes.string.isRequired
foo: React.PropTypes.string.isRequired,
},
getInitialState() {
this.mm(); // cause error in mm below
@@ -341,12 +341,12 @@ const K = React.createClass({
},
mm() {
this.state.foo; // error: property fo not found (called by getInitialState)
}
},
});
const L = React.createClass({
propTypes: {
foo: React.PropTypes.string.isRequired
foo: React.PropTypes.string.isRequired,
},
getInitialState() {
return { bar: 0 };
@@ -389,7 +389,7 @@ const L = React.createClass({
(this.props.foo: empty); // string ~> empty
(this.state.bar: empty); // number ~> empty
return 0; // number ~> void
}
},
});
React.createClass({}); // error: spec must be [x] exact and [ ] sealed
@@ -501,7 +501,7 @@ React.createClass({
},
g() {
(this.state.q: empty); // number ~> empty
}
},
});
// initial state = Some (exact & sealed) [lit]
@@ -514,7 +514,7 @@ React.createClass({
},
g() {
(this.state.q: empty); // number ~> empty
}
},
});
// initial state = Some (exact & sealed) [annot]
@@ -527,7 +527,7 @@ React.createClass({
},
g() {
(this.state.q: empty); // number ~> empty
}
},
});
// initial state = Some (inexact & sealed) [annot]
@@ -540,7 +540,7 @@ React.createClass({
},
g() {
(this.state.q: empty); // property \`q\` not found
}
},
});
// mixins = (exact & sealed) + (exact & sealed)
@@ -549,8 +549,8 @@ React.createClass({
{
getInitialState() {
return { foo: 0 };
}
}
},
},
],
getInitialState() {
return { bar: 0 };
@@ -560,7 +560,7 @@ React.createClass({
},
g() {
(this.state.baz: empty); // number ~> empty
}
},
});
// mixins = (exact & sealed) + (inexact & sealed)
@@ -569,8 +569,8 @@ React.createClass({
{
getInitialState(): { foo: number } {
return { foo: 0 };
}
}
},
},
],
getInitialState() {
return { bar: 0 };
@@ -580,7 +580,7 @@ React.createClass({
},
g() {
(this.state.baz: empty); // property \`baz\` not found
}
},
});
================================================================================
@@ -657,7 +657,7 @@ A.bar = 0;
// statics = Some (exact & sealed) [lit]
const B = React.createClass({
statics: { foo: 0 }
statics: { foo: 0 },
});
(B.foo: empty); // number ~> empty
(B.bar: empty); // number ~> empty (inflow below)
@@ -665,7 +665,7 @@ B.bar = 0;
// statics = Some (exact & sealed) [annot]
const C = React.createClass({
statics: ({ foo: 0 }: {| foo: number |})
statics: ({ foo: 0 }: {| foo: number |}),
});
(C.foo: empty); // number ~> empty
(C.bar: empty); // number ~> empty (inflow below)
@@ -673,7 +673,7 @@ C.bar = 0;
// statics = Some (inexact & sealed) [annot]
const D = React.createClass({
statics: ({ foo: 0 }: { foo: number })
statics: ({ foo: 0 }: { foo: number }),
});
(D.foo: empty); // number ~> empty
(D.bar: empty); // property \`bar\` not found
@@ -683,10 +683,10 @@ D.bar = 0; // property \`bar\` not found
const E = React.createClass({
mixins: [
{
statics: { foo: 0 }
}
statics: { foo: 0 },
},
],
statics: { bar: 0 }
statics: { bar: 0 },
});
(E.foo: empty); // number ~> empty
(E.bar: empty); // number ~> empty
@@ -697,10 +697,10 @@ E.baz = 0;
const F = React.createClass({
mixins: [
{
statics: ({ foo: 0 }: { foo: number })
}
statics: ({ foo: 0 }: { foo: number }),
},
],
statics: { bar: 0 }
statics: { bar: 0 },
});
(F.foo: empty); // number ~> empty
(F.bar: empty); // number ~> empty
@@ -779,7 +779,7 @@ import React from "react";
class Bar extends React.Component {
props: {
test: number
test: number,
};
render() {
return <div>{this.props.test}</div>;
@@ -846,8 +846,8 @@ var blah = <Foo {...props} />; // error bar, number given string expected
var React = require("react");
var Foo = React.createClass({
propTypes: {
bar: React.PropTypes.string.isRequired
}
bar: React.PropTypes.string.isRequired,
},
});
var props = { bar: 42 };
@@ -887,8 +887,8 @@ const React = require("react");
var AnyExample = React.createClass({
propTypes: {
foo: (0: any) // OK
}
foo: (0: any), // OK
},
});
<AnyExample />; // OK
@@ -896,8 +896,8 @@ var AnyExample = React.createClass({
var AnyFunExample = React.createClass({
propTypes: {
foo: (() => {}: Function) // OK
}
foo: (() => {}: Function), // OK
},
});
<AnyFunExample />; // OK
@@ -964,8 +964,8 @@ var InvalidExample = React.createClass({
var React = require("react");
var Example = React.createClass({
propTypes: {
arr: React.PropTypes.arrayOf(React.PropTypes.number).isRequired
}
arr: React.PropTypes.arrayOf(React.PropTypes.number).isRequired,
},
});
var ok_empty = <Example arr={[]} />;
@@ -982,8 +982,8 @@ var todo_required = <Example arr={[null]} />;
var OptionalExample = React.createClass({
propTypes: {
arr: React.PropTypes.arrayOf(React.PropTypes.number)
}
arr: React.PropTypes.arrayOf(React.PropTypes.number),
},
});
<OptionalExample />; // OK
@@ -992,8 +992,8 @@ var OptionalExample = React.createClass({
var AnyExample = React.createClass({
propTypes: {
arr: React.PropTypes.arrayOf((0: any)) // OK
}
arr: React.PropTypes.arrayOf((0: any)), // OK
},
});
<AnyExample arr={0} />; // error: still needs to be an array
@@ -1001,8 +1001,8 @@ var AnyExample = React.createClass({
var InvalidExample = React.createClass({
propTypes: {
arr: React.PropTypes.arrayOf(0) // error: number not a prop type
}
arr: React.PropTypes.arrayOf(0), // error: number not a prop type
},
});
================================================================================
@@ -1045,8 +1045,8 @@ var Example = React.createClass({
(componentName: empty); // error: componentName is a string
(href: empty); // error: href is an optional string
return (0: mixed); // error: should return ?Error
}
}
},
},
});
// Inferred prop type is optional \`any\`
@@ -1083,8 +1083,8 @@ var fail_mistyped = <Example func={2} />
var React = require("react");
var Example = React.createClass({
propTypes: {
func: React.PropTypes.func.isRequired
}
func: React.PropTypes.func.isRequired,
},
});
var ok_void = <Example func={() => {}} />;
@@ -1118,8 +1118,8 @@ const React = require("react");
var Example = React.createClass({
propTypes: {
foo: 0 // error: \`0\` is not a prop type
}
foo: 0, // error: \`0\` is not a prop type
},
});
<Example />; // OK: don't cascade errors
@@ -1186,8 +1186,8 @@ class C extends B {}
var React = require("react");
var Example = React.createClass({
propTypes: {
x: React.PropTypes.instanceOf(B)
}
x: React.PropTypes.instanceOf(B),
},
});
<Example x={new A()} />; // error: A ~> B
@@ -1200,11 +1200,11 @@ class Poly<T> {
}
var PolyExample = React.createClass({
propTypes: {
x: React.PropTypes.instanceOf(Poly).isRequired
x: React.PropTypes.instanceOf(Poly).isRequired,
},
m() {
(this.props.x.x: empty); // OK, T instantiated to \`any\`
}
},
});
// Different instantiations don't interact
@@ -1216,11 +1216,11 @@ class PolyDefault<T = string> {
}
var PolyDefaultExample = React.createClass({
propTypes: {
x: React.PropTypes.instanceOf(PolyDefault).isRequired
x: React.PropTypes.instanceOf(PolyDefault).isRequired,
},
m() {
(this.props.x.x: empty); // OK, T instantiated to \`any\`
}
},
});
================================================================================
@@ -1296,7 +1296,7 @@ var Foo = React.createClass({
render() {
// But this never errored
return <div id={this.props.name} />;
}
},
});
================================================================================
@@ -1328,8 +1328,8 @@ var fail_mistyped = <Example object={2} />
var React = require("react");
var Example = React.createClass({
propTypes: {
object: React.PropTypes.object.isRequired
}
object: React.PropTypes.object.isRequired,
},
});
var ok_empty = <Example object={{}} />;
@@ -1398,8 +1398,8 @@ var InvalidExample = React.createClass({
var React = require("react");
var Example = React.createClass({
propTypes: {
obj: React.PropTypes.objectOf(React.PropTypes.number).isRequired
}
obj: React.PropTypes.objectOf(React.PropTypes.number).isRequired,
},
});
var ok_empty = <Example obj={{}} />;
@@ -1416,8 +1416,8 @@ var todo_required = <Example obj={{ p: null }} />;
var OptionalExample = React.createClass({
propTypes: {
obj: React.PropTypes.objectOf(React.PropTypes.number)
}
obj: React.PropTypes.objectOf(React.PropTypes.number),
},
});
<OptionalExample />; // OK
@@ -1426,8 +1426,8 @@ var OptionalExample = React.createClass({
var AnyExample = React.createClass({
propTypes: {
obj: React.PropTypes.objectOf((0: any)) // OK
}
obj: React.PropTypes.objectOf((0: any)), // OK
},
});
<AnyExample obj={0} />; // error: still needs to be an object
@@ -1435,8 +1435,8 @@ var AnyExample = React.createClass({
var InvalidExample = React.createClass({
propTypes: {
obj: React.PropTypes.objectOf(0) // error: number not a prop type
}
obj: React.PropTypes.objectOf(0), // error: number not a prop type
},
});
================================================================================
@@ -1545,8 +1545,8 @@ var Example = React.createClass({
str: React.PropTypes.oneOf(["foo", "bar"]),
num: React.PropTypes.oneOf([0, 1, 2]),
bool: React.PropTypes.oneOf([true]),
mixed: React.PropTypes.oneOf(["foo", 0, true])
}
mixed: React.PropTypes.oneOf(["foo", 0, true]),
},
});
<Example str="foo" />; // OK
@@ -1564,64 +1564,64 @@ var Example = React.createClass({
var RequiredExample = React.createClass({
propTypes: {
p: React.PropTypes.oneOf([]).isRequired
}
p: React.PropTypes.oneOf([]).isRequired,
},
});
<RequiredExample />; // error: \`p\` not found
var EmptyExample = React.createClass({
propTypes: {
nil: React.PropTypes.oneOf([]) // i.e., \`empty\`
}
nil: React.PropTypes.oneOf([]), // i.e., \`empty\`
},
});
<EmptyExample nil={0} />; // number ~> empty
var AnyArrayExample = React.createClass({
propTypes: {
any: React.PropTypes.oneOf((0: any))
}
any: React.PropTypes.oneOf((0: any)),
},
});
<AnyArrayExample any={0} />; // OK
var AnyElemExample = React.createClass({
propTypes: {
any: React.PropTypes.oneOf(["foo", (0: any)])
}
any: React.PropTypes.oneOf(["foo", (0: any)]),
},
});
<AnyElemExample any={0} />; // OK
var DynamicArrayExample = React.createClass({
propTypes: {
dyn: React.PropTypes.oneOf(([]: Array<string>))
}
dyn: React.PropTypes.oneOf(([]: Array<string>)),
},
});
<DynamicArrayExample dyn={0} />; // OK
var DynamicElemExample = React.createClass({
propTypes: {
dyn: React.PropTypes.oneOf(["foo", ("": string)])
}
dyn: React.PropTypes.oneOf(["foo", ("": string)]),
},
});
<DynamicElemExample dyn={0} />; // OK
var InvalidArrayExample = React.createClass({
propTypes: {
p: React.PropTypes.oneOf(0) // error: expected array, got 0
}
p: React.PropTypes.oneOf(0), // error: expected array, got 0
},
});
<InvalidArrayExample p={0} />; // OK, don't cascade errors
var NonLiteralElemExample = React.createClass({
propTypes: {
p: React.PropTypes.oneOf([{}]) // OK: allow non-literals
}
p: React.PropTypes.oneOf([{}]), // OK: allow non-literals
},
});
<NonLiteralElemExample p={0} />; // OK, result is unknown/any
@@ -1746,8 +1746,8 @@ var Example = React.createClass({
propTypes: {
prop: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]).isRequired
React.PropTypes.number,
]).isRequired,
},
render() {
if (typeof this.props.prop === "string") {
@@ -1755,7 +1755,7 @@ var Example = React.createClass({
} else {
return <div>{this.props.prop.toFixed(2)}</div>;
}
}
},
});
var ok_number = <Example prop={42} />;
@@ -1771,8 +1771,8 @@ var todo_required = <Example prop={null} />;
var OptionalExample = React.createClass({
propTypes: {
p: React.PropTypes.oneOfType([React.PropTypes.string])
}
p: React.PropTypes.oneOfType([React.PropTypes.string]),
},
});
<OptionalExample />; // OK
@@ -1781,32 +1781,32 @@ var OptionalExample = React.createClass({
var EmptyExample = React.createClass({
propTypes: {
nil: React.PropTypes.oneOfType([]) // i.e., \`empty\`
}
nil: React.PropTypes.oneOfType([]), // i.e., \`empty\`
},
});
<EmptyExample nil={0} />; // number ~> empty
var AnyArrayExample = React.createClass({
propTypes: {
any: React.PropTypes.oneOfType((0: any))
}
any: React.PropTypes.oneOfType((0: any)),
},
});
<AnyArrayExample any={0} />; // OK
var AnyElemExample = React.createClass({
propTypes: {
any: React.PropTypes.oneOfType([React.PropTypes.string, (0: any)])
}
any: React.PropTypes.oneOfType([React.PropTypes.string, (0: any)]),
},
});
<AnyElemExample any={0} />; // OK
var DynamicArrayExample = React.createClass({
propTypes: {
dyn: React.PropTypes.oneOfType(([]: Array<Function>))
}
dyn: React.PropTypes.oneOfType(([]: Array<Function>)),
},
});
<DynamicArrayExample dyn={0} />; // OK
@@ -1815,25 +1815,25 @@ var DynamicElemExample = React.createClass({
propTypes: {
dyn: React.PropTypes.oneOfType([
React.PropTypes.string,
(() => {}: Function)
])
}
(() => {}: Function),
]),
},
});
<DynamicElemExample dyn={0} />; // OK
var InvalidArrayExample = React.createClass({
propTypes: {
p: React.PropTypes.oneOfType(0) // error: expected array, got 0
}
p: React.PropTypes.oneOfType(0), // error: expected array, got 0
},
});
<InvalidArrayExample p={0} />; // OK, don't cascade errors
var InvalidElemExample = React.createClass({
propTypes: {
p: React.PropTypes.oneOfType([{}]) // error: expected prop type, got {}
}
p: React.PropTypes.oneOfType([{}]), // error: expected prop type, got {}
},
});
<InvalidElemExample p={0} />; // OK, don't cascade errors
@@ -1898,8 +1898,8 @@ import React from "react";
React.createClass({
propTypes: {
foo: React.PropTypes.shape({
bar: React.PropTypes.string.isRequired
}).isRequired
bar: React.PropTypes.string.isRequired,
}).isRequired,
},
f() {
@@ -1908,16 +1908,16 @@ React.createClass({
g() {
this.props.foo.baz = 0;
}
},
});
React.createClass({
propTypes: {
foo: React.PropTypes.shape(({}: { [string]: any })).isRequired
foo: React.PropTypes.shape(({}: { [string]: any })).isRequired,
},
f() {
(this.props.foo.bar: empty); // OK
}
},
});
================================================================================
@@ -2034,7 +2034,7 @@ import React from "react";
React.createClass({
propTypes: {
foo: React.PropTypes.string.isRequired
foo: React.PropTypes.string.isRequired,
},
f() {
@@ -2043,7 +2043,7 @@ React.createClass({
g() {
this.props.baz = 0;
}
},
});
================================================================================
@@ -40,12 +40,12 @@ var Hello = require("./createclass-module");
var HelloLocal = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired
name: React.PropTypes.string.isRequired,
},
render: function(): React.Element<*> {
return <div>{this.props.name}</div>;
}
},
});
var Callsite = React.createClass({
@@ -56,7 +56,7 @@ var Callsite = React.createClass({
<HelloLocal />
</div>
);
}
},
});
module.exports = Callsite;
@@ -91,12 +91,12 @@ var React = require("react");
var Hello = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired
name: React.PropTypes.string.isRequired,
},
render: function(): React.Element<*> {
return <div>{this.props.name}</div>;
}
},
});
module.exports = Hello;
@@ -145,7 +145,7 @@ import Hello from "./es6class-proptypes-module";
class HelloLocal extends React.Component<void, { name: string }, void> {
defaultProps = {};
propTypes = {
name: React.PropTypes.string.isRequired
name: React.PropTypes.string.isRequired,
};
render(): React.Element<*> {
return <div>{this.props.name}</div>;
@@ -197,7 +197,7 @@ import React from "react";
class Hello extends React.Component<void, { name: string }, void> {
defaultProps = {};
propTypes = {
name: React.PropTypes.string.isRequired
name: React.PropTypes.string.isRequired,
};
render(): React.Element<*> {
@@ -44,14 +44,14 @@ function bar2<X>(y: F<any>): F<X> {
}
type Functor<A> = {
map<B>(f: (val: A) => B): Functor<B>
map<B>(f: (val: A) => B): Functor<B>,
};
function identity<A>(val: A): Functor<A> {
return {
map<B>(f: (_: typeof val) => B): Functor<B> {
return identity(f(val));
}
},
};
}
@@ -79,7 +79,7 @@ function id(x: Task<any,any>): Task<any,any> { return x; }
type Task<error, value> = {
chain<tagged>(
next: (input: value) => Task<error, tagged>
): Task<error, tagged>
): Task<error, tagged>,
};
function id(x: Task<any, any>): Task<any, any> {
@@ -26,7 +26,7 @@ type LibK = {
=====================================output=====================================
type LibK = {
p: string
p: string,
};
================================================================================
@@ -35,7 +35,7 @@ var o3: {[key: AnyKey]: number} = { foo: 0 };
type Key1 = "foo" | "bar"; // make an enum type with known key set
var o1: { [key: Key1]: number } = {
foo: 0,
bar: "" // error: string ~/~ number
bar: "", // error: string ~/~ number
};
o1.foo; // OK
o1.qux; // error: qux not found
@@ -135,7 +135,7 @@ var tests = [
function() {
var y: string = x || ""; // ok
}
},
];
================================================================================
@@ -625,7 +625,7 @@ var tests = [
var { p } = x; // TODO: annot checked against type of x
(p: string); // ok
}
}
},
];
================================================================================
@@ -890,7 +890,7 @@ var paths = [
x = "xxx";
}
var y: string = x;
}
},
];
================================================================================
@@ -1158,7 +1158,7 @@ var null_tests = [
} else {
var y: string | void = x.p.q; // ok
}
}
},
];
// this.p op null
@@ -1586,7 +1586,7 @@ var null_tests = [
} else {
var y: string = x.p.q; // ok
}
}
},
];
// typeof this.p op typename
@@ -1754,7 +1754,7 @@ var undef_tests = [
} else {
var y: string = x.p.q; // ok
}
}
},
];
// this.p op undefined
@@ -1912,7 +1912,7 @@ var void_tests = [
} else {
var y: string = x.p.q; // ok
}
}
},
];
// this.p op void(...)
@@ -51,7 +51,7 @@ function foo(x: ?number) {
type Bar = {
parent: ?Bar,
doStuff: () => void
doStuff: () => void,
};
function bar0(x: Bar) {
@@ -99,12 +99,12 @@ export type ASTNode = Node1 | Node2;
=====================================output=====================================
type Node1 = {
kind: "Node1",
prop1?: string
prop1?: string,
};
type Node2 = {
kind: "Node2",
prop2?: string
prop2?: string,
};
export type ASTNode = Node1 | Node2;
@@ -210,7 +210,7 @@ let tests = [
return x.result;
}
return x.result; // error
}
},
];
================================================================================
@@ -246,7 +246,7 @@ function testLiteralProperty(a: A) {
// @flow
type A = {
b_c: ?string
b_c: ?string,
};
function stuff(str: string) {}
@@ -374,7 +374,7 @@ let tests = [
(t.quux: string); // error, consider { foo: {}, bar: "" }
}
}
}
},
];
================================================================================
@@ -457,7 +457,7 @@ let tests = [
} // error
if (x.y === 123) {
} // ok
}
},
];
================================================================================
@@ -535,7 +535,7 @@ let tests = [
// incorrectly.
x.y.indexOf(z()); // no error
}
}
},
];
================================================================================
@@ -927,7 +927,7 @@ function foo8(o: { p: mixed }) {
}
type Foo9Expected = {
foo: string
foo: string,
};
function foo9() {
@@ -1319,7 +1319,7 @@ let tests = [
},
function(x: TestClass) {
(!x: false); // ok, classes are always truthy
}
},
];
================================================================================
@@ -1605,7 +1605,7 @@ let tests = [
} else {
return x; // no error, inferred to be 0
}
}
},
];
================================================================================
@@ -2234,7 +2234,7 @@ let tests = [
return x;
}
return "foo";
}
},
];
================================================================================
@@ -2998,7 +2998,7 @@ let tests = [
(x.y: string);
x.z; // error
}
}
},
];
================================================================================
@@ -3041,12 +3041,12 @@ import { SUCCESS, ERROR } from "./constants";
type Success = {
type: typeof SUCCESS,
message: string
message: string,
};
type Error = {
type: typeof ERROR,
error: string
error: string,
};
function handleStatus(status: Success | Error) {
@@ -56,7 +56,7 @@ exports = {stringValue: ''};
// value will affect the exports object but re-binding it makes it useless and
// does not affect the exports value.
module.exports = {
numberValue: 42
numberValue: 42,
};
exports = { stringValue: "" };
@@ -24,7 +24,7 @@ module.exports = {
module.exports = {
numberValueA: 1,
stringValueA: "someString"
stringValueA: "someString",
};
================================================================================
@@ -54,7 +54,7 @@ module.exports = {
module.exports = {
numberValueB: 1,
stringValueB: "someString"
stringValueB: "someString",
};
================================================================================
@@ -70,7 +70,7 @@ o.x = "...";
Foo.prototype = {
m: function() {
return false;
}
},
};
var export_o: { x: any } = o; // awkward type cast
@@ -47,7 +47,7 @@ var s6: string = o6.y; // ok (indexers make object types extensible)
var o7: { x: number, y?: string } = ({ x: 0, y: 0 }: {
x: number,
[_: any]: number
[_: any]: number,
}); // error
================================================================================
@@ -34,7 +34,7 @@ var y: $Shape<Foo> = x;
=====================================output=====================================
type Foo = {
field: number
field: number,
};
var x: { field?: number } = {};
@@ -52,14 +52,14 @@ function parseGroup(
counter: number,
begin: number,
end: number,
text: string
text: string,
} {
var counter = parseCounter(lines[0]);
var timeframe = parseTimeframe(lines[1]);
return {
counter,
...timeframe,
text: lines[2]
text: lines[2],
};
}
@@ -67,7 +67,7 @@ function parseTimeframe(line: string): { begin: number, end: number } {
var timestamps = line.split("-->");
return {
begin: parseTimestamp(timestamps[0].trim()),
end: parseTimestamp(timestamps[1].trim())
end: parseTimestamp(timestamps[1].trim()),
};
}
@@ -134,7 +134,7 @@ var q = { z: "" };
var o = {
x: 5,
...p,
...q
...q,
};
var y: number = o.y;
var z: number = o.z;
@@ -143,7 +143,7 @@ var z: number = o.z;
var r = { y: 123 };
var s = {
...p,
...r
...r,
};
var t: boolean = s.y; // error, string or number
@@ -224,7 +224,7 @@ function test(
(value: string); // OK
return {
...x,
kind: value
kind: value,
};
});
}
@@ -261,20 +261,20 @@ for (var i = 0; i < 10; i++) {
=====================================output=====================================
var o = {
foo: "bar"
foo: "bar",
};
o = { ...o };
(o: { foo: string });
var p = {
foo: "bar"
foo: "bar",
};
(p: { foo: string, abc: string }); // error, p doesn't have \`abc\` yet
p = { ...p, abc: "def" };
(p: { foo: string, abc: string });
var q = {
foo: "bar"
foo: "bar",
};
for (var i = 0; i < 10; i++) {
q = { ...q };
@@ -306,7 +306,7 @@ let tests = [
function(x: Object) {
({ ...x }: Object);
({ ...x }: void); // error, Object
}
},
];
================================================================================
Loaded 100 of 205 files, more files were not shown because too many files have changed in this diff. Show more