Skip to content

Commit 77b24ae

Browse files
author
Andy
authored
Apply 'unified-signatures' tslint rule (microsoft#19738)
* Apply 'unified-signatures' tslint rule * Fix new failure
1 parent 40efd1b commit 77b24ae

6 files changed

Lines changed: 17 additions & 26 deletions

File tree

src/compiler/factory.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ namespace ts {
7070

7171
// Literals
7272

73-
export function createLiteral(value: string): StringLiteral;
73+
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
74+
export function createLiteral(value: string | StringLiteral | NumericLiteral | Identifier): StringLiteral;
7475
export function createLiteral(value: number): NumericLiteral;
7576
export function createLiteral(value: boolean): BooleanLiteral;
76-
/** Create a string literal whose source text is read from a source node during emit. */
77-
export function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral;
7877
export function createLiteral(value: string | number | boolean): PrimaryExpression;
7978
export function createLiteral(value: string | number | boolean | StringLiteral | NumericLiteral | Identifier): PrimaryExpression {
8079
if (typeof value === "number") {
@@ -113,6 +112,7 @@ namespace ts {
113112

114113
export function createIdentifier(text: string): Identifier;
115114
/* @internal */
115+
// tslint:disable-next-line unified-signatures
116116
export function createIdentifier(text: string, typeArguments: ReadonlyArray<TypeNode>): Identifier;
117117
export function createIdentifier(text: string, typeArguments?: ReadonlyArray<TypeNode>): Identifier {
118118
const node = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
@@ -166,6 +166,7 @@ namespace ts {
166166

167167
/** Create a unique name generated for a node. */
168168
export function getGeneratedNameForNode(node: Node): Identifier;
169+
// tslint:disable-next-line unified-signatures
169170
/*@internal*/ export function getGeneratedNameForNode(node: Node, shouldSkipNameGenerationScope?: boolean): Identifier;
170171
export function getGeneratedNameForNode(node: Node, shouldSkipNameGenerationScope?: boolean): Identifier {
171172
const name = createIdentifier("");

src/harness/fourslash.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,7 @@ namespace FourSlash {
483483
}
484484

485485
// Opens a file given its 0-based index or fileName
486-
public openFile(index: number, content?: string, scriptKindName?: string): void;
487-
public openFile(name: string, content?: string, scriptKindName?: string): void;
488-
public openFile(indexOrName: any, content?: string, scriptKindName?: string) {
486+
public openFile(indexOrName: number | string, content?: string, scriptKindName?: string): void {
489487
const fileToOpen: FourSlashFile = this.findFile(indexOrName);
490488
fileToOpen.fileName = ts.normalizeSlashes(fileToOpen.fileName);
491489
this.activeFile = fileToOpen;
@@ -3093,7 +3091,7 @@ Actual: ${stringify(fullActual)}`);
30933091
this.raiseError(`Expected "${stringify({ entryId, text, documentation, kind })}" to be in list [${itemsString}]`);
30943092
}
30953093

3096-
private findFile(indexOrName: any) {
3094+
private findFile(indexOrName: string | number) {
30973095
let result: FourSlashFile;
30983096
if (typeof indexOrName === "number") {
30993097
const index = <number>indexOrName;
@@ -3745,9 +3743,7 @@ namespace FourSlashInterface {
37453743
this.state.goToImplementation();
37463744
}
37473745

3748-
public position(position: number, fileIndex?: number): void;
3749-
public position(position: number, fileName?: string): void;
3750-
public position(position: number, fileNameOrIndex?: any): void {
3746+
public position(position: number, fileNameOrIndex?: string | number): void {
37513747
if (fileNameOrIndex !== undefined) {
37523748
this.file(fileNameOrIndex);
37533749
}
@@ -3757,9 +3753,7 @@ namespace FourSlashInterface {
37573753
// Opens a file, given either its index as it
37583754
// appears in the test source, or its filename
37593755
// as specified in the test metadata
3760-
public file(index: number, content?: string, scriptKindName?: string): void;
3761-
public file(name: string, content?: string, scriptKindName?: string): void;
3762-
public file(indexOrName: any, content?: string, scriptKindName?: string): void {
3756+
public file(indexOrName: number | string, content?: string, scriptKindName?: string): void {
37633757
this.state.openFile(indexOrName, content, scriptKindName);
37643758
}
37653759

@@ -3966,17 +3960,14 @@ namespace FourSlashInterface {
39663960
this.state.verifyGoToDefinitionIs(endMarkers);
39673961
}
39683962

3969-
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[]): void;
3970-
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[], range: FourSlash.Range): void;
3971-
public goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void;
3972-
public goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
3963+
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[], range?: FourSlash.Range): void;
3964+
public goToDefinition(startsAndEnds: [string | string[], string | string[]][] | { [startMarkerName: string]: string | string[] }): void;
39733965
public goToDefinition(arg0: any, endMarkerName?: string | string[]) {
39743966
this.state.verifyGoToDefinition(arg0, endMarkerName);
39753967
}
39763968

39773969
public goToType(startMarkerName: string | string[], endMarkerName: string | string[]): void;
3978-
public goToType(startsAndEnds: [string | string[], string | string[]][]): void;
3979-
public goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
3970+
public goToType(startsAndEnds: [string | string[], string | string[]][] | { [startMarkerName: string]: string | string[] }): void;
39803971
public goToType(arg0: any, endMarkerName?: string | string[]) {
39813972
this.state.verifyGoToType(arg0, endMarkerName);
39823973
}

src/services/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ namespace ts {
55
getChildAt(index: number, sourceFile?: SourceFile): Node;
66
getChildren(sourceFile?: SourceFile): Node[];
77
/* @internal */
8+
// tslint:disable-next-line unified-signatures
89
getChildren(sourceFile?: SourceFileLike): Node[];
910
getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
1011
/* @internal */
12+
// tslint:disable-next-line unified-signatures
1113
getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number;
1214
getFullStart(): number;
1315
getEnd(): number;

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,11 +3271,10 @@ declare namespace ts {
32713271
}
32723272
declare namespace ts {
32733273
function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T>;
3274-
function createLiteral(value: string): StringLiteral;
3274+
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
3275+
function createLiteral(value: string | StringLiteral | NumericLiteral | Identifier): StringLiteral;
32753276
function createLiteral(value: number): NumericLiteral;
32763277
function createLiteral(value: boolean): BooleanLiteral;
3277-
/** Create a string literal whose source text is read from a source node during emit. */
3278-
function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral;
32793278
function createLiteral(value: string | number | boolean): PrimaryExpression;
32803279
function createNumericLiteral(value: string): NumericLiteral;
32813280
function createIdentifier(text: string): Identifier;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,11 +3218,10 @@ declare namespace ts {
32183218
}
32193219
declare namespace ts {
32203220
function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T>;
3221-
function createLiteral(value: string): StringLiteral;
3221+
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
3222+
function createLiteral(value: string | StringLiteral | NumericLiteral | Identifier): StringLiteral;
32223223
function createLiteral(value: number): NumericLiteral;
32233224
function createLiteral(value: boolean): BooleanLiteral;
3224-
/** Create a string literal whose source text is read from a source node during emit. */
3225-
function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral;
32263225
function createLiteral(value: string | number | boolean): PrimaryExpression;
32273226
function createNumericLiteral(value: string): NumericLiteral;
32283227
function createIdentifier(text: string): Identifier;

tslint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
"radix": false,
101101
"space-before-function-paren": false,
102102
"trailing-comma": false,
103-
"unified-signatures": false,
104103

105104
// These should be done automatically by a formatter. https://github.com/Microsoft/TypeScript/issues/18340
106105
"align": false,

0 commit comments

Comments
 (0)