Merge pull request #9580 from Microsoft/compile-with-noImplicitThis

Compile with --noImplicitThis
This commit is contained in:
Nathan Shively-Sanders 2016-07-11 15:25:44 -07:00 committed by GitHub
commit f19844fbe9
11 changed files with 29 additions and 13 deletions

View File

@ -11,8 +11,11 @@ import newer = require("gulp-newer");
import tsc = require("gulp-typescript");
declare module "gulp-typescript" {
interface Settings {
stripInternal?: boolean;
pretty?: boolean;
newLine?: string;
noImplicitThis?: boolean;
stripInternal?: boolean;
types?: string[];
}
interface CompileStream extends NodeJS.ReadWriteStream {} // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required
}
@ -306,6 +309,11 @@ function needsUpdate(source: string | string[], dest: string | string[]): boolea
function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): tsc.Settings {
const copy: tsc.Settings = {};
copy.noEmitOnError = true;
copy.noImplicitAny = true;
copy.noImplicitThis = true;
copy.pretty = true;
copy.types = [];
for (const key in base) {
copy[key] = base[key];
}

View File

@ -284,7 +284,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
file(outFile, prereqs, function() {
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
var options = "--noImplicitAny --noEmitOnError --types --pretty";
var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types --pretty";
opts = opts || {};
// Keep comments when specifically requested
// or when in debug mode.

View File

@ -1237,20 +1237,20 @@ namespace ts {
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
}
function Symbol(flags: SymbolFlags, name: string) {
function Symbol(this: Symbol, flags: SymbolFlags, name: string) {
this.flags = flags;
this.name = name;
this.declarations = undefined;
}
function Type(checker: TypeChecker, flags: TypeFlags) {
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
this.flags = flags;
}
function Signature(checker: TypeChecker) {
}
function Node(kind: SyntaxKind, pos: number, end: number) {
function Node(this: Node, kind: SyntaxKind, pos: number, end: number) {
this.kind = kind;
this.pos = pos;
this.end = end;

View File

@ -1399,7 +1399,7 @@ namespace ts {
}
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult {
return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken));
return runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken));
}
function isEmitBlocked(emitFileName: string): boolean {

View File

@ -182,7 +182,7 @@ namespace ts {
return matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
}
return {
const wscriptSystem: System = {
args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
@ -201,7 +201,7 @@ namespace ts {
return fso.FolderExists(path);
},
createDirectory(directoryName: string) {
if (!this.directoryExists(directoryName)) {
if (!wscriptSystem.directoryExists(directoryName)) {
fso.CreateFolder(directoryName);
}
},
@ -221,6 +221,7 @@ namespace ts {
}
}
};
return wscriptSystem;
}
function getNodeSystem(): System {
@ -439,7 +440,7 @@ namespace ts {
return filter<string>(_fs.readdirSync(path), p => fileSystemEntryExists(combinePaths(path, p), FileSystemEntryKind.Directory));
}
return {
const nodeSystem: System = {
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
@ -501,7 +502,7 @@ namespace ts {
fileExists,
directoryExists,
createDirectory(directoryName: string) {
if (!this.directoryExists(directoryName)) {
if (!nodeSystem.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
@ -549,6 +550,7 @@ namespace ts {
return _fs.realpathSync(path);
}
};
return nodeSystem;
}
function getChakraSystem(): System {

View File

@ -1,8 +1,10 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitThis": true,
"removeComments": true,
"preserveConstEnums": true,
"pretty": true,
"outFile": "../../built/local/tsc.js",
"sourceMap": true,
"declaration": true,

View File

@ -127,7 +127,7 @@ namespace Utils {
export function memoize<T extends Function>(f: T): T {
const cache: { [idx: string]: any } = {};
return <any>(function() {
return <any>(function(this: any) {
const key = Array.prototype.join.call(arguments);
const cachedResult = cache[key];
if (cachedResult) {

View File

@ -2083,7 +2083,7 @@ namespace ts.server {
done: false,
leaf: function (relativeStart: number, relativeLength: number, ll: LineLeaf) {
if (!f(ll, relativeStart, relativeLength)) {
this.done = true;
walkFns.done = true;
}
}
};

View File

@ -1,8 +1,10 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitThis": true,
"removeComments": true,
"preserveConstEnums": true,
"pretty": true,
"out": "../../built/local/tsserver.js",
"sourceMap": true,
"stripInternal": true

View File

@ -16,7 +16,7 @@
/// <reference path='services.ts' />
/* @internal */
let debugObjectHost = (<any>this);
let debugObjectHost = new Function("return this")();
// We need to use 'null' to interface with the managed side.
/* tslint:disable:no-null-keyword */

View File

@ -1,8 +1,10 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitThis": true,
"removeComments": false,
"preserveConstEnums": true,
"pretty": true,
"outFile": "../../built/local/typescriptServices.js",
"sourceMap": true,
"stripInternal": true,