diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3940be5d698..bfa398f190d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4115,7 +4115,7 @@ namespace ts { else { parameters.push(paramSymbol); } - + if (param.type && param.type.kind === SyntaxKind.StringLiteralType) { hasStringLiterals = true; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ab8de44ec98..21536da36ff 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -818,26 +818,25 @@ namespace ts { getSignatureConstructor(): new (checker: TypeChecker) => Signature; } - // TODO: Add a 'this' parameter after I update the previous-version compiler function Symbol(flags: SymbolFlags, name: string) { - (this).flags = flags; - (this).name = name; - (this).declarations = undefined; + this.flags = flags; + this.name = name; + this.declarations = undefined; } function Type(checker: TypeChecker, flags: TypeFlags) { - (this).flags = flags; + this.flags = flags; } function Signature(checker: TypeChecker) { } function Node(kind: SyntaxKind, pos: number, end: number) { - (this).kind = kind; - (this).pos = pos; - (this).end = end; - (this).flags = NodeFlags.None; - (this).parent = undefined; + this.kind = kind; + this.pos = pos; + this.end = end; + this.flags = NodeFlags.None; + this.parent = undefined; } export let objectAllocator: ObjectAllocator = { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 88c77aa5759..803ae47b0fd 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -933,9 +933,8 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - // TODO: needs to have this: Program function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { - return runWithCancellationToken(() => emitWorker((this), sourceFile, writeFileCallback, cancellationToken)); + return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); } function isEmitBlocked(emitFileName: string): boolean { diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index fb61f8b78b8..8abf1432b0c 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -4,10 +4,10 @@ namespace ts { export interface SourceMapWriter { getSourceMapData(): SourceMapData; - setSourceFile: (sourceFile: SourceFile) => void; - emitPos: (pos: number) => void; - emitStart: (range: TextRange) => void; - emitEnd: (range: TextRange, stopOverridingSpan?: boolean) => void; + setSourceFile(sourceFile: SourceFile): void; + emitPos(pos: number): void; + emitStart(range: TextRange): void; + emitEnd(range: TextRange, stopOverridingSpan?: boolean): void; changeEmitSourcePos(): void; getText(): string; getSourceMappingURL(): string; diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 1a9da39bf9a..bf25d39aa43 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -63,7 +63,7 @@ namespace ts { useCaseSensitiveFileNames?: boolean; echo(s: string): void; quit(exitCode?: number): void; - fileExists: (path: string) => boolean; + fileExists(path: string): boolean; directoryExists(path: string): boolean; createDirectory(path: string): void; resolvePath(path: string): string; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9c2612d96b6..6e0ccc3bf66 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1593,8 +1593,8 @@ namespace ts { } export interface ScriptReferenceHost { - getCompilerOptions: () => CompilerOptions; - getSourceFile: (fileName: string) => SourceFile; + getCompilerOptions(): CompilerOptions; + getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } @@ -1625,7 +1625,7 @@ namespace ts { /** * Get a list of files in the program */ - getSourceFiles: () => SourceFile[]; + getSourceFiles(): SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then @@ -1650,7 +1650,7 @@ namespace ts { */ getTypeChecker(): TypeChecker; - /* @internal */ getCommonSourceDirectory: () => string; + /* @internal */ getCommonSourceDirectory(): string; // For testing purposes only. Should not be used by any other consumers (including the // language service). @@ -1905,11 +1905,11 @@ namespace ts { getReferencedImportDeclaration(node: Identifier): Declaration; getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; isDeclarationWithCollidingName(node: Declaration): boolean; - isValueAliasDeclaration: (node: Node) => boolean; - isReferencedAliasDeclaration: (node: Node, checkChildren?: boolean) => boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; - isDeclarationVisible: (node: Declaration) => boolean; + isDeclarationVisible(node: Declaration): boolean; collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; @@ -2430,7 +2430,7 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; - strictThis?: boolean, + strictThis?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bce821c3756..bab66eb0688 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -32,11 +32,11 @@ namespace ts { } export interface EmitHost extends ScriptReferenceHost { - getSourceFiles: () => SourceFile[]; + getSourceFiles(): SourceFile[]; - getCommonSourceDirectory: () => string; - getCanonicalFileName: (fileName: string) => string; - getNewLine: () => string; + getCommonSourceDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; isEmitBlocked(emitFileName: string): boolean; @@ -1869,11 +1869,11 @@ namespace ts { } export interface EmitTextWriter { - write: (s: string) => void; - writeTextOfNode: (text: string, node: Node) => void; - writeLine: () => void; - increaseIndent: () => void; - decreaseIndent: () => void; + write(s: string): void; + writeTextOfNode(text: string, node: Node): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; getText(): string; rawWrite(s: string): void; writeLiteral(s: string): void; @@ -2490,7 +2490,7 @@ namespace ts { * as the fallback implementation does not check for circular references by default. */ export const stringify: (value: any) => string = typeof JSON !== "undefined" && JSON.stringify - ? JSON.stringify + ? JSON.stringify : stringifyFallback; /** diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 3b211a0d91a..2b0c95c0a61 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -417,24 +417,24 @@ namespace Harness.Path { namespace Harness { export interface IO { - args(): string[]; newLine(): string; - readFile(this: ts.System | IO, path: string): string; - writeFile(path: string, contents: string): void; - resolvePath(path: string): string; - fileExists: (fileName: string) => boolean; - directoryExists: (path: string) => boolean; - createDirectory(path: string): void; - getExecutingFilePath(this: ts.System | IO): string; getCurrentDirectory(): string; - readDirectory(path: string, extension?: string, exclude?: string[]): string[]; - getMemoryUsage?(): number; - exit(exitCode?: number): void; - deleteFile(fileName: string): void; - directoryName: (path: string) => string; - listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; - log: (text: string) => void; useCaseSensitiveFileNames(): boolean; + resolvePath(path: string): string; + readFile(path: string): string; + writeFile(path: string, contents: string): void; + directoryName(path: string): string; + createDirectory(path: string): void; + fileExists(fileName: string): boolean; + directoryExists(path: string): boolean; + deleteFile(fileName: string): void; + listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; + log(text: string): void; + getMemoryUsage?(): number; + args(): string[]; + getExecutingFilePath(): string; + exit(exitCode?: number): void; + readDirectory(path: string, extension?: string, exclude?: string[]): string[]; } export var IO: IO; diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index dbc05112f3e..cc5e06ab920 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -70,11 +70,11 @@ interface IOLog { interface PlaybackControl { startReplayFromFile(logFileName: string): void; - startReplayFromString(this: PlaybackControl, logContents: string): void; - startReplayFromData(this: PlaybackControl, log: IOLog): void; + startReplayFromString(logContents: string): void; + startReplayFromData(log: IOLog): void; endReplay(): void; startRecord(logFileName: string): void; - endRecord(this: PlaybackControl): void; + endRecord(): void; } namespace Playback { @@ -127,8 +127,6 @@ namespace Playback { function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void; function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void; function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void { - // TODO: Define a common interface over ts.System | Harness.IO and stop passing a union type. - const underlyingShim: any = underlying; ts.forEach(Object.keys(underlying), prop => { (wrapper)[prop] = (underlying)[prop]; }); @@ -156,20 +154,20 @@ namespace Playback { }; wrapper.startReplayFromFile = logFn => { - wrapper.startReplayFromString(underlyingShim.readFile(logFn)); + wrapper.startReplayFromString(underlying.readFile(logFn)); }; wrapper.endRecord = () => { if (recordLog !== undefined) { let i = 0; const fn = () => recordLogFileNameBase + i + ".json"; - while (underlyingShim.fileExists(fn())) i++; - underlyingShim.writeFile(fn(), JSON.stringify(recordLog)); + while (underlying.fileExists(fn())) i++; + underlying.writeFile(fn(), JSON.stringify(recordLog)); recordLog = undefined; } }; wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( - path => callAndRecord(underlyingShim.fileExists(path), recordLog.fileExists, { path }), + path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }), memoize(path => { // If we read from the file, it must exist if (findResultByPath(wrapper, replayLog.filesRead, path, null) !== null) { @@ -186,10 +184,10 @@ namespace Playback { return replayLog.executingPath; } else if (recordLog !== undefined) { - return recordLog.executingPath = underlyingShim.getExecutingFilePath(); + return recordLog.executingPath = underlying.getExecutingFilePath(); } else { - return underlyingShim.getExecutingFilePath(); + return underlying.getExecutingFilePath(); } }; @@ -198,20 +196,20 @@ namespace Playback { return replayLog.currentDirectory || ""; } else if (recordLog !== undefined) { - return recordLog.currentDirectory = underlyingShim.getCurrentDirectory(); + return recordLog.currentDirectory = underlying.getCurrentDirectory(); } else { - return underlyingShim.getCurrentDirectory(); + return underlying.getCurrentDirectory(); } }; wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)( - path => callAndRecord(underlyingShim.resolvePath(path), recordLog.pathsResolved, { path }), + path => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path }), memoize(path => findResultByFields(replayLog.pathsResolved, { path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path)))); wrapper.readFile = recordReplay(wrapper.readFile, underlying)( path => { - const result = underlyingShim.readFile(path); + const result = underlying.readFile(path); const logEntry = { path, codepage: 0, result: { contents: result, codepage: 0 } }; recordLog.filesRead.push(logEntry); return result; @@ -228,14 +226,14 @@ namespace Playback { (path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path)); wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( - (path: string, contents: string) => callAndRecord(underlyingShim.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), + (path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), (path: string, contents: string) => noOpReplay("writeFile")); wrapper.exit = (exitCode) => { if (recordLog !== undefined) { wrapper.endRecord(); } - underlyingShim.exit(exitCode); + underlying.exit(exitCode); }; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 5516b18e0de..e2ec5cc159f 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1834,7 +1834,7 @@ namespace ts.server { if (!rangeEnd) { rangeEnd = this.root.charCount(); } - const walkFns: ILineIndexWalker = { + const walkFns = { goSubtree: true, done: false, leaf: function (relativeStart: number, relativeLength: number, ll: LineLeaf) { diff --git a/src/server/node.d.ts b/src/server/node.d.ts index 8e4d8c28e9b..0bde0bb6602 100644 --- a/src/server/node.d.ts +++ b/src/server/node.d.ts @@ -68,7 +68,7 @@ interface BufferConstructor { new (array: any[]): Buffer; prototype: Buffer; isBuffer(obj: any): boolean; - byteLength: (string: string, encoding?: string) => number; + byteLength(string: string, encoding?: string): number; concat(list: Buffer[], totalLength?: number): Buffer; } declare var Buffer: BufferConstructor; @@ -190,7 +190,7 @@ declare namespace NodeJS { nextTick(callback: Function): void; umask(mask?: number): number; uptime(): number; - hrtime: (time?: number[]) => number[]; + hrtime(time?: number[]): number[]; // Worker send? (message: any, sendHandle?: any): void; diff --git a/src/services/formatting/ruleOperationContext.ts b/src/services/formatting/ruleOperationContext.ts index 3108095e8e6..47330faa0dd 100644 --- a/src/services/formatting/ruleOperationContext.ts +++ b/src/services/formatting/ruleOperationContext.ts @@ -6,8 +6,8 @@ namespace ts.formatting { export class RuleOperationContext { private customContextChecks: { (context: FormattingContext): boolean; }[]; - constructor(...funcs: { (this: typeof Rules, context: FormattingContext): boolean; }[]) { - this.customContextChecks = <{ (this: any, context: FormattingContext): boolean }[]>funcs; + constructor(...funcs: { (context: FormattingContext): boolean; }[]) { + this.customContextChecks = funcs; } static Any: RuleOperationContext = new RuleOperationContext(); diff --git a/src/services/services.ts b/src/services/services.ts index 1a43f9a744b..496dd7172ea 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -19,15 +19,15 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; - getStart(this: Node, sourceFile?: SourceFile): number; + getStart(sourceFile?: SourceFile): number; getFullStart(): number; - getEnd(this: Node): number; + getEnd(): number; getWidth(sourceFile?: SourceFile): number; getFullWidth(): number; getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; - getFirstToken(this: Node, sourceFile?: SourceFile): Node; + getFirstToken(sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0363e45a64a..afdc85fffd8 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -769,7 +769,7 @@ namespace ts { * The default is CRLF. */ export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost) { - return (host).getNewLine ? (host).getNewLine() : carriageReturnLineFeed; + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; } export function lineBreakPart() {