Undo strictThis-clean changes

Also fix other lint.
This commit is contained in:
Nathan Shively-Sanders 2016-02-02 16:00:52 -08:00
parent 675e0816d4
commit f6361cec66
14 changed files with 73 additions and 77 deletions

View File

@ -4115,7 +4115,7 @@ namespace ts {
else {
parameters.push(paramSymbol);
}
if (param.type && param.type.kind === SyntaxKind.StringLiteralType) {
hasStringLiterals = true;
}

View File

@ -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) {
(<any>this).flags = flags;
(<any>this).name = name;
(<any>this).declarations = undefined;
this.flags = flags;
this.name = name;
this.declarations = undefined;
}
function Type(checker: TypeChecker, flags: TypeFlags) {
(<any>this).flags = flags;
this.flags = flags;
}
function Signature(checker: TypeChecker) {
}
function Node(kind: SyntaxKind, pos: number, end: number) {
(<any>this).kind = kind;
(<any>this).pos = pos;
(<any>this).end = end;
(<any>this).flags = NodeFlags.None;
(<any>this).parent = undefined;
this.kind = kind;
this.pos = pos;
this.end = end;
this.flags = NodeFlags.None;
this.parent = undefined;
}
export let objectAllocator: ObjectAllocator = {

View File

@ -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((<any>this), sourceFile, writeFileCallback, cancellationToken));
return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken));
}
function isEmitBlocked(emitFileName: string): boolean {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
? <any>JSON.stringify
? JSON.stringify
: stringifyFallback;
/**

View File

@ -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;

View File

@ -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 => {
(<any>wrapper)[prop] = (<any>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);
};
}

View File

@ -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) {

View File

@ -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;

View File

@ -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();

View File

@ -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;
}

View File

@ -769,7 +769,7 @@ namespace ts {
* The default is CRLF.
*/
export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost) {
return (<any>host).getNewLine ? (<any>host).getNewLine() : carriageReturnLineFeed;
return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed;
}
export function lineBreakPart() {