Skip to content

Commit d1b2329

Browse files
committed
update test input / output for autofix
1 parent 787e0fb commit d1b2329

File tree

3 files changed

+134
-22
lines changed

3 files changed

+134
-22
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// So typescript treats this as a module
2+
export {};
3+
4+
class GraphQLExtension<T> {_: T}
5+
6+
interface GraphQLResponse {}
7+
8+
namespace Koa {
9+
export interface Context {}
10+
}
11+
12+
const inlineArrow: (props: {bar: boolean, foo: boolean; baz?: boolean;}) => null = ({...props}) => null;
13+
14+
const inlineArrow2: (props: {baz: boolean, foo: boolean; bar?: boolean;}) => null = ({...props}) => null;
15+
16+
const inlineWeird: (props: {bar: boolean,baz: boolean,
17+
foo?: boolean;}) => null = ({...props}) => null;
18+
19+
function inlineGeneric<T extends { bar: boolean, foo: boolean; baz?: boolean;}>({...props}: T | {bar: boolean; foo: boolean; baz?: boolean}) {
20+
return null
21+
}
22+
23+
enum InlineEnum {a="T", b="T", c="T", d="T", e="T"}
24+
25+
enum InlineEnum2 {Bar = 'BAR',Baz = 'BAZ', Foo = 'FOO' }
26+
27+
enum InlineEnum3 {C="T", b_="T", c="T"}
28+
29+
enum WeirdEnum {
30+
Bar = 'BAR',Baz = 'BAZ', Foo = 'FOO'}
31+
32+
interface InlineInterface {b:"T"; d:"T"; e: "T"; a?:"T", c?:"T";}
33+
34+
class Class extends GraphQLExtension<{
35+
graphqlResponse: GraphQLResponse;
36+
context?: Koa.Context;
37+
}> {
38+
public method(o: {
39+
graphqlResponse: GraphQLResponse;
40+
context?: Koa.Context;
41+
}): void | { context?: Koa.Context, graphqlResponse?: GraphQLResponse; } {
42+
//
43+
}
44+
}
45+
46+
interface Interface {
47+
// %bar
48+
bar: boolean;
49+
/**
50+
* %foo
51+
*/
52+
foo: boolean;
53+
/* %baz */
54+
baz?: boolean;
55+
}
56+
57+
type Type1<TKey extends string> = Partial<{
58+
/**
59+
* %bar
60+
*/
61+
bar: boolean;
62+
/* %baz */ baz: boolean;
63+
64+
// %foo
65+
foo?: boolean;
66+
}> & {
67+
/**
68+
* %bar
69+
*/
70+
bar: boolean;
71+
72+
// %baz
73+
baz: boolean;
74+
/* %foo */
75+
foo?: boolean;
76+
} & {
77+
[K in keyof TKey]: boolean;
78+
};
79+
80+
enum StringEnum {
81+
/**
82+
* %bar
83+
*/
84+
Bar = 'BAR',
85+
86+
// %baz
87+
Baz = 'BAZ',
88+
89+
/* %foo */
90+
Foo = 'FOO'
91+
}
92+
93+
type Type2 = {
94+
/**
95+
* %bar
96+
*/
97+
bar: boolean;
98+
99+
// %baz
100+
baz: boolean;
101+
/* %foo */
102+
foo?: boolean;
103+
}
104+
105+
interface ClockConstructor {
106+
new (hour: number, minute: number): ClockInterface;
107+
new (hour: number): ClockInterface;
108+
}
109+
110+
interface ClockInterface {
111+
tick(): void;
112+
}

tests/fixtures/autofix.input.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ namespace Koa {
99
export interface Context {}
1010
}
1111

12-
const inlineArrow: (props: {foo: boolean; baz: boolean; bar: boolean}) => null = ({...props}) => null;
12+
const inlineArrow: (props: {foo: boolean; baz?: boolean; bar: boolean}) => null = ({...props}) => null;
1313

14-
const inlineArrow2: (props: {foo: boolean; bar: boolean; baz: boolean}) => null = ({...props}) => null;
14+
const inlineArrow2: (props: {foo: boolean; bar?: boolean; baz: boolean}) => null = ({...props}) => null;
1515

16-
const inlineWeird: (props: {foo: boolean;baz: boolean,
16+
const inlineWeird: (props: {foo?: boolean;baz: boolean,
1717
bar: boolean}) => null = ({...props}) => null;
1818

19-
function inlineGeneric<T extends { foo: boolean; baz: boolean; bar: boolean}>({...props}: T | {foo: boolean; bar: boolean; baz: boolean}) {
19+
function inlineGeneric<T extends { foo: boolean; baz?: boolean; bar: boolean}>({...props}: T | {foo: boolean; bar: boolean; baz?: boolean}) {
2020
return null
2121
}
2222

@@ -29,15 +29,15 @@ enum InlineEnum3 {b_="T", c="T", C="T"}
2929
enum WeirdEnum {
3030
Foo = 'FOO',Baz = 'BAZ', Bar = 'BAR',}
3131

32-
interface InlineInterface {e: "T"; c:"T"; d:"T"; b:"T"; a:"T"}
32+
interface InlineInterface {e: "T"; c?:"T"; d:"T"; b:"T"; a?:"T"}
3333

3434
class Class extends GraphQLExtension<{
3535
graphqlResponse: GraphQLResponse;
36-
context: Koa.Context;
36+
context?: Koa.Context;
3737
}> {
3838
public method(o: {
3939
graphqlResponse: GraphQLResponse;
40-
context: Koa.Context;
40+
context?: Koa.Context;
4141
}): void | { graphqlResponse?: GraphQLResponse; context?: Koa.Context } {
4242
//
4343
}
@@ -49,22 +49,22 @@ interface Interface {
4949
*/
5050
foo: boolean;
5151
/* %baz */
52-
baz: boolean;
52+
baz?: boolean;
5353
// %bar
5454
bar: boolean;
5555
}
5656

5757
type Type1<TKey extends string> = Partial<{
5858
// %foo
59-
foo: boolean;
59+
foo?: boolean;
6060
/* %baz */ baz: boolean;
6161

6262
/**
6363
* %bar
6464
*/
6565
bar: boolean;
6666
}> & {/* %foo */
67-
foo: boolean;
67+
foo?: boolean;
6868

6969
// %baz
7070
baz: boolean;
@@ -90,7 +90,7 @@ enum StringEnum {
9090
}
9191

9292
type Type2 = {/* %foo */
93-
foo: boolean;
93+
foo?: boolean;
9494

9595
// %baz
9696
baz: boolean;

tests/fixtures/autofix.output.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ namespace Koa {
99
export interface Context {}
1010
}
1111

12-
const inlineArrow: (props: {bar: boolean, baz: boolean; foo: boolean;}) => null = ({...props}) => null;
12+
const inlineArrow: (props: {bar: boolean, baz?: boolean; foo: boolean;}) => null = ({...props}) => null;
1313

14-
const inlineArrow2: (props: {bar: boolean; baz: boolean, foo: boolean;}) => null = ({...props}) => null;
14+
const inlineArrow2: (props: {bar?: boolean; baz: boolean, foo: boolean;}) => null = ({...props}) => null;
1515

1616
const inlineWeird: (props: {bar: boolean,baz: boolean,
17-
foo: boolean;}) => null = ({...props}) => null;
17+
foo?: boolean;}) => null = ({...props}) => null;
1818

19-
function inlineGeneric<T extends { bar: boolean, baz: boolean; foo: boolean;}>({...props}: T | {bar: boolean; baz: boolean, foo: boolean;}) {
19+
function inlineGeneric<T extends { bar: boolean, baz?: boolean; foo: boolean;}>({...props}: T | {bar: boolean; baz?: boolean, foo: boolean;}) {
2020
return null
2121
}
2222

@@ -29,14 +29,14 @@ enum InlineEnum3 {C="T", b_="T", c="T"}
2929
enum WeirdEnum {
3030
Bar = 'BAR',Baz = 'BAZ', Foo = 'FOO'}
3131

32-
interface InlineInterface {a:"T", b:"T"; c:"T"; d:"T"; e: "T";}
32+
interface InlineInterface {a?:"T", b:"T"; c?:"T"; d:"T"; e: "T";}
3333

3434
class Class extends GraphQLExtension<{
35-
context: Koa.Context;
35+
context?: Koa.Context;
3636
graphqlResponse: GraphQLResponse;
3737
}> {
3838
public method(o: {
39-
context: Koa.Context;
39+
context?: Koa.Context;
4040
graphqlResponse: GraphQLResponse;
4141
}): void | { context?: Koa.Context, graphqlResponse?: GraphQLResponse; } {
4242
//
@@ -47,7 +47,7 @@ interface Interface {
4747
// %bar
4848
bar: boolean;
4949
/* %baz */
50-
baz: boolean;
50+
baz?: boolean;
5151
/**
5252
* %foo
5353
*/
@@ -62,7 +62,7 @@ type Type1<TKey extends string> = Partial<{
6262
/* %baz */ baz: boolean;
6363

6464
// %foo
65-
foo: boolean;
65+
foo?: boolean;
6666
}> & {
6767
/**
6868
* %bar
@@ -72,7 +72,7 @@ type Type1<TKey extends string> = Partial<{
7272
// %baz
7373
baz: boolean;
7474
/* %foo */
75-
foo: boolean;
75+
foo?: boolean;
7676
} & {
7777
[K in keyof TKey]: boolean;
7878
};
@@ -99,7 +99,7 @@ type Type2 = {
9999
// %baz
100100
baz: boolean;
101101
/* %foo */
102-
foo: boolean;
102+
foo?: boolean;
103103
}
104104

105105
interface ClockConstructor {

0 commit comments

Comments
 (0)