Add module, class and typed nodes to sourceElements (#2266)
babylon flow typescript parsers + tests to cover module and classmaster
parent
b8af5e5241
commit
400f34624f
10
index.js
10
index.js
|
@ -185,6 +185,16 @@ function isSourceElement(node) {
|
|||
case "VariableDeclaration":
|
||||
case "WhileStatement":
|
||||
case "WithStatement":
|
||||
case "ClassDeclaration": // ES 2015
|
||||
case "ImportDeclaration": // Module
|
||||
case "ExportDefaultDeclaration": // Module
|
||||
case "ExportNamedDeclaration": // Module
|
||||
case "ExportAllDeclaration": // Module
|
||||
case "TypeAlias": // Flow
|
||||
case "InterfaceDeclaration": // Flow, Typescript
|
||||
case "TypeAliasDeclaration": // Typescript
|
||||
case "ExportAssignment": // Typescript
|
||||
case "ExportDeclaration": // Typescript
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`class-declaration.js 1`] = `
|
||||
|
||||
|
||||
class a {
|
||||
b( ) {}
|
||||
}
|
||||
|
||||
let x~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
class a {
|
||||
b() {}
|
||||
}
|
||||
|
||||
let x
|
||||
`;
|
||||
|
||||
exports[`different-levels.js 1`] = `
|
||||
call(1,2,3)
|
||||
call(1,2,3)
|
||||
|
@ -41,6 +58,97 @@ function ugly ( {a=1, b = 2 } ) {
|
|||
}
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`module-export1.js 1`] = `
|
||||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import def , {named} from 'x'
|
||||
|
||||
export * from "d";
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
||||
|
||||
`;
|
||||
|
||||
exports[`module-export2.js 1`] = `
|
||||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x = 42;
|
||||
|
||||
export default 42
|
||||
|
||||
|
||||
`;
|
||||
|
||||
exports[`module-export3.js 1`] = `
|
||||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42;
|
||||
|
||||
|
||||
`;
|
||||
|
||||
exports[`module-import.js 1`] = `
|
||||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import def, { named } from "x";
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
||||
|
||||
`;
|
||||
|
||||
exports[`multiple-statements.js 1`] = `
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
|
||||
class <<<PRETTIER_RANGE_START>>> a {
|
||||
b( ) {}<<<PRETTIER_RANGE_END>>>
|
||||
}
|
||||
|
||||
let x
|
|
@ -0,0 +1,9 @@
|
|||
import def , {named} from 'x'
|
||||
|
||||
export * <<<PRETTIER_RANGE_START>>> from 'd'<<<PRETTIER_RANGE_END>>>
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
<<<PRETTIER_RANGE_START>>>
|
||||
export const x
|
||||
<<<PRETTIER_RANGE_END>>>= 42
|
||||
|
||||
export default 42
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import def , {named} from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default <<<PRETTIER_RANGE_START>>> 42<<<PRETTIER_RANGE_END>>>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import <<<PRETTIER_RANGE_START>>> def , {named} <<<PRETTIER_RANGE_END>>> from 'x'
|
||||
|
||||
export * from 'd'
|
||||
|
||||
export const x
|
||||
= 42
|
||||
|
||||
export default 42
|
||||
|
Loading…
Reference in New Issue