Move accessibility before static (#1908)

I looked through all the places where we display accessibility and all of them now have a consistent way of printing all those modifiers.

Fixes #1877
master
Christopher Chedeau 2017-06-02 14:27:19 -07:00 committed by GitHub
parent 02c48d284e
commit 74f7f96fe4
4 changed files with 19 additions and 7 deletions

View File

@ -1664,9 +1664,6 @@ function genericPrintNoParens(path, options, print, args) {
return concat(parts);
case "ClassProperty":
case "TSAbstractClassProperty": {
if (n.static) {
parts.push("static ");
}
const variance = getFlowVariance(n);
if (variance) {
parts.push(variance);
@ -1674,6 +1671,9 @@ function genericPrintNoParens(path, options, print, args) {
if (n.accessibility) {
parts.push(n.accessibility + " ");
}
if (n.static) {
parts.push("static ");
}
if (n.type === "TSAbstractClassProperty") {
parts.push("abstract ");
}

View File

@ -149,25 +149,25 @@ class Private2 {
class Protected {
constructor(...args: any[]) {}
protected p: string;
static protected s: string;
protected static s: string;
}
class Protected2 {
constructor(...args: any[]) {}
protected p: string;
static protected s: string;
protected static s: string;
}
class Public {
constructor(...args: any[]) {}
public p: string;
static public s: string;
public static s: string;
}
class Public2 {
constructor(...args: any[]) {}
public p: string;
static public s: string;
public static s: string;
}
function f1(x: Private & Private2) {

View File

@ -51,6 +51,10 @@ class X {
interface Iterable<T> {
export [Symbol.iterator](): Iterator<T>;
}
export class Check {
private static property = 'test';
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class X {
optionalMethod?() {}
@ -60,6 +64,10 @@ interface Iterable<T> {
export [Symbol.iterator](): Iterator<T>;
}
export class Check {
private static property = "test";
}
`;
exports[`optional.ts 1`] = `

View File

@ -5,3 +5,7 @@ class X {
interface Iterable<T> {
export [Symbol.iterator](): Iterator<T>;
}
export class Check {
private static property = 'test';
}