Apply 'unified-signatures' tslint rule (#19738)

* Apply 'unified-signatures' tslint rule

* Fix new failure
This commit is contained in:
Andy
2017-11-06 18:38:03 -08:00
committed by GitHub
parent 40efd1b3bd
commit 77b24aec83
6 changed files with 17 additions and 26 deletions

View File

@@ -70,11 +70,10 @@ namespace ts {
// Literals
export function createLiteral(value: string): StringLiteral;
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
export function createLiteral(value: string | StringLiteral | NumericLiteral | Identifier): StringLiteral;
export function createLiteral(value: number): NumericLiteral;
export function createLiteral(value: boolean): BooleanLiteral;
/** Create a string literal whose source text is read from a source node during emit. */
export function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral;
export function createLiteral(value: string | number | boolean): PrimaryExpression;
export function createLiteral(value: string | number | boolean | StringLiteral | NumericLiteral | Identifier): PrimaryExpression {
if (typeof value === "number") {
@@ -113,6 +112,7 @@ namespace ts {
export function createIdentifier(text: string): Identifier;
/* @internal */
// tslint:disable-next-line unified-signatures
export function createIdentifier(text: string, typeArguments: ReadonlyArray<TypeNode>): Identifier;
export function createIdentifier(text: string, typeArguments?: ReadonlyArray<TypeNode>): Identifier {
const node = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
@@ -166,6 +166,7 @@ namespace ts {
/** Create a unique name generated for a node. */
export function getGeneratedNameForNode(node: Node): Identifier;
// tslint:disable-next-line unified-signatures
/*@internal*/ export function getGeneratedNameForNode(node: Node, shouldSkipNameGenerationScope?: boolean): Identifier;
export function getGeneratedNameForNode(node: Node, shouldSkipNameGenerationScope?: boolean): Identifier {
const name = createIdentifier("");

View File

@@ -483,9 +483,7 @@ namespace FourSlash {
}
// Opens a file given its 0-based index or fileName
public openFile(index: number, content?: string, scriptKindName?: string): void;
public openFile(name: string, content?: string, scriptKindName?: string): void;
public openFile(indexOrName: any, content?: string, scriptKindName?: string) {
public openFile(indexOrName: number | string, content?: string, scriptKindName?: string): void {
const fileToOpen: FourSlashFile = this.findFile(indexOrName);
fileToOpen.fileName = ts.normalizeSlashes(fileToOpen.fileName);
this.activeFile = fileToOpen;
@@ -3093,7 +3091,7 @@ Actual: ${stringify(fullActual)}`);
this.raiseError(`Expected "${stringify({ entryId, text, documentation, kind })}" to be in list [${itemsString}]`);
}
private findFile(indexOrName: any) {
private findFile(indexOrName: string | number) {
let result: FourSlashFile;
if (typeof indexOrName === "number") {
const index = <number>indexOrName;
@@ -3745,9 +3743,7 @@ namespace FourSlashInterface {
this.state.goToImplementation();
}
public position(position: number, fileIndex?: number): void;
public position(position: number, fileName?: string): void;
public position(position: number, fileNameOrIndex?: any): void {
public position(position: number, fileNameOrIndex?: string | number): void {
if (fileNameOrIndex !== undefined) {
this.file(fileNameOrIndex);
}
@@ -3757,9 +3753,7 @@ namespace FourSlashInterface {
// Opens a file, given either its index as it
// appears in the test source, or its filename
// as specified in the test metadata
public file(index: number, content?: string, scriptKindName?: string): void;
public file(name: string, content?: string, scriptKindName?: string): void;
public file(indexOrName: any, content?: string, scriptKindName?: string): void {
public file(indexOrName: number | string, content?: string, scriptKindName?: string): void {
this.state.openFile(indexOrName, content, scriptKindName);
}
@@ -3966,17 +3960,14 @@ namespace FourSlashInterface {
this.state.verifyGoToDefinitionIs(endMarkers);
}
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[]): void;
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[], range: FourSlash.Range): void;
public goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void;
public goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[], range?: FourSlash.Range): void;
public goToDefinition(startsAndEnds: [string | string[], string | string[]][] | { [startMarkerName: string]: string | string[] }): void;
public goToDefinition(arg0: any, endMarkerName?: string | string[]) {
this.state.verifyGoToDefinition(arg0, endMarkerName);
}
public goToType(startMarkerName: string | string[], endMarkerName: string | string[]): void;
public goToType(startsAndEnds: [string | string[], string | string[]][]): void;
public goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
public goToType(startsAndEnds: [string | string[], string | string[]][] | { [startMarkerName: string]: string | string[] }): void;
public goToType(arg0: any, endMarkerName?: string | string[]) {
this.state.verifyGoToType(arg0, endMarkerName);
}

View File

@@ -5,9 +5,11 @@ namespace ts {
getChildAt(index: number, sourceFile?: SourceFile): Node;
getChildren(sourceFile?: SourceFile): Node[];
/* @internal */
// tslint:disable-next-line unified-signatures
getChildren(sourceFile?: SourceFileLike): Node[];
getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
/* @internal */
// tslint:disable-next-line unified-signatures
getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number;
getFullStart(): number;
getEnd(): number;

View File

@@ -3271,11 +3271,10 @@ declare namespace ts {
}
declare namespace ts {
function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T>;
function createLiteral(value: string): StringLiteral;
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
function createLiteral(value: string | StringLiteral | NumericLiteral | Identifier): StringLiteral;
function createLiteral(value: number): NumericLiteral;
function createLiteral(value: boolean): BooleanLiteral;
/** Create a string literal whose source text is read from a source node during emit. */
function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral;
function createLiteral(value: string | number | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createIdentifier(text: string): Identifier;

View File

@@ -3218,11 +3218,10 @@ declare namespace ts {
}
declare namespace ts {
function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T>;
function createLiteral(value: string): StringLiteral;
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
function createLiteral(value: string | StringLiteral | NumericLiteral | Identifier): StringLiteral;
function createLiteral(value: number): NumericLiteral;
function createLiteral(value: boolean): BooleanLiteral;
/** Create a string literal whose source text is read from a source node during emit. */
function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral;
function createLiteral(value: string | number | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createIdentifier(text: string): Identifier;

View File

@@ -100,7 +100,6 @@
"radix": false,
"space-before-function-paren": false,
"trailing-comma": false,
"unified-signatures": false,
// These should be done automatically by a formatter. https://github.com/Microsoft/TypeScript/issues/18340
"align": false,