mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
fix: make requested changes from PR
This commit is contained in:
parent
d15eb07b56
commit
de79fe5294
7
types/prettier/parser-angular.d.ts
vendored
7
types/prettier/parser-angular.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
7
types/prettier/parser-babylon.d.ts
vendored
7
types/prettier/parser-babylon.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
7
types/prettier/parser-flow.d.ts
vendored
7
types/prettier/parser-flow.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
5
types/prettier/parser-glimmer.d.ts
vendored
5
types/prettier/parser-glimmer.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
import { Plugin } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
7
types/prettier/parser-graphql.d.ts
vendored
7
types/prettier/parser-graphql.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
7
types/prettier/parser-html.d.ts
vendored
7
types/prettier/parser-html.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
7
types/prettier/parser-markdown.d.ts
vendored
7
types/prettier/parser-markdown.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
7
types/prettier/parser-postcss.d.ts
vendored
7
types/prettier/parser-postcss.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
7
types/prettier/parser-typescript.d.ts
vendored
7
types/prettier/parser-typescript.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
7
types/prettier/parser-yaml.d.ts
vendored
7
types/prettier/parser-yaml.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
import { Plugin } from './';
|
||||
import { Parser } from './';
|
||||
|
||||
declare const plugin: Plugin;
|
||||
export as namespace plugin;
|
||||
export = plugin;
|
||||
declare const parser: { parsers: { [parserName: string]: Parser } };
|
||||
export = parser;
|
||||
|
||||
@ -1,21 +1,29 @@
|
||||
import * as prettier from 'prettier';
|
||||
import { ExpressionStatement, CallExpression, Identifier } from 'babel-types';
|
||||
import * as prettierStandalone from 'prettier/standalone';
|
||||
import typescriptParser = require('prettier/parser-typescript');
|
||||
import graphqlParser = require('prettier/parser-graphql');
|
||||
import babylonParser = require('prettier/parser-babylon');
|
||||
import htmlParser = require('prettier/parser-html');
|
||||
import markdownParser = require('prettier/parser-markdown');
|
||||
import postcssParser = require('prettier/parser-postcss');
|
||||
import yamlParser = require('prettier/parser-yaml');
|
||||
|
||||
const formatted = prettier.format("foo ( );", { semi: false });
|
||||
const formatted = prettier.format('foo ( );', { semi: false });
|
||||
|
||||
const isFormatted = prettier.check("foo ( );", { semi: false });
|
||||
const isFormatted = prettier.check('foo ( );', { semi: false });
|
||||
|
||||
const result = prettier.formatWithCursor(" 1", { cursorOffset: 2 });
|
||||
const result = prettier.formatWithCursor(' 1', { cursorOffset: 2 });
|
||||
|
||||
const customFormatted = prettier.format("lodash ( )", {
|
||||
const customFormatted = prettier.format('lodash ( )', {
|
||||
parser(text, { babylon }) {
|
||||
const ast = babylon(text);
|
||||
const statement = ast.program.body[0] as ExpressionStatement;
|
||||
const expression = statement.expression as CallExpression;
|
||||
const identifier = expression.callee as Identifier;
|
||||
identifier.name = "_";
|
||||
identifier.name = '_';
|
||||
return ast;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
prettier.resolveConfig('path/to/somewhere').then(options => {
|
||||
@ -28,10 +36,10 @@ if (prettier.getFileInfo.sync('./tsconfig.json').inferredParser !== 'json') {
|
||||
throw new Error('Bad parser');
|
||||
}
|
||||
|
||||
prettier.getFileInfo('./tsconfig.json').then((result) => {
|
||||
if (result.inferredParser !== 'json') {
|
||||
throw new Error('Bad parser');
|
||||
}
|
||||
prettier.getFileInfo('./tsconfig.json').then(result => {
|
||||
if (result.inferredParser !== 'json') {
|
||||
throw new Error('Bad parser');
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
@ -45,4 +53,17 @@ if (options !== null) {
|
||||
prettier.clearConfigCache();
|
||||
|
||||
const currentSupportInfo = prettier.getSupportInfo();
|
||||
const specificSupportInfo = prettier.getSupportInfo("1.8.0");
|
||||
const specificSupportInfo = prettier.getSupportInfo('1.8.0');
|
||||
|
||||
prettierStandalone.formatWithCursor(' 1', { cursorOffset: 2, parser: 'babel' });
|
||||
|
||||
prettierStandalone.format(' 1', { parser: 'babel' });
|
||||
prettierStandalone.check(' console.log(b)');
|
||||
|
||||
typescriptParser.parsers.typescript.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any
|
||||
graphqlParser.parsers.graphql.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any
|
||||
babylonParser.parsers.babylon.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any
|
||||
htmlParser.parsers.html.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any
|
||||
markdownParser.parsers.markdown.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any
|
||||
postcssParser.parsers.postcss.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any
|
||||
yamlParser.parsers.yaml.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any
|
||||
|
||||
21
types/prettier/standalone.d.ts
vendored
21
types/prettier/standalone.d.ts
vendored
@ -1,18 +1,5 @@
|
||||
import { CursorOptions, CursorResult, Options, Plugin } from './';
|
||||
|
||||
type Omit<GType, GKeys extends keyof GType> = Pick<
|
||||
GType,
|
||||
Exclude<keyof GType, GKeys>
|
||||
>;
|
||||
|
||||
type MakeRequired<GType extends {}, GKeys extends keyof GType> = Omit<
|
||||
GType,
|
||||
GKeys
|
||||
> &
|
||||
{ [P in GKeys]-?: GType[P] };
|
||||
|
||||
type MR<GType extends { parser?: any }> = MakeRequired<GType, 'parser'>;
|
||||
|
||||
/**
|
||||
* formatWithCursor both formats the code, and translates a cursor position from unformatted code to formatted code.
|
||||
* This is useful for editor integrations, to prevent the cursor from moving when code is formatted
|
||||
@ -26,18 +13,18 @@ type MR<GType extends { parser?: any }> = MakeRequired<GType, 'parser'>;
|
||||
*/
|
||||
export function formatWithCursor(
|
||||
source: string,
|
||||
options: MR<CursorOptions>,
|
||||
options: CursorOptions,
|
||||
): CursorResult;
|
||||
|
||||
/**
|
||||
* `format` is used to format text using Prettier. [Options](https://github.com/prettier/prettier#options) may be provided to override the defaults.
|
||||
*/
|
||||
export function format(source: string, options?: MR<Options>): string;
|
||||
export function format(source: string, options?: Options): string;
|
||||
|
||||
/**
|
||||
* `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
|
||||
* This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
|
||||
*/
|
||||
export function check(source: string, options?: MR<Options>): boolean;
|
||||
export function check(source: string, options?: Options): boolean;
|
||||
|
||||
export { Plugin };
|
||||
export as namespace prettier;
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
"parser-angular.d.ts",
|
||||
"parser-babylon.d.ts",
|
||||
"parser-flow.d.ts",
|
||||
"parser-glimmer.d.ts",
|
||||
"parser-graphql.d.ts",
|
||||
"parser-html.d.ts",
|
||||
"parser-markdown.d.ts",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user