Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8b2e557
printers [nfc]: Add methods printInexactObjectType and friends
gnprice Apr 18, 2022
e865795
printers: Fix intersections-as-spreads when `inexact` true
gnprice Apr 18, 2022
3f13be1
printers [nfc]: Factor out common Record and Omit logic a bit better
gnprice Apr 18, 2022
8d2416a
printers: Fix Omit to use an explicitly exact type
gnprice Apr 18, 2022
c33cc5b
printers: Fix Record when `inexact` false, to use explicit exact types
gnprice Apr 18, 2022
3f1e06d
printers: Fix Partial when `inexact` false, to use explicit inexact type
gnprice Apr 18, 2022
ca79e4d
printers: Fix untyped object binding patterns to use explicit inexact…
gnprice Apr 18, 2022
fe6d723
printers: Use common printExactObjectType for namespaces
gnprice Apr 18, 2022
740f24f
printers [nfc]: Slightly simplify loop logic in interfaceType
gnprice Apr 18, 2022
324fe97
printers [nfc]: Factor out helper typeMembers, deduplicating
gnprice Apr 18, 2022
176e3ce
printers [nfc]: Cut unused withSemicolons on interfaceRecordType
gnprice Apr 18, 2022
fad4e4b
printers [nfc]: Split classBody from interfaceType
gnprice Apr 18, 2022
6dbdd51
printers [nfc]: Split interfaceDeclaration logic for type vs. interface
gnprice Apr 18, 2022
37ce190
printers [nfc]: Split objectType from interfaceTypeBody
gnprice Apr 18, 2022
0f64e4a
printers [nfc]: Push control of newlines out of typeMembers, to callers
gnprice Apr 19, 2022
3e8963c
printers [nfc]: Make interfaceDeclaration's inexact-forcing explicit
gnprice Apr 18, 2022
ef5ce3e
printers: Use common printDefaultObjectType for type literals
gnprice Apr 18, 2022
d8e8e9e
printers: Fix interface-extends to stay explicitly inexact when `inex…
gnprice Apr 18, 2022
de337ab
printers: Fix interfaceRecordType to make inexact types explicit
gnprice Apr 18, 2022
e4a8e96
printers [nfc]: Dissolve interfaceRecordType into its one caller
gnprice Apr 18, 2022
326094e
printers: Fix formatting of static class members
gnprice Apr 20, 2022
a2716e8
printers [nfc]: Simplify newlines logic of interfaceTypeBody, classBody
gnprice Apr 20, 2022
92525ea
printers [nfc]: Inline classBody into classDeclaration
gnprice Apr 20, 2022
f371e6d
printers [nfc]: Fix a comment in classDeclaration; simplify code slig…
gnprice Apr 20, 2022
36674aa
printers [nfc]: Inline interfaceTypeBody into interfaceDeclaration
gnprice Apr 20, 2022
df16b22
printers: Drop now-redundant comments on enum members
gnprice Apr 18, 2022
98097b6
printers: Use common printExactObjectType in enumDeclaration
gnprice Apr 18, 2022
74c7ada
Enable flowlint implicit-inexact-object for our tests
gnprice Apr 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
[ignore]

[include]

[libs]

[lints]

[options]

[strict]
; This Flow config is used when having Flow check our output for validity,
; in test cases that use `expect(…).toBeValidFlowTypeDeclarations()`.
implicit-inexact-object=error
5 changes: 1 addition & 4 deletions src/__tests__/__snapshots__/classes.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ declare class Observable<T> mixins Subscribable<T> {
jump?: () => void;
+jump?: () => void;
static +jump?: () => void;
cfnProperties: {
[key: string]: any,
...
};
cfnProperties: { [key: string]: any, ... };
static fooGet: string;
}
"
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/__snapshots__/duplicated-names.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export type AuthMechanismType = $ElementType<
`;

exports[`should support generic type rename 1`] = `
"declare export var ProfilingLevel: $ReadOnly<{
+off: \\"off\\",
...
}>;
"declare export var ProfilingLevel: $ReadOnly<{ +off: \\"off\\", ... }>;
export type ProfilingLevelType = $ElementType<
typeof ProfilingLevel,
$Keys<typeof ProfilingLevel>
Expand Down
30 changes: 15 additions & 15 deletions src/__tests__/__snapshots__/enums.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

exports[`should handle basic enums: class 1`] = `
"declare var Label: {|
+LABEL_OPTIONAL: 0, // 0
+LABEL_REQUIRED: 1, // 1
+LABEL_REPEATED: 2, // 2
+LABEL_OPTIONAL: 0,
+LABEL_REQUIRED: 1,
+LABEL_REPEATED: 2,
|};
declare type A = $Values<typeof Label>;
declare type B = typeof Label.LABEL_OPTIONAL;
Expand All @@ -18,8 +18,8 @@ exports[`should handle empty enums: class 1`] = `

exports[`should handle importing enum types: class 1`] = `
"declare export var Label: {|
+A: \\"A\\", // \\"A\\"
+B: \\"B\\", // \\"B\\"
+A: \\"A\\",
+B: \\"B\\",
|};
"
`;
Expand All @@ -32,8 +32,8 @@ declare export function foo(label: $Values<Label>): void;

exports[`should handle importing enums: class 1`] = `
"declare export var Label: {|
+A: \\"A\\", // \\"A\\"
+B: \\"B\\", // \\"B\\"
+A: \\"A\\",
+B: \\"B\\",
|};
"
`;
Expand All @@ -46,11 +46,11 @@ declare export function foo(label: $Values<typeof Label>): void;

exports[`should handle number enums: class 1`] = `
"declare var Label: {|
+ONE: 1, // 1
+TWO: 2, // 2
+THREE: 3, // 3
+NEGATIVE: -123, // -123
+DECIMAL: 3.14, // 3.14
+ONE: 1,
+TWO: 2,
+THREE: 3,
+NEGATIVE: -123,
+DECIMAL: 3.14,
|};
declare type A = $Values<typeof Label>;
declare type B = typeof Label.TWO;
Expand All @@ -59,9 +59,9 @@ declare type B = typeof Label.TWO;

exports[`should handle string enums: class 1`] = `
"declare var Label: {|
+LABEL_OPTIONAL: \\"LABEL_OPTIONAL\\", // \\"LABEL_OPTIONAL\\"
+LABEL_REQUIRED: \\"LABEL_REQUIRED\\", // \\"LABEL_REQUIRED\\"
+LABEL_REPEATED: \\"LABEL_REPEATED\\", // \\"LABEL_REPEATED\\"
+LABEL_OPTIONAL: \\"LABEL_OPTIONAL\\",
+LABEL_REQUIRED: \\"LABEL_REQUIRED\\",
+LABEL_REPEATED: \\"LABEL_REPEATED\\",
|};
declare type A = $Values<typeof Label>;
declare type B = typeof Label.LABEL_REQUIRED;
Expand Down
43 changes: 21 additions & 22 deletions src/__tests__/__snapshots__/interfaces.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ exports[`should handle interface inheritance 1`] = `
"declare interface User {
firstName: string;
}
declare type SpecialUser = {
nice: number,
...
} & User;
declare type SpecialUser = { nice: number, ... } & User;
"
`;

exports[`should handle interface inheritance 2`] = `
"declare type User = {
firstName: string,
};
"declare type User = { firstName: string, ... };
declare type SpecialUser = {
...$Exact<User>,

nice: number,
...
};
"
`;

exports[`should handle interface inheritance 3`] = `
"declare type User = {|
firstName: string,
|};
"declare type User = {| firstName: string |};
declare type SpecialUser = {|
...$Exact<User>,

nice: number,
|};
"
`;

exports[`should handle interface inheritance 4`] = `
"declare interface User {
firstName: string;
}
declare type SpecialUser = { nice: number, ... } & User;
"
`;

exports[`should handle interface merging 1`] = `
"declare interface User {
firstName: string;
Expand All @@ -59,6 +59,7 @@ exports[`should handle interface merging 2`] = `
firstName: string,
lastName: string,
username: string,
...
};
"
`;
Expand All @@ -70,11 +71,7 @@ exports[`should handle mutli-extends pattern 1`] = `
declare interface PenStroke {
penWidth: number;
}
declare type Square = {
sideLength: number,
...
} & Shape &
PenStroke;
declare type Square = { sideLength: number, ... } & Shape & PenStroke;
"
`;

Expand All @@ -86,9 +83,7 @@ exports[`should handle single interface 1`] = `
`;

exports[`should handle single interface 2`] = `
"declare type User = {
firstName: string,
};
"declare type User = { firstName: string, ... };
"
`;

Expand Down Expand Up @@ -133,8 +128,12 @@ exports[`should handle untyped array binding pattern 1`] = `
exports[`should handle untyped object binding pattern 1`] = `
"declare interface ObjectBinding {
(): void;
(x: {}): void;
(x: { a: any, b: any }): void;
(x: { ... }): void;
(x: {
a: any,
b: any,
...
}): void;
}
"
`;
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/__snapshots__/mapped-types.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should handle mapped types 1`] = `
"declare type Ref<T> = {
current: T | null,
...
};
"declare type Ref<T> = { current: T | null, ... };
declare type SourceUnion = \\"a\\" | \\"b\\" | \\"c\\";
declare type SourceObject = {
a: number,
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/__snapshots__/module-identifiers.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
exports[`should handle global types jsx 1`] = `
"import * as React from \\"react\\";
declare function s(node: React$Node): void;
declare type Props = {
children: React$Node,
...
};
declare type Props = { children: React$Node, ... };
declare class Component mixins React.Component<Props> {
render(): React$Node;
}
Expand Down
10 changes: 2 additions & 8 deletions src/__tests__/__snapshots__/modules.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ exports[`should handle module 1`] = `
value: T,
...
}
| {
type: \\"nothing\\",
...
};
declare export type Ref<T> = {
current: T,
...
};
| { type: \\"nothing\\", ... };
declare export type Ref<T> = { current: T, ... };
declare export var ok: number;
}
"
Expand Down
Loading