flow-typed: fix Prettier libdefs (#925)

Summary:
This patches in the following two pull requests from upstream:

  - https://github.com/flow-typed/flow-typed/pull/2856
  - https://github.com/flow-typed/flow-typed/pull/2860

The first exports types so that they can be used in client code.
The second fixes a broken type definition.

Test Plan:
See the test plans in those two PRs.

wchargin-branch: flow-typed-fix-prettier
This commit is contained in:
William Chargin 2018-10-19 08:54:00 -07:00 committed by GitHub
parent ee4900616b
commit 4558d775a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 22 deletions

View File

@ -2,11 +2,11 @@
// flow-typed version: cc7a557b34/prettier_v1.x.x/flow_>=v0.56.x // flow-typed version: cc7a557b34/prettier_v1.x.x/flow_>=v0.56.x
declare module "prettier" { declare module "prettier" {
declare type AST = Object; declare export type AST = Object;
declare type Doc = Object; declare export type Doc = Object;
declare type FastPath = Object; declare export type FastPath = Object;
declare type PrettierParserName = declare export type PrettierParserName =
| "babylon" | "babylon"
| "flow" | "flow"
| "typescript" | "typescript"
@ -19,17 +19,17 @@ declare module "prettier" {
| "markdown" | "markdown"
| "vue"; | "vue";
declare type PrettierParser = { declare export type PrettierParser = {
[name: PrettierParserName]: (text: string, options?: Object) => AST [name: PrettierParserName]: (text: string, options?: Object) => AST
}; };
declare type CustomParser = ( declare export type CustomParser = (
text: string, text: string,
parsers: PrettierParser, parsers: PrettierParser,
options: Options options: Options
) => AST; ) => AST;
declare type Options = {| declare export type Options = {|
printWidth?: number, printWidth?: number,
tabWidth?: number, tabWidth?: number,
useTabs?: boolean, useTabs?: boolean,
@ -49,13 +49,13 @@ declare module "prettier" {
plugins?: Array<string | Plugin> plugins?: Array<string | Plugin>
|}; |};
declare type Plugin = { declare export type Plugin = {
languages: SupportLanguage, languages: SupportLanguage,
parsers: { [parserName: string]: Parser }, parsers: { [parserName: string]: Parser },
printers: { [astFormat: string]: Printer } printers: { [astFormat: string]: Printer }
}; };
declare type Parser = { declare export type Parser = {
parse: ( parse: (
text: string, text: string,
parsers: { [parserName: string]: Parser }, parsers: { [parserName: string]: Parser },
@ -64,7 +64,7 @@ declare module "prettier" {
astFormat: string astFormat: string
}; };
declare type Printer = { declare export type Printer = {
print: ( print: (
path: FastPath, path: FastPath,
options: Object, options: Object,
@ -78,7 +78,7 @@ declare module "prettier" {
) => ?Doc ) => ?Doc
}; };
declare type CursorOptions = {| declare export type CursorOptions = {|
cursorOffset: number, cursorOffset: number,
printWidth?: $PropertyType<Options, "printWidth">, printWidth?: $PropertyType<Options, "printWidth">,
tabWidth?: $PropertyType<Options, "tabWidth">, tabWidth?: $PropertyType<Options, "tabWidth">,
@ -97,18 +97,18 @@ declare module "prettier" {
plugins?: $PropertyType<Options, "plugins"> plugins?: $PropertyType<Options, "plugins">
|}; |};
declare type CursorResult = {| declare export type CursorResult = {|
formatted: string, formatted: string,
cursorOffset: number cursorOffset: number
|}; |};
declare type ResolveConfigOptions = {| declare export type ResolveConfigOptions = {|
useCache?: boolean, useCache?: boolean,
config?: string, config?: string,
editorconfig?: boolean editorconfig?: boolean
|}; |};
declare type SupportLanguage = { declare export type SupportLanguage = {
name: string, name: string,
since: string, since: string,
parsers: Array<string>, parsers: Array<string>,
@ -124,7 +124,7 @@ declare module "prettier" {
vscodeLanguageIds: Array<string> vscodeLanguageIds: Array<string>
}; };
declare type SupportOption = {| declare export type SupportOption = {|
since: string, since: string,
type: "int" | "boolean" | "choice" | "path", type: "int" | "boolean" | "choice" | "path",
deprecated?: string, deprecated?: string,
@ -136,18 +136,18 @@ declare module "prettier" {
choices?: SupportOptionChoice choices?: SupportOptionChoice
|}; |};
declare type SupportOptionRedirect = {| declare export type SupportOptionRedirect = {|
options: string, options: string,
value: SupportOptionValue value: SupportOptionValue
|}; |};
declare type SupportOptionRange = {| declare export type SupportOptionRange = {|
start: number, start: number,
end: number, end: number,
step: number step: number
|}; |};
declare type SupportOptionChoice = {| declare export type SupportOptionChoice = {|
value: boolean | string, value: boolean | string,
description?: string, description?: string,
since?: string, since?: string,
@ -155,20 +155,20 @@ declare module "prettier" {
redirect?: SupportOptionValue redirect?: SupportOptionValue
|}; |};
declare type SupportOptionValue = number | boolean | string; declare export type SupportOptionValue = number | boolean | string;
declare type SupportInfo = {| declare export type SupportInfo = {|
languages: Array<SupportLanguage>, languages: Array<SupportLanguage>,
options: Array<SupportOption> options: Array<SupportOption>
|}; |};
declare type Prettier = {| declare export type Prettier = {|
format: (source: string, options?: Options) => string, format: (source: string, options?: Options) => string,
check: (source: string, options?: Options) => boolean, check: (source: string, options?: Options) => boolean,
formatWithCursor: (source: string, options: CursorOptions) => CursorResult, formatWithCursor: (source: string, options: CursorOptions) => CursorResult,
resolveConfig: { resolveConfig: {
(filePath: string, options?: ResolveConfigOptions): Promise<?Options>, (filePath: string, options?: ResolveConfigOptions): Promise<?Options>,
sync(filePath: string, options?: ResolveConfigOptions): Promise<?Options> sync(filePath: string, options?: ResolveConfigOptions): ?Options
}, },
clearConfigCache: () => void, clearConfigCache: () => void,
getSupportInfo: (version?: string) => SupportInfo getSupportInfo: (version?: string) => SupportInfo