Add option to include spaces inside object/array literals, default to false
This commit is contained in:
1 parent
98fef67b4e
commit
8326963f2d
44 files changed
+181
-253
No files matched your search
+3
-1
@@ -5,18 +5,20 @@ const minimist = require("minimist");
|
||||
const jscodefmt = require("../index");
|
||||
|
||||
const argv = minimist(process.argv.slice(2), {
|
||||
boolean: ["write", "useFlowParser"]
|
||||
boolean: ["write", "useFlowParser", "bracket-spacing"]
|
||||
});
|
||||
|
||||
const filename = argv["_"][0];
|
||||
const printWidth = argv['print-width'] || 80;
|
||||
const tabWidth = argv['tab-width'] || 2;
|
||||
const useFlowParser = argv['flow-parser'];
|
||||
const bracketSpacing = argv['bracket-spacing'];
|
||||
const write = argv['write'];
|
||||
|
||||
const output = jscodefmt.format(fs.readFileSync(filename, "utf8"), {
|
||||
printWidth,
|
||||
tabWidth,
|
||||
bracketSpacing,
|
||||
useFlowParser
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ var babylonOptions = {
|
||||
|
||||
module.exports = {
|
||||
format: function(text, opts={}) {
|
||||
let { tabWidth = 2, printWidth = 80 } = opts;
|
||||
let ast;
|
||||
|
||||
if(opts.useFlowParser) {
|
||||
@@ -52,7 +51,7 @@ module.exports = {
|
||||
|
||||
ast.tokens = [];
|
||||
|
||||
const printer = new Printer({ tabWidth, wrapColumn: printWidth });
|
||||
const printer = new Printer(opts);
|
||||
return printer.printGenerically(ast).code;
|
||||
}
|
||||
};
|
||||
+9
-85
@@ -1,64 +1,15 @@
|
||||
var defaults = {
|
||||
// If you want to use a different branch of esprima, or any other
|
||||
// module that supports a .parse function, pass that module object to
|
||||
// recast.parse as options.parser (legacy synonym: options.esprima).
|
||||
parser: require("esprima"),
|
||||
|
||||
// Number of spaces the pretty-printer should use per tab for
|
||||
// indentation. If you do not pass this option explicitly, it will be
|
||||
// (quite reliably!) inferred from the original code.
|
||||
tabWidth: 4,
|
||||
tabWidth: 2,
|
||||
|
||||
// If you really want the pretty-printer to use tabs instead of
|
||||
// spaces, make this option true.
|
||||
useTabs: false,
|
||||
|
||||
// The reprinting code leaves leading whitespace untouched unless it
|
||||
// has to reindent a line, or you pass false for this option.
|
||||
reuseWhitespace: true,
|
||||
|
||||
// Override this option to use a different line terminator, e.g. \r\n.
|
||||
lineTerminator: require("os").EOL,
|
||||
|
||||
// Some of the pretty-printer code (such as that for printing function
|
||||
// parameter lists) makes a valiant attempt to prevent really long
|
||||
// lines. You can adjust the limit by changing this option; however,
|
||||
// there is no guarantee that line length will fit inside this limit.
|
||||
wrapColumn: 74, // Aspirational for now.
|
||||
|
||||
// Pass a string as options.sourceFileName to recast.parse to tell the
|
||||
// reprinter to keep track of reused code so that it can construct a
|
||||
// source map automatically.
|
||||
sourceFileName: null,
|
||||
|
||||
// Pass a string as options.sourceMapName to recast.print, and
|
||||
// (provided you passed options.sourceFileName earlier) the
|
||||
// PrintResult of recast.print will have a .map property for the
|
||||
// generated source map.
|
||||
sourceMapName: null,
|
||||
|
||||
// If provided, this option will be passed along to the source map
|
||||
// generator as a root directory for relative source file paths.
|
||||
sourceRoot: null,
|
||||
|
||||
// If you provide a source map that was generated from a previous call
|
||||
// to recast.print as options.inputSourceMap, the old source map will
|
||||
// be composed with the new source map.
|
||||
inputSourceMap: null,
|
||||
|
||||
// If you want esprima to generate .range information (recast only
|
||||
// uses .loc internally), pass true for this option.
|
||||
range: false,
|
||||
|
||||
// If you want esprima not to throw exceptions when it encounters
|
||||
// non-fatal errors, keep this option true.
|
||||
tolerant: true,
|
||||
// Fit code within this line limit.
|
||||
printWidth: 80,
|
||||
|
||||
// If you want to override the quotes used in string literals, specify
|
||||
// either "single", "double", or "auto" here ("auto" will select the one
|
||||
// which results in the shorter literal)
|
||||
// Otherwise, double quotes are used.
|
||||
quote: null,
|
||||
// either "single" or "double".
|
||||
quote: "double",
|
||||
|
||||
// Controls the printing of trailing commas in object literals,
|
||||
// array expressions and function parameters.
|
||||
@@ -75,23 +26,9 @@ var defaults = {
|
||||
// }
|
||||
trailingComma: false,
|
||||
|
||||
// Controls the printing of spaces inside array brackets.
|
||||
// Controls the printing of spaces inside array and objects
|
||||
// See: http://eslint.org/docs/rules/array-bracket-spacing
|
||||
arrayBracketSpacing: false,
|
||||
|
||||
// Controls the printing of spaces inside object literals,
|
||||
// destructuring assignments, and import/export specifiers.
|
||||
// See: http://eslint.org/docs/rules/object-curly-spacing
|
||||
objectCurlySpacing: true,
|
||||
|
||||
// If you want parenthesis to wrap single-argument arrow function parameter
|
||||
// lists, pass true for this option.
|
||||
arrowParensAlways: false,
|
||||
|
||||
// There are 2 supported syntaxes (`,` and `;`) in Flow Object Types;
|
||||
// The use of commas is in line with the more popular style and matches
|
||||
// how objects are defined in JS, making it a bit more natural to write.
|
||||
flowObjectCommas: true,
|
||||
bracketSpacing: true
|
||||
}, hasOwn = defaults.hasOwnProperty;
|
||||
|
||||
// Copy options and fill in default values.
|
||||
@@ -106,22 +43,9 @@ exports.normalize = function(options) {
|
||||
|
||||
return {
|
||||
tabWidth: +get("tabWidth"),
|
||||
useTabs: !!get("useTabs"),
|
||||
reuseWhitespace: !!get("reuseWhitespace"),
|
||||
lineTerminator: get("lineTerminator"),
|
||||
wrapColumn: Math.max(get("wrapColumn"), 0),
|
||||
sourceFileName: get("sourceFileName"),
|
||||
sourceMapName: get("sourceMapName"),
|
||||
sourceRoot: get("sourceRoot"),
|
||||
inputSourceMap: get("inputSourceMap"),
|
||||
parser: get("esprima") || get("parser"),
|
||||
range: get("range"),
|
||||
tolerant: get("tolerant"),
|
||||
printWidth: Math.max(get("printWidth"), 0),
|
||||
quote: get("quote"),
|
||||
trailingComma: get("trailingComma"),
|
||||
arrayBracketSpacing: get("arrayBracketSpacing"),
|
||||
objectCurlySpacing: get("objectCurlySpacing"),
|
||||
arrowParensAlways: get("arrowParensAlways"),
|
||||
flowObjectCommas: get("flowObjectCommas"),
|
||||
bracketSpacing: get("bracketSpacing")
|
||||
};
|
||||
};
|
||||
+6
-3
@@ -149,7 +149,7 @@ function Printer(originalOptions) {
|
||||
options.reuseWhitespace = false;
|
||||
|
||||
var res = printGenerically(path);
|
||||
var pr = new PrintResult(pp.print(options.wrapColumn, res));
|
||||
var pr = new PrintResult(pp.print(options.printWidth, res));
|
||||
|
||||
options.reuseWhitespace = oldReuseWhitespace;
|
||||
|
||||
@@ -666,9 +666,12 @@ function genericPrintNoParens(path, options, print) {
|
||||
leftBrace,
|
||||
indent(
|
||||
options.tabWidth,
|
||||
concat([ line, join(concat([ separator, line ]), props) ])
|
||||
concat([
|
||||
options.bracketSpacing ? line : softline,
|
||||
join(concat([ separator, line ]), props)
|
||||
])
|
||||
),
|
||||
line,
|
||||
options.bracketSpacing ? line : softline,
|
||||
rightBrace,
|
||||
path.call(print, "typeAnnotation")
|
||||
]
|
||||
|
||||
@@ -8,7 +8,7 @@ var b: string = test; // Error: number ~> string
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: number ~> string
|
||||
import { test } from \"testmodule\";
|
||||
import {test} from \"testmodule\";
|
||||
var a: number = test;
|
||||
var b: string = test;
|
||||
"
|
||||
|
||||
@@ -6,7 +6,7 @@ import {doesntExist} from \"./SomeCSSFile.css\"; // Error: \`doestExist\` isn\'t
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: \`doestExist\` isn\'t an export
|
||||
import { className } from \"./SomeCSSFile.css\";
|
||||
import { doesntExist } from \"./SomeCSSFile.css\";
|
||||
import {className} from \"./SomeCSSFile.css\";
|
||||
import {doesntExist} from \"./SomeCSSFile.css\";
|
||||
"
|
||||
`;
|
||||
@@ -21,11 +21,11 @@ import {numVal as numVal2} from \'3DoesntExist\'; // Error
|
||||
// Error
|
||||
// Error
|
||||
var m1 = require(\"1DoesntExist\");
|
||||
import { numVal as numVal1 } from \"1DoesntExist\";
|
||||
import {numVal as numVal1} from \"1DoesntExist\";
|
||||
var a_1: number = m1.numVal;
|
||||
var a_2: number = numVal1;
|
||||
var m2 = require(\"2DoesntExist\");
|
||||
import { numVal as numVal2 } from \"3DoesntExist\";
|
||||
import {numVal as numVal2} from \"3DoesntExist\";
|
||||
"
|
||||
`;
|
||||
|
||||
|
||||
@@ -38,19 +38,19 @@ var c_4: string = numVal3; // Error: number ~> string
|
||||
var m1 = require(\"./1DoesntExist\");
|
||||
var a_1: number = m1.numVal;
|
||||
var a_2: string = m1.numVal;
|
||||
import { numVal } from \"./1DoesntExist\";
|
||||
import {numVal} from \"./1DoesntExist\";
|
||||
var a_3: number = numVal;
|
||||
var a_4: string = numVal;
|
||||
var m2 = require(\"./2DoesntExist\");
|
||||
var b_1: number = m2.numVal;
|
||||
var b_2: string = m2.numVal;
|
||||
import { numVal as numVal2 } from \"./3DoesntExist\";
|
||||
import {numVal as numVal2} from \"./3DoesntExist\";
|
||||
var b_3: number = numVal2;
|
||||
var b_4: string = numVal2;
|
||||
var m3 = require(\"4DoesntExist\");
|
||||
var c_1: number = m3.numVal;
|
||||
var c_2: string = m3.numVal;
|
||||
import { numVal as numVal3 } from \"5DoesntExist\";
|
||||
import {numVal as numVal3} from \"5DoesntExist\";
|
||||
var c_3: number = numVal3;
|
||||
var c_4: string = numVal3;
|
||||
"
|
||||
|
||||
@@ -8,7 +8,7 @@ import {name} from \"testproj\";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: Resolve from node_modules first!
|
||||
import { name } from \"testproj\";
|
||||
import {name} from \"testproj\";
|
||||
|
||||
(name: \"node_modules/testproj\");
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import {name} from \"testproj2\";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: Resolve from sibling \'custom_resolve_dir\' first!
|
||||
import { name } from \"testproj2\";
|
||||
import {name} from \"testproj2\";
|
||||
|
||||
(name: \"node_modules/testproj2\");
|
||||
|
||||
|
||||
@@ -95,6 +95,6 @@ exports[`test commonjs_import.js 1`] = `
|
||||
import {_p} from \"./commonjs_export\";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
import { _p } from \"./commonjs_export\";
|
||||
import {_p} from \"./commonjs_export\";
|
||||
"
|
||||
`;
|
||||
@@ -125,7 +125,7 @@ exports[`test test_relative.js 1`] = `
|
||||
(foo(): boolean); // Error: either Implementation ~> boolean or Definition ~> boolean
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Error: either Implementation ~> boolean or Definition ~> boolean
|
||||
import { foo } from \"./A\";
|
||||
import {foo} from \"./A\";
|
||||
|
||||
(foo(): boolean);
|
||||
"
|
||||
|
||||
@@ -179,7 +179,7 @@ declare export function getAFoo(): FooImpl;
|
||||
//
|
||||
// Default-exported class should also be available in local scope
|
||||
declare export default class FooImpl { givesANum(): number }
|
||||
declare export { FooImpl as Foo }
|
||||
declare export {FooImpl as Foo}
|
||||
declare export function getAFoo(): FooImpl;
|
||||
"
|
||||
`;
|
||||
@@ -335,7 +335,7 @@ declare export {
|
||||
* @providesModule ES6_ExportFrom_Intermediary1
|
||||
* @flow
|
||||
*/
|
||||
declare export { numberValue1, numberValue2 as numberValue2_renamed } from \"ES6_ExportFrom_Source1\"
|
||||
declare export {numberValue1, numberValue2 as numberValue2_renamed} from \"ES6_ExportFrom_Source1\"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -354,7 +354,7 @@ declare export {
|
||||
* @providesModule ES6_ExportFrom_Intermediary2
|
||||
* @flow
|
||||
*/
|
||||
declare export { numberValue1, numberValue2 as numberValue2_renamed2 } from \"ES6_ExportFrom_Source2\"
|
||||
declare export {numberValue1, numberValue2 as numberValue2_renamed2} from \"ES6_ExportFrom_Source2\"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -426,10 +426,10 @@ var specifierNumber2 = 2;
|
||||
var specifierNumber3 = 3;
|
||||
var groupedSpecifierNumber1 = 1;
|
||||
var groupedSpecifierNumber2 = 2;
|
||||
declare export { specifierNumber1 }
|
||||
declare export { specifierNumber2 as specifierNumber2Renamed }
|
||||
declare export { specifierNumber3 }
|
||||
declare export { groupedSpecifierNumber1, groupedSpecifierNumber2 }
|
||||
declare export {specifierNumber1}
|
||||
declare export {specifierNumber2 as specifierNumber2Renamed}
|
||||
declare export {specifierNumber3}
|
||||
declare export {groupedSpecifierNumber1, groupedSpecifierNumber2}
|
||||
declare export function givesANumber(): number;
|
||||
declare export class NumberGenerator { givesANumber(): number }
|
||||
declare export var varDeclNumber1: number;
|
||||
@@ -466,9 +466,9 @@ var specifierNumber4 = 1;
|
||||
var specifierNumber5 = 2;
|
||||
var groupedSpecifierNumber3 = 1;
|
||||
var groupedSpecifierNumber4 = 2;
|
||||
declare export { specifierNumber4 }
|
||||
declare export { specifierNumber5 as specifierNumber5Renamed }
|
||||
declare export { groupedSpecifierNumber3, groupedSpecifierNumber4 }
|
||||
declare export {specifierNumber4}
|
||||
declare export {specifierNumber5 as specifierNumber5Renamed}
|
||||
declare export {groupedSpecifierNumber3, groupedSpecifierNumber4}
|
||||
declare export function givesANumber2(): number;
|
||||
declare export class NumberGenerator2 { givesANumber(): number }
|
||||
declare export var varDeclNumber3: number;
|
||||
@@ -980,11 +980,11 @@ var b1: number = DefaultB.numberValue;
|
||||
var b2: string = DefaultB.numberValue;
|
||||
import DefaultC from \"C\";
|
||||
import DefaultD from \"./D\";
|
||||
import { doesntExist1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import { numberValue1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import {doesntExist1} from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue1} from \"CommonJS_Clobbering_Lit\";
|
||||
var c1: number = numberValue1;
|
||||
var c2: string = numberValue1;
|
||||
import { numberValue2 as numVal1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue2 as numVal1} from \"CommonJS_Clobbering_Lit\";
|
||||
var d1: number = numVal1;
|
||||
var d2: string = numVal1;
|
||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
@@ -1001,8 +1001,8 @@ CJS_Clobb_Lit_NS.default.default;
|
||||
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||
import {doesntExist2} from \"CommonJS_Clobbering_Class\";
|
||||
import {staticNumber1, baseProp, childProp} from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class();
|
||||
@@ -1020,11 +1020,11 @@ new CJS_Clobb_Class_NS();
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
var i3: string = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
import { doesntExist3 } from \"CommonJS_Named\";
|
||||
import { numberValue2 } from \"CommonJS_Named\";
|
||||
import {doesntExist3} from \"CommonJS_Named\";
|
||||
import {numberValue2} from \"CommonJS_Named\";
|
||||
var j1: number = numberValue2;
|
||||
var j2: string = numberValue2;
|
||||
import { numberValue3 as numVal3 } from \"CommonJS_Named\";
|
||||
import {numberValue3 as numVal3} from \"CommonJS_Named\";
|
||||
var k1: number = numVal3;
|
||||
var k2: string = numVal3;
|
||||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
@@ -1037,7 +1037,7 @@ import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4;
|
||||
var m3: string = CJS_Named_NS.numberValue4;
|
||||
import { doesntExist4 } from \"ES6_Default_AnonFunction1\";
|
||||
import {doesntExist4} from \"ES6_Default_AnonFunction1\";
|
||||
import ES6_Def_AnonFunc1 from \"ES6_Default_AnonFunction1\";
|
||||
var n1: number = ES6_Def_AnonFunc1();
|
||||
var n2: string = ES6_Def_AnonFunc1();
|
||||
@@ -1048,38 +1048,38 @@ import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\";
|
||||
var q1: number = new ES6_Def_NamedClass1().givesANum();
|
||||
var q2: string = new ES6_Def_NamedClass1().givesANum();
|
||||
import doesntExist5 from \"ES6_Named1\";
|
||||
import { specifierNumber1 as specifierNumber1_1 } from \"ES6_Named1\";
|
||||
import {specifierNumber1 as specifierNumber1_1} from \"ES6_Named1\";
|
||||
var r1: number = specifierNumber1_1;
|
||||
var r2: string = specifierNumber1_1;
|
||||
import { specifierNumber2Renamed } from \"ES6_Named1\";
|
||||
import {specifierNumber2Renamed} from \"ES6_Named1\";
|
||||
var s1: number = specifierNumber2Renamed;
|
||||
var s2: string = specifierNumber2Renamed;
|
||||
import { specifierNumber3 as specifierNumber3Renamed } from \"ES6_Named1\";
|
||||
import {specifierNumber3 as specifierNumber3Renamed} from \"ES6_Named1\";
|
||||
var t1: number = specifierNumber3Renamed;
|
||||
var t2: string = specifierNumber3Renamed;
|
||||
import { groupedSpecifierNumber1, groupedSpecifierNumber2 } from \"ES6_Named1\";
|
||||
import {groupedSpecifierNumber1, groupedSpecifierNumber2} from \"ES6_Named1\";
|
||||
var u1: number = groupedSpecifierNumber1;
|
||||
var u2: number = groupedSpecifierNumber2;
|
||||
var u3: string = groupedSpecifierNumber1;
|
||||
var u4: string = groupedSpecifierNumber2;
|
||||
import { givesANumber } from \"ES6_Named1\";
|
||||
import {givesANumber} from \"ES6_Named1\";
|
||||
var v1: number = givesANumber();
|
||||
var v2: string = givesANumber();
|
||||
import { NumberGenerator } from \"ES6_Named1\";
|
||||
import {NumberGenerator} from \"ES6_Named1\";
|
||||
var w1: number = new NumberGenerator().givesANumber();
|
||||
var w2: string = new NumberGenerator().givesANumber();
|
||||
import { varDeclNumber1, varDeclNumber2 } from \"ES6_Named1\";
|
||||
import {varDeclNumber1, varDeclNumber2} from \"ES6_Named1\";
|
||||
var x1: number = varDeclNumber1;
|
||||
var x2: number = varDeclNumber2;
|
||||
var x3: string = varDeclNumber1;
|
||||
var x4: string = varDeclNumber2;
|
||||
import { numberValue1 as numberValue4 } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue4} from \"ES6_ExportFrom_Intermediary1\";
|
||||
var aa1: number = numberValue4;
|
||||
var aa2: string = numberValue4;
|
||||
import { numberValue2_renamed } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue2_renamed} from \"ES6_ExportFrom_Intermediary1\";
|
||||
var ab1: number = numberValue2_renamed;
|
||||
var ab2: string = numberValue2_renamed;
|
||||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue5} from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5;
|
||||
|
||||
@@ -1129,15 +1129,15 @@ var aq2: string = numberValue2_renamed2;
|
||||
var numberValue7 = require(\"ES6_ExportAllFrom_Intermediary2\").numberValue2;
|
||||
var ar1: number = numberValue7;
|
||||
var ar2: string = numberValue7;
|
||||
import defaultNum, { str as namedStr } from \"./ES6_DefaultAndNamed\";
|
||||
import defaultNum, {str as namedStr} from \"./ES6_DefaultAndNamed\";
|
||||
var as1: number = defaultNum;
|
||||
var as2: string = defaultNum;
|
||||
var as3: string = namedStr;
|
||||
var as4: number = namedStr;
|
||||
import \"./SideEffects\";
|
||||
import specifierNumber1 from \"ES6_Named1\";
|
||||
import { specifierNumber } from \"ES6_Named1\";
|
||||
import { numberValue1 as numberValue8, numberValue2 as numberValue9 } from \"./ES6_ExportAllFromMulti\";
|
||||
import {specifierNumber} from \"ES6_Named1\";
|
||||
import {numberValue1 as numberValue8, numberValue2 as numberValue9} from \"./ES6_ExportAllFromMulti\";
|
||||
var at1: number = numberValue8;
|
||||
var at2: string = numberValue8;
|
||||
var at3: number = numberValue9;
|
||||
|
||||
@@ -41,8 +41,8 @@ import declare_module_exports from \"declare_module_exports\";
|
||||
|
||||
(declare_module_exports: string);
|
||||
|
||||
import { str } from \"declare_m_e_with_other_value_declares\";
|
||||
import type { str2 } from \"declare_m_e_with_other_type_declares\";
|
||||
import {str} from \"declare_m_e_with_other_value_declares\";
|
||||
import type {str2} from \"declare_m_e_with_other_type_declares\";
|
||||
|
||||
(\"asdf\": str2);
|
||||
|
||||
|
||||
@@ -45,15 +45,15 @@ blah(0, 0);
|
||||
// error : {toz : number} ~> string
|
||||
// error : number ~> A
|
||||
// error : string ~> number
|
||||
import type { baz } from \"ModuleAliasFoo\";
|
||||
import { foo } from \"ModuleAliasFoo\";
|
||||
import type {baz} from \"ModuleAliasFoo\";
|
||||
import {foo} from \"ModuleAliasFoo\";
|
||||
var k1: baz = 42;
|
||||
var k2: baz = \"shab\";
|
||||
var k3: toz = foo(k1);
|
||||
import type { toz } from \"ModuleAliasFoo\";
|
||||
import type {toz} from \"ModuleAliasFoo\";
|
||||
var k4: toz = foo(k1);
|
||||
import blah from \"foo\";
|
||||
import type { Foo, Bar, Id } from \"foo\";
|
||||
import type {Foo, Bar, Id} from \"foo\";
|
||||
|
||||
blah(0, 0);
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ export function emitExpression(node: TypedNode) : t.Expression {
|
||||
// FALLTHROUGH
|
||||
import * as t from \"./jsAst\";
|
||||
const b = t.builders;
|
||||
import type { TypedNode } from \"./ast\";
|
||||
import type {TypedNode} from \"./ast\";
|
||||
|
||||
function getBinaryOp(
|
||||
op: \"plus\" | \"minus\" | \"divide\" | \"multiply\"
|
||||
|
||||
@@ -408,7 +408,7 @@ export {
|
||||
* @providesModule ES6_ExportFrom_Intermediary1
|
||||
* @flow
|
||||
*/
|
||||
export { numberValue1, numberValue2 as numberValue2_renamed } from \"ES6_ExportFrom_Source1\"
|
||||
export {numberValue1, numberValue2 as numberValue2_renamed} from \"ES6_ExportFrom_Source1\"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -427,7 +427,7 @@ export {
|
||||
* @providesModule ES6_ExportFrom_Intermediary2
|
||||
* @flow
|
||||
*/
|
||||
export { numberValue1, numberValue2 as numberValue2_renamed2 } from \"ES6_ExportFrom_Source2\"
|
||||
export {numberValue1, numberValue2 as numberValue2_renamed2} from \"ES6_ExportFrom_Source2\"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -496,10 +496,10 @@ var specifierNumber2 = 2;
|
||||
var specifierNumber3 = 3;
|
||||
var groupedSpecifierNumber1 = 1;
|
||||
var groupedSpecifierNumber2 = 2;
|
||||
export { specifierNumber1 }
|
||||
export { specifierNumber2 as specifierNumber2Renamed }
|
||||
export { specifierNumber3 }
|
||||
export { groupedSpecifierNumber1, groupedSpecifierNumber2 }
|
||||
export {specifierNumber1}
|
||||
export {specifierNumber2 as specifierNumber2Renamed}
|
||||
export {specifierNumber3}
|
||||
export {groupedSpecifierNumber1, groupedSpecifierNumber2}
|
||||
export function givesANumber(): number {
|
||||
return 42;
|
||||
}
|
||||
@@ -544,9 +544,9 @@ var specifierNumber4 = 1;
|
||||
var specifierNumber5 = 2;
|
||||
var groupedSpecifierNumber3 = 1;
|
||||
var groupedSpecifierNumber4 = 2;
|
||||
export { specifierNumber4 }
|
||||
export { specifierNumber5 as specifierNumber5Renamed }
|
||||
export { groupedSpecifierNumber3, groupedSpecifierNumber4 }
|
||||
export {specifierNumber4}
|
||||
export {specifierNumber5 as specifierNumber5Renamed}
|
||||
export {groupedSpecifierNumber3, groupedSpecifierNumber4}
|
||||
export function givesANumber2(): number {
|
||||
return 42;
|
||||
}
|
||||
@@ -1090,11 +1090,11 @@ var b1: number = DefaultB.numberValue;
|
||||
var b2: string = DefaultB.numberValue;
|
||||
import DefaultC from \"C\";
|
||||
import DefaultD from \"./D\";
|
||||
import { doesntExist1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import { numberValue1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import {doesntExist1} from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue1} from \"CommonJS_Clobbering_Lit\";
|
||||
var c1: number = numberValue1;
|
||||
var c2: string = numberValue1;
|
||||
import { numberValue2 as numVal1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue2 as numVal1} from \"CommonJS_Clobbering_Lit\";
|
||||
var d1: number = numVal1;
|
||||
var d2: string = numVal1;
|
||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
@@ -1111,8 +1111,8 @@ CJS_Clobb_Lit_NS.default.default;
|
||||
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||
import {doesntExist2} from \"CommonJS_Clobbering_Class\";
|
||||
import {staticNumber1, baseProp, childProp} from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class();
|
||||
@@ -1130,11 +1130,11 @@ new CJS_Clobb_Class_NS();
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
var i3: string = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
import { doesntExist3 } from \"CommonJS_Named\";
|
||||
import { numberValue2 } from \"CommonJS_Named\";
|
||||
import {doesntExist3} from \"CommonJS_Named\";
|
||||
import {numberValue2} from \"CommonJS_Named\";
|
||||
var j1: number = numberValue2;
|
||||
var j2: string = numberValue2;
|
||||
import { numberValue3 as numVal3 } from \"CommonJS_Named\";
|
||||
import {numberValue3 as numVal3} from \"CommonJS_Named\";
|
||||
var k1: number = numVal3;
|
||||
var k2: string = numVal3;
|
||||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
@@ -1147,7 +1147,7 @@ import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4;
|
||||
var m3: string = CJS_Named_NS.numberValue4;
|
||||
import { doesntExist4 } from \"ES6_Default_AnonFunction1\";
|
||||
import {doesntExist4} from \"ES6_Default_AnonFunction1\";
|
||||
import ES6_Def_AnonFunc1 from \"ES6_Default_AnonFunction1\";
|
||||
var n1: number = ES6_Def_AnonFunc1();
|
||||
var n2: string = ES6_Def_AnonFunc1();
|
||||
@@ -1161,44 +1161,44 @@ import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\";
|
||||
var q1: number = new ES6_Def_NamedClass1().givesANum();
|
||||
var q2: string = new ES6_Def_NamedClass1().givesANum();
|
||||
import doesntExist5 from \"ES6_Named1\";
|
||||
import { specifierNumber1 as specifierNumber1_1 } from \"ES6_Named1\";
|
||||
import {specifierNumber1 as specifierNumber1_1} from \"ES6_Named1\";
|
||||
var r1: number = specifierNumber1_1;
|
||||
var r2: string = specifierNumber1_1;
|
||||
import { specifierNumber2Renamed } from \"ES6_Named1\";
|
||||
import {specifierNumber2Renamed} from \"ES6_Named1\";
|
||||
var s1: number = specifierNumber2Renamed;
|
||||
var s2: string = specifierNumber2Renamed;
|
||||
import { specifierNumber3 as specifierNumber3Renamed } from \"ES6_Named1\";
|
||||
import {specifierNumber3 as specifierNumber3Renamed} from \"ES6_Named1\";
|
||||
var t1: number = specifierNumber3Renamed;
|
||||
var t2: string = specifierNumber3Renamed;
|
||||
import { groupedSpecifierNumber1, groupedSpecifierNumber2 } from \"ES6_Named1\";
|
||||
import {groupedSpecifierNumber1, groupedSpecifierNumber2} from \"ES6_Named1\";
|
||||
var u1: number = groupedSpecifierNumber1;
|
||||
var u2: number = groupedSpecifierNumber2;
|
||||
var u3: string = groupedSpecifierNumber1;
|
||||
var u4: string = groupedSpecifierNumber2;
|
||||
import { givesANumber } from \"ES6_Named1\";
|
||||
import {givesANumber} from \"ES6_Named1\";
|
||||
var v1: number = givesANumber();
|
||||
var v2: string = givesANumber();
|
||||
import { NumberGenerator } from \"ES6_Named1\";
|
||||
import {NumberGenerator} from \"ES6_Named1\";
|
||||
var w1: number = new NumberGenerator().givesANumber();
|
||||
var w2: string = new NumberGenerator().givesANumber();
|
||||
import { varDeclNumber1, varDeclNumber2 } from \"ES6_Named1\";
|
||||
import {varDeclNumber1, varDeclNumber2} from \"ES6_Named1\";
|
||||
var x1: number = varDeclNumber1;
|
||||
var x2: number = varDeclNumber2;
|
||||
var x3: string = varDeclNumber1;
|
||||
var x4: string = varDeclNumber2;
|
||||
import { destructuredObjNumber } from \"ES6_Named1\";
|
||||
import {destructuredObjNumber} from \"ES6_Named1\";
|
||||
var y1: number = destructuredObjNumber;
|
||||
var y2: string = destructuredObjNumber;
|
||||
import { destructuredArrNumber } from \"ES6_Named1\";
|
||||
import {destructuredArrNumber} from \"ES6_Named1\";
|
||||
var z1: number = destructuredArrNumber;
|
||||
var z2: string = destructuredArrNumber;
|
||||
import { numberValue1 as numberValue4 } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue4} from \"ES6_ExportFrom_Intermediary1\";
|
||||
var aa1: number = numberValue4;
|
||||
var aa2: string = numberValue4;
|
||||
import { numberValue2_renamed } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue2_renamed} from \"ES6_ExportFrom_Intermediary1\";
|
||||
var ab1: number = numberValue2_renamed;
|
||||
var ab2: string = numberValue2_renamed;
|
||||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue5} from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5;
|
||||
|
||||
@@ -1257,20 +1257,20 @@ var aq2: string = numberValue2_renamed2;
|
||||
var numberValue7 = require(\"ES6_ExportAllFrom_Intermediary2\").numberValue2;
|
||||
var ar1: number = numberValue7;
|
||||
var ar2: string = numberValue7;
|
||||
import defaultNum, { str as namedStr } from \"./ES6_DefaultAndNamed\";
|
||||
import defaultNum, {str as namedStr} from \"./ES6_DefaultAndNamed\";
|
||||
var as1: number = defaultNum;
|
||||
var as2: string = defaultNum;
|
||||
var as3: string = namedStr;
|
||||
var as4: number = namedStr;
|
||||
import \"./SideEffects\";
|
||||
import specifierNumber1 from \"ES6_Named1\";
|
||||
import { specifierNumber } from \"ES6_Named1\";
|
||||
import { numberValue1 as numberValue8, numberValue2 as numberValue9 } from \"./ES6_ExportAllFromMulti\";
|
||||
import {specifierNumber} from \"ES6_Named1\";
|
||||
import {numberValue1 as numberValue8, numberValue2 as numberValue9} from \"./ES6_ExportAllFromMulti\";
|
||||
var at1: number = numberValue8;
|
||||
var at2: string = numberValue8;
|
||||
var at3: number = numberValue9;
|
||||
var at4: string = numberValue9;
|
||||
import { typeAlias } from \"./ExportType\";
|
||||
import {typeAlias} from \"./ExportType\";
|
||||
"
|
||||
`;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import {exports as nope} from \"ES\"; // Error: Not an export
|
||||
// Error: T is a type import, not a value
|
||||
// Error: string ~> number
|
||||
// Error: Not an export
|
||||
import { num1, str1 } from \"CJS_Named\";
|
||||
import {num1, str1} from \"CJS_Named\";
|
||||
import CJS_Named from \"CJS_Named\";
|
||||
|
||||
(num1: number);
|
||||
@@ -71,34 +71,34 @@ import CJS_Named from \"CJS_Named\";
|
||||
|
||||
(CJS_Named: number);
|
||||
|
||||
import { num2 } from \"CJS_Clobbered\";
|
||||
import { numExport } from \"CJS_Clobbered\";
|
||||
import {num2} from \"CJS_Clobbered\";
|
||||
import {numExport} from \"CJS_Clobbered\";
|
||||
|
||||
(numExport: number);
|
||||
|
||||
(numExport: string);
|
||||
|
||||
import type { numType } from \"CJS_Clobbered\";
|
||||
import type {numType} from \"CJS_Clobbered\";
|
||||
|
||||
(42: numType);
|
||||
|
||||
(\"asdf\": numType);
|
||||
|
||||
import { strHidden } from \"ES\";
|
||||
import { str3 } from \"ES\";
|
||||
import {strHidden} from \"ES\";
|
||||
import {str3} from \"ES\";
|
||||
|
||||
(str3: string);
|
||||
|
||||
(str3: number);
|
||||
|
||||
import { num3 } from \"ES\";
|
||||
import {num3} from \"ES\";
|
||||
|
||||
(num3: number);
|
||||
|
||||
(num3: string);
|
||||
|
||||
import { C } from \"ES\";
|
||||
import type { C as CType } from \"ES\";
|
||||
import {C} from \"ES\";
|
||||
import type {C as CType} from \"ES\";
|
||||
|
||||
(new C(): C);
|
||||
|
||||
@@ -108,13 +108,13 @@ import type { C as CType } from \"ES\";
|
||||
|
||||
(42: CType);
|
||||
|
||||
import { T } from \"ES\";
|
||||
import type { T as T2 } from \"ES\";
|
||||
import {T} from \"ES\";
|
||||
import type {T as T2} from \"ES\";
|
||||
|
||||
(42: T2);
|
||||
|
||||
(\"asdf\": T2);
|
||||
|
||||
import { exports as nope } from \"ES\";
|
||||
import {exports as nope} from \"ES\";
|
||||
"
|
||||
`;
|
||||
@@ -32,7 +32,7 @@ declare module \"CJS_Clobbered\" {
|
||||
}
|
||||
declare module \"ES\" {
|
||||
declare var strHidden: string;
|
||||
declare export { strHidden as str3 }
|
||||
declare export {strHidden as str3}
|
||||
declare export var num3: number;
|
||||
declare export class C {}
|
||||
declare export type T = number;
|
||||
|
||||
@@ -12,7 +12,7 @@ var d: number = source.str; // Error: num ~> string
|
||||
// @flow
|
||||
// Error: num ~> string
|
||||
// Error: num ~> string
|
||||
import { source } from \"./test\";
|
||||
import {source} from \"./test\";
|
||||
var a: number = source.num;
|
||||
var b: string = source.num;
|
||||
var c: string = source.str;
|
||||
|
||||
@@ -12,7 +12,7 @@ var d: number = source.str; // Ignored error: num ~> string
|
||||
// @flow
|
||||
// Error: num ~> string
|
||||
// Ignored error: num ~> string
|
||||
import { source } from \"./test\";
|
||||
import {source} from \"./test\";
|
||||
var a: number = source.num;
|
||||
var b: string = source.num;
|
||||
var c: string = source.str;
|
||||
|
||||
@@ -56,7 +56,7 @@ var n: IFoo2 = {prop: 42}; // Error: {prop:number} ~> {prop:string}
|
||||
// Error: string ~> number
|
||||
// Error: {prop:string} ~> {prop:number}
|
||||
// Error: {prop:number} ~> {prop:string}
|
||||
import type { inlinedType1, standaloneType1, talias1, talias3 } from \"./types_only\";
|
||||
import type {inlinedType1, standaloneType1, talias1, talias3} from \"./types_only\";
|
||||
var a: inlinedType1 = 42;
|
||||
var b: inlinedType1 = \"asdf\";
|
||||
var c: standaloneType1 = 42;
|
||||
@@ -65,10 +65,10 @@ var e: talias1 = 42;
|
||||
var f: talias1 = \"asdf\";
|
||||
var g: talias3 = 42;
|
||||
var h: talias3 = \"asdf\";
|
||||
import type { talias4 } from \"./cjs_with_types\";
|
||||
import type {talias4} from \"./cjs_with_types\";
|
||||
var i: talias4 = 42;
|
||||
var j: talias4 = \"asdf\";
|
||||
import { IFoo, IFoo2 } from \"./types_only\";
|
||||
import {IFoo, IFoo2} from \"./types_only\";
|
||||
var k: IFoo = { prop: 42 };
|
||||
var l: IFoo = { prop: \"asdf\" };
|
||||
var m: IFoo2 = { prop: \"asdf\" };
|
||||
@@ -100,10 +100,10 @@ export type inlinedType1 = number;
|
||||
var a: inlinedType1 = 42;
|
||||
var b: inlinedType1 = \"asdf\";
|
||||
type standaloneType1 = number;
|
||||
export type { standaloneType1 }
|
||||
export type {standaloneType1}
|
||||
type standaloneType2 = number;
|
||||
export { standaloneType2 }
|
||||
export type { talias1, talias2 as talias3, IFoo2 } from \"./types_only2\"
|
||||
export {standaloneType2}
|
||||
export type {talias1, talias2 as talias3, IFoo2} from \"./types_only2\"
|
||||
export interface IFoo { prop: number }
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -50,7 +50,7 @@ import thing from \"./helpers/exports_default.js\";
|
||||
|
||||
thing;
|
||||
|
||||
import { foo, bar as baz } from \"./helpers/exports_named.js\";
|
||||
import {foo, bar as baz} from \"./helpers/exports_named.js\";
|
||||
|
||||
foo;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ let foo = require(\"./Parent\").ParentFoo.foo;
|
||||
|
||||
foo;
|
||||
|
||||
import type { Foo } from \"./types\";
|
||||
import type {Foo} from \"./types\";
|
||||
"
|
||||
`;
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class ClassFoo2 {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
export { ClassFoo2 }
|
||||
export {ClassFoo2}
|
||||
export var foo2Inst = new ClassFoo2();
|
||||
"
|
||||
`;
|
||||
@@ -298,14 +298,14 @@ function foo() {
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Error: Not a value binding
|
||||
import type ClassFoo1 from \"./ExportDefault_Class\";
|
||||
import { foo1Inst } from \"./ExportDefault_Class\";
|
||||
import {foo1Inst} from \"./ExportDefault_Class\";
|
||||
var a1: ClassFoo1 = foo1Inst;
|
||||
var a2: number = foo1Inst;
|
||||
|
||||
new ClassFoo1();
|
||||
|
||||
import type { ClassFoo2 } from \"./ExportNamed_Class\";
|
||||
import { foo2Inst } from \"./ExportNamed_Class\";
|
||||
import type {ClassFoo2} from \"./ExportNamed_Class\";
|
||||
import {foo2Inst} from \"./ExportNamed_Class\";
|
||||
var b1: ClassFoo2 = foo2Inst;
|
||||
var b2: number = foo2Inst;
|
||||
|
||||
@@ -317,20 +317,20 @@ var c1: ClassFoo3T = new ClassFoo3();
|
||||
|
||||
new ClassFoo3T();
|
||||
|
||||
import type { ClassFoo4, ClassFoo5 } from \"./ExportCJSNamed_Class\";
|
||||
import { foo4Inst, foo5Inst } from \"./ExportCJSNamed_Class\";
|
||||
import type {ClassFoo4, ClassFoo5} from \"./ExportCJSNamed_Class\";
|
||||
import {foo4Inst, foo5Inst} from \"./ExportCJSNamed_Class\";
|
||||
var d1: ClassFoo4 = foo4Inst;
|
||||
var d2: number = foo4Inst;
|
||||
|
||||
new ClassFoo4();
|
||||
|
||||
var d3: typeof ClassFoo5 = foo5Inst;
|
||||
import type { AliasFoo3 } from \"./ExportNamed_Alias\";
|
||||
import { givesAFoo3Obj } from \"./ExportNamed_Alias\";
|
||||
import type {AliasFoo3} from \"./ExportNamed_Alias\";
|
||||
import {givesAFoo3Obj} from \"./ExportNamed_Alias\";
|
||||
var e1: AliasFoo3 = givesAFoo3Obj();
|
||||
var e2: number = givesAFoo3Obj();
|
||||
var e3: typeof AliasFoo3 = givesAFoo3Obj();
|
||||
import type { numValue } from \"./ExportsANumber\";
|
||||
import type {numValue} from \"./ExportsANumber\";
|
||||
import type ClassFoo6 from \"./issue-359\";
|
||||
|
||||
function foo() {
|
||||
|
||||
@@ -146,7 +146,7 @@ class ClassFoo2 {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
export { ClassFoo2 }
|
||||
export {ClassFoo2}
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -335,8 +335,8 @@ var a2: ClassFoo1T = new ClassFoo1();
|
||||
|
||||
new ClassFoo1T();
|
||||
|
||||
import typeof { ClassFoo2 as ClassFoo2T } from \"./ExportNamed_Class\";
|
||||
import { ClassFoo2 } from \"./ExportNamed_Class\";
|
||||
import typeof {ClassFoo2 as ClassFoo2T} from \"./ExportNamed_Class\";
|
||||
import {ClassFoo2} from \"./ExportNamed_Class\";
|
||||
var b1: ClassFoo2T = ClassFoo2;
|
||||
var b2: ClassFoo2T = new ClassFoo2();
|
||||
|
||||
@@ -346,21 +346,21 @@ import typeof ClassFoo3T from \"./ExportCJSDefault_Class\";
|
||||
import ClassFoo3 from \"./ExportCJSDefault_Class\";
|
||||
var c1: ClassFoo3T = ClassFoo3;
|
||||
var c2: ClassFoo3T = new ClassFoo3();
|
||||
import typeof { ClassFoo4 as ClassFoo4T } from \"./ExportCJSNamed_Class\";
|
||||
import { ClassFoo4 } from \"./ExportCJSNamed_Class\";
|
||||
import typeof {ClassFoo4 as ClassFoo4T} from \"./ExportCJSNamed_Class\";
|
||||
import {ClassFoo4} from \"./ExportCJSNamed_Class\";
|
||||
var d1: ClassFoo4T = ClassFoo4;
|
||||
var d2: ClassFoo4T = new ClassFoo4();
|
||||
import typeof { AliasFoo3 } from \"./ExportNamed_Alias\";
|
||||
import typeof {AliasFoo3} from \"./ExportNamed_Alias\";
|
||||
import typeof num_default from \"./ExportDefault_Number\";
|
||||
var f1: num_default = 42;
|
||||
var f2: num_default = \"asdf\";
|
||||
import typeof { num as num_named } from \"./ExportNamed_Number\";
|
||||
import typeof {num as num_named} from \"./ExportNamed_Number\";
|
||||
var g1: num_named = 42;
|
||||
var g2: num_named = \"asdf\";
|
||||
import typeof num_cjs_default from \"./ExportCJSDefault_Number\";
|
||||
var h1: num_cjs_default = 42;
|
||||
var h2: num_cjs_default = \"asdf\";
|
||||
import typeof { num as num_cjs_named } from \"./ExportCJSNamed_Number\";
|
||||
import typeof {num as num_cjs_named} from \"./ExportCJSNamed_Number\";
|
||||
var i1: num_cjs_named = 42;
|
||||
var i2: num_cjs_named = \"asdf\";
|
||||
import typeof * as ModuleNSObjT from \"./ExportNamed_Multi\";
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = C;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var A = require(\"./A\");
|
||||
import type { B } from \"./B\";
|
||||
import type {B} from \"./B\";
|
||||
class C extends A {
|
||||
b: B;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ function bar(m: M) { m.x; m.y; m.z; } // OK
|
||||
// error: z not found in L
|
||||
// interface + multiple inheritance is similar to object type + intersection
|
||||
// OK
|
||||
import type { J } from \"./import\";
|
||||
import type {J} from \"./import\";
|
||||
interface K {}
|
||||
interface L extends J, K { y: string }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export {Foo};
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
declare class Foo { bar?: () => string }
|
||||
export { Foo }
|
||||
export {Foo}
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -50,7 +50,7 @@ new C().foo.x;
|
||||
|
||||
C.bar.x;
|
||||
|
||||
import { Foo } from \"./exports_optional_prop\";
|
||||
import {Foo} from \"./exports_optional_prop\";
|
||||
const foo = new Foo();
|
||||
|
||||
(foo.bar(): string);
|
||||
|
||||
@@ -6,7 +6,7 @@ import {bar} from \'foo\';
|
||||
bar(5);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { bar } from \"foo\";
|
||||
import {bar} from \"foo\";
|
||||
|
||||
bar(5);
|
||||
"
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { ObjectType } from \'./test\';
|
||||
function subtypeCheck(x: Interface): ObjectType { return x; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
interface Interface { m(): void }
|
||||
import type { ObjectType } from \"./test\";
|
||||
import type {ObjectType} from \"./test\";
|
||||
|
||||
function subtypeCheck(x: Interface): ObjectType {
|
||||
return x;
|
||||
|
||||
@@ -107,7 +107,7 @@ var b: number = new react.Component(); // Error: ReactComponent ~> number
|
||||
/* @flow */
|
||||
// Error: ReactComponent ~> number
|
||||
import react from \"react\";
|
||||
import { Component } from \"react\";
|
||||
import {Component} from \"react\";
|
||||
var a: Component<*, *, *> = new react.Component();
|
||||
var b: number = new react.Component();
|
||||
"
|
||||
|
||||
@@ -78,7 +78,7 @@ class D extends F { }
|
||||
module.exports = { C, D };
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { C, E } from \"./b0\";
|
||||
import {C, E} from \"./b0\";
|
||||
|
||||
function foo() {
|
||||
return C;
|
||||
@@ -114,7 +114,7 @@ import { C, D } from \"./b2\";
|
||||
(new D: C);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { C, D } from \"./b2\";
|
||||
import {C, D} from \"./b2\";
|
||||
|
||||
(new D(): C);
|
||||
"
|
||||
@@ -140,7 +140,7 @@ export function bar(props: { x: number }) {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { foo } from \"./c1\";
|
||||
import {foo} from \"./c1\";
|
||||
export function bar(props: { x: number }) {
|
||||
foo({ x: 0 });
|
||||
}
|
||||
@@ -155,7 +155,7 @@ import { bar } from \"./c2\";
|
||||
bar({ x: 0 });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { bar } from \"./c2\";
|
||||
import {bar} from \"./c2\";
|
||||
|
||||
bar({ x: 0 });
|
||||
"
|
||||
@@ -182,7 +182,7 @@ import {A, x} from \"./d1\";
|
||||
export var y: A = x;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { A, x } from \"./d1\";
|
||||
import {A, x} from \"./d1\";
|
||||
export var y: A = x;
|
||||
"
|
||||
`;
|
||||
@@ -217,11 +217,11 @@ import { LIFE } from \'./e1\';
|
||||
(LIFE: 42);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import type { Action } from \"./e1\";
|
||||
import type {Action} from \"./e1\";
|
||||
const f = (): Action => {
|
||||
return { type: \"FOO\" };
|
||||
};
|
||||
import { LIFE } from \"./e1\";
|
||||
import {LIFE} from \"./e1\";
|
||||
|
||||
(LIFE: 42);
|
||||
"
|
||||
@@ -283,7 +283,7 @@ class D extends C { }
|
||||
module.exports = { D };
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { C } from \"./g1\";
|
||||
import {C} from \"./g1\";
|
||||
class D extends C {}
|
||||
|
||||
module.exports = { D };
|
||||
@@ -299,8 +299,8 @@ import { D } from \'./g2\';
|
||||
(new D: C)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { C } from \"./g1\";
|
||||
import { D } from \"./g2\";
|
||||
import {C} from \"./g1\";
|
||||
import {D} from \"./g2\";
|
||||
|
||||
(new D(): C);
|
||||
"
|
||||
@@ -322,6 +322,6 @@ exports[`test h2.js 1`] = `
|
||||
import type { Foo } from \'./h1\';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import type { Foo } from \"./h1\";
|
||||
import type {Foo} from \"./h1\";
|
||||
"
|
||||
`;
|
||||
@@ -10,7 +10,7 @@ class D extends F { }
|
||||
module.exports = { C, D };
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { C, E } from \"./b0\";
|
||||
import {C, E} from \"./b0\";
|
||||
|
||||
function foo() {
|
||||
return C;
|
||||
|
||||
@@ -8,7 +8,7 @@ export function bar(props: { y: number }) {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import { foo } from \"./c1\";
|
||||
import {foo} from \"./c1\";
|
||||
export function bar(props: { y: number }) {
|
||||
foo({ y: 0 });
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import { LIFE } from \'./e1\';
|
||||
(LIFE: 42);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import type { Action } from \"./e1\";
|
||||
import type {Action} from \"./e1\";
|
||||
const f = (): Action => {
|
||||
return { type: \"QUX\" };
|
||||
};
|
||||
import { LIFE } from \"./e1\";
|
||||
import {LIFE} from \"./e1\";
|
||||
|
||||
(LIFE: 42);
|
||||
"
|
||||
|
||||
@@ -28,11 +28,11 @@ import { LIFE } from \'./e1\';
|
||||
(LIFE: 0);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import type { Action } from \"./e1\";
|
||||
import type {Action} from \"./e1\";
|
||||
const f = (): Action => {
|
||||
return { type: \"QUX\" };
|
||||
};
|
||||
import { LIFE } from \"./e1\";
|
||||
import {LIFE} from \"./e1\";
|
||||
|
||||
(LIFE: 0);
|
||||
"
|
||||
|
||||
@@ -2723,7 +2723,7 @@ function getTypeASTName(typeAST: Type): string {
|
||||
}
|
||||
}
|
||||
|
||||
import type { ASTNode } from \"./ast_node\";
|
||||
import type {ASTNode} from \"./ast_node\";
|
||||
var Node = require(\"./node1\");
|
||||
|
||||
function foo(x: ASTNode) {
|
||||
@@ -3015,7 +3015,7 @@ function handleStatus(status: Success | Error) {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
import { SUCCESS, ERROR } from \"./constants\";
|
||||
import {SUCCESS, ERROR} from \"./constants\";
|
||||
type Success = { type: typeof SUCCESS; message: string };
|
||||
type Error = { type: typeof ERROR; error: string };
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ exports[`test qux.js 1`] = `
|
||||
"import type { Foo } from \'./bar.js\';
|
||||
({ x: \"\" }: Foo);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import type { Foo } from \"./bar.js\";
|
||||
import type {Foo} from \"./bar.js\";
|
||||
|
||||
({ x: \"\" }: Foo);
|
||||
"
|
||||
|
||||
@@ -234,9 +234,9 @@ class B3<X> extends A3<X> {
|
||||
// OK
|
||||
// error
|
||||
// error
|
||||
import { A1 } from \"./export\";
|
||||
import type { A2 } from \"./export\";
|
||||
import { A3 } from \"./export\";
|
||||
import {A1} from \"./export\";
|
||||
import type {A2} from \"./export\";
|
||||
import {A3} from \"./export\";
|
||||
class B1 extends A1 {
|
||||
foo(): B1 {
|
||||
return new B1();
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = printBinaryExpression;
|
||||
*/
|
||||
\"use babel\";
|
||||
|
||||
import type { BinaryExpression } from \"./types\";
|
||||
import type {BinaryExpression} from \"./types\";
|
||||
|
||||
function printBinaryExpression(node: BinaryExpression) {
|
||||
console.log(node);
|
||||
|
||||
@@ -50,7 +50,7 @@ var duck: string = \"quack\";
|
||||
// These string types should confict with the imported types
|
||||
// This string type should conflict with the typedef
|
||||
import typeof A from \"./A.js\";
|
||||
import type { Foo, Bar as Baz } from \"./A.js\";
|
||||
import type {Foo, Bar as Baz} from \"./A.js\";
|
||||
type duck = { quack(): string };
|
||||
var A: string = \"Hello\";
|
||||
var Foo: string = \"Goodbye\";
|
||||
@@ -87,7 +87,7 @@ var b: Foo = new A.Foo();
|
||||
// errors in prev block leave type bindings in place, so these are errors
|
||||
// errors from value positions only
|
||||
import typeof A from \"./A.js\";
|
||||
import type { Foo, Bar as Baz } from \"./A.js\";
|
||||
import type {Foo, Bar as Baz} from \"./A.js\";
|
||||
var A = require(\"./A.js\");
|
||||
var Foo = A.Foo;
|
||||
var Baz = A.Bar;
|
||||
@@ -126,7 +126,7 @@ var a: Foo = new actualA.Foo();
|
||||
// You can\'t use it as an identifier
|
||||
// But using it in a type should still work
|
||||
import typeof A from \"./A.js\";
|
||||
import type { Foo, Bar as Baz } from \"./A.js\";
|
||||
import type {Foo, Bar as Baz} from \"./A.js\";
|
||||
var actualA = require(\"./A.js\");
|
||||
var m = A;
|
||||
var n = Foo;
|
||||
|
||||
@@ -61,7 +61,7 @@ export default class A {
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import { B, C } from \"./issue-824-helper\";
|
||||
import {B, C} from \"./issue-824-helper\";
|
||||
type K = B | C;
|
||||
type I = { which(): number };
|
||||
export default class A {
|
||||
@@ -148,7 +148,7 @@ function node(content: ?Foobar | String | Array<String>) {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
import type { Foobar } from \"./issue-1455-helper\";
|
||||
import type {Foobar} from \"./issue-1455-helper\";
|
||||
|
||||
function create(content: ?Foobar | String | Array<String>) {}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ function parse(string) {
|
||||
}
|
||||
|
||||
function prettyprint(src, filename) {
|
||||
return jscodefmt.format(src, { filename, useFlowParser: true });
|
||||
return jscodefmt.format(src, { filename, useFlowParser: true, printWidth: 80 });
|
||||
}
|
||||
|
||||
function read(filename) {
|
||||
|
||||
Reference in new issue
Block a user