Skip to content

Commit a4e80b5

Browse files
committed
Merge branch 'master' into strictChecks
2 parents cda741d + b152034 commit a4e80b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+288
-154
lines changed

Jakefile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
328328
if (opts.stripInternal) {
329329
options += " --stripInternal";
330330
}
331-
332-
options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters";
331+
options += " --target es5";
332+
if (opts.lib) {
333+
options += " --lib " + opts.lib
334+
}
335+
else {
336+
options += " --lib es5,scripthost"
337+
}
338+
options += " --noUnusedLocals --noUnusedParameters";
333339

334340
var cmd = host + " " + compilerPath + " " + options + " ";
335341
cmd = cmd + sources.join(" ");
@@ -1110,7 +1116,7 @@ desc("Compiles tslint rules to js");
11101116
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"]));
11111117
tslintRulesFiles.forEach(function (ruleFile, i) {
11121118
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
1113-
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") });
1119+
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" });
11141120
});
11151121

11161122
desc("Emit the start of the build-rules fold");

scripts/parallel-lint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var tslint = require("tslint");
22
var fs = require("fs");
3+
var path = require("path");
34

45
function getLinterOptions() {
56
return {
@@ -9,7 +10,7 @@ function getLinterOptions() {
910
};
1011
}
1112
function getLinterConfiguration() {
12-
return require("../tslint.json");
13+
return tslint.Configuration.loadConfigurationFromPath(path.join(__dirname, "../tslint.json"));
1314
}
1415

1516
function lintFileContents(options, configuration, path, contents) {

src/compiler/checker.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace ts {
143143
getAugmentedPropertiesOfType,
144144
getRootSymbols,
145145
getContextualType: node => {
146-
node = getParseTreeNode(node, isExpression)
146+
node = getParseTreeNode(node, isExpression);
147147
return node ? getContextualType(node) : undefined;
148148
},
149149
getFullyQualifiedName,
@@ -16133,7 +16133,7 @@ namespace ts {
1613316133
}
1613416134

1613516135
function checkDeclarationInitializer(declaration: VariableLikeDeclaration) {
16136-
const type = checkExpressionCached(declaration.initializer);
16136+
const type = getTypeOfExpression(declaration.initializer, /*cache*/ true);
1613716137
return getCombinedNodeFlags(declaration) & NodeFlags.Const ||
1613816138
getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) ||
1613916139
isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type);
@@ -16206,10 +16206,12 @@ namespace ts {
1620616206

1620716207
// Returns the type of an expression. Unlike checkExpression, this function is simply concerned
1620816208
// with computing the type and may not fully check all contained sub-expressions for errors.
16209-
function getTypeOfExpression(node: Expression) {
16209+
// A cache argument of true indicates that if the function performs a full type check, it is ok
16210+
// to cache the result.
16211+
function getTypeOfExpression(node: Expression, cache?: boolean) {
1621016212
// Optimize for the common case of a call to a function with a single non-generic call
1621116213
// signature where we can just fetch the return type without checking the arguments.
16212-
if (node.kind === SyntaxKind.CallExpression && (<CallExpression>node).expression.kind !== SyntaxKind.SuperKeyword) {
16214+
if (node.kind === SyntaxKind.CallExpression && (<CallExpression>node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) {
1621316215
const funcType = checkNonNullExpression((<CallExpression>node).expression);
1621416216
const signature = getSingleCallSignature(funcType);
1621516217
if (signature && !signature.typeParameters) {
@@ -16219,7 +16221,7 @@ namespace ts {
1621916221
// Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions
1622016222
// should have a parameter that indicates whether full error checking is required such that
1622116223
// we can perform the optimizations locally.
16222-
return checkExpression(node);
16224+
return cache ? checkExpressionCached(node) : checkExpression(node);
1622316225
}
1622416226

1622516227
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
@@ -20676,7 +20678,7 @@ namespace ts {
2067620678
}
2067720679

2067820680
if (potentialNewTargetCollisions.length) {
20679-
forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope)
20681+
forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
2068020682
potentialNewTargetCollisions.length = 0;
2068120683
}
2068220684

src/compiler/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace ts {
8484
this.index++;
8585
return { value: this.selector(this.data, this.keys[index]), done: false };
8686
}
87-
return { value: undefined as never, done: true }
87+
return { value: undefined as never, done: true };
8888
}
8989
}
9090

@@ -140,7 +140,7 @@ namespace ts {
140140
action(this.data[key], key);
141141
}
142142
}
143-
}
143+
};
144144
}
145145

146146
export function createFileMap<T>(keyMapper?: (key: string) => string): FileMap<T> {

src/compiler/declarationEmitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ namespace ts {
11641164
emitTypeParameters(node.typeParameters);
11651165
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
11661166
if (baseTypeNode) {
1167-
node.name
1167+
node.name;
11681168
emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false);
11691169
}
11701170
emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true);

src/compiler/moduleNameResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ namespace ts {
675675
}
676676

677677
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations {
678-
return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false);
678+
return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false);
679679
}
680680

681681
/* @internal */
@@ -962,7 +962,7 @@ namespace ts {
962962
const result = cache && cache.get(containingDirectory);
963963
if (result) {
964964
if (traceEnabled) {
965-
trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName)
965+
trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName);
966966
}
967967
return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } };
968968
}

src/compiler/transformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ namespace ts {
121121
enableEmitNotification,
122122
isSubstitutionEnabled,
123123
isEmitNotificationEnabled,
124-
get onSubstituteNode() { return onSubstituteNode },
124+
get onSubstituteNode() { return onSubstituteNode; },
125125
set onSubstituteNode(value) {
126126
Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed.");
127127
Debug.assert(value !== undefined, "Value must not be 'undefined'");
128128
onSubstituteNode = value;
129129
},
130-
get onEmitNode() { return onEmitNode },
130+
get onEmitNode() { return onEmitNode; },
131131
set onEmitNode(value) {
132132
Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed.");
133133
Debug.assert(value !== undefined, "Value must not be 'undefined'");

src/compiler/transformers/es2015.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2690,7 +2690,7 @@ namespace ts {
26902690
if (loopOutParameters.length) {
26912691
copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements);
26922692
}
2693-
addRange(statements, lexicalEnvironment)
2693+
addRange(statements, lexicalEnvironment);
26942694
loopBody = createBlock(statements, /*multiline*/ true);
26952695
}
26962696

src/compiler/transformers/module/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ namespace ts {
11521152
createIdentifier("__esModule"),
11531153
createLiteral(true)
11541154
)
1155-
)
1155+
);
11561156
}
11571157
else {
11581158
statement = createStatement(

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@
32973297
}
32983298

32993299
export interface PluginImport {
3300-
name: string
3300+
name: string;
33013301
}
33023302

33033303
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[];

src/harness/fourslash.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ namespace FourSlash {
585585
}
586586

587587
private getGoToDefinition(): ts.DefinitionInfo[] {
588-
return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)
588+
return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
589589
}
590590

591591
public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) {
@@ -926,7 +926,7 @@ namespace FourSlash {
926926
function rangeToReferenceEntry(r: Range) {
927927
let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false };
928928
isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition;
929-
return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }
929+
return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition };
930930
}
931931
}
932932

@@ -2136,7 +2136,7 @@ namespace FourSlash {
21362136

21372137
const result = includeWhiteSpace
21382138
? actualText === expectedText
2139-
: this.removeWhitespace(actualText) === this.removeWhitespace(expectedText)
2139+
: this.removeWhitespace(actualText) === this.removeWhitespace(expectedText);
21402140

21412141
if (!result) {
21422142
this.raiseError(`Actual text doesn't match expected text. Actual:\n'${actualText}'\nExpected:\n'${expectedText}'`);
@@ -2173,7 +2173,7 @@ namespace FourSlash {
21732173
start: diagnostic.start,
21742174
length: diagnostic.length,
21752175
code: diagnostic.code
2176-
}
2176+
};
21772177
});
21782178
const dedupedDiagnositcs = ts.deduplicate(diagnosticsForCodeFix, ts.equalOwnProperties);
21792179

src/harness/harness.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ declare namespace NodeJS {
4444
declare var window: {};
4545
declare var XMLHttpRequest: {
4646
new(): XMLHttpRequest;
47-
}
47+
};
4848
interface XMLHttpRequest {
4949
readonly readyState: number;
5050
readonly responseText: string;
@@ -1017,7 +1017,7 @@ namespace Harness {
10171017
}
10181018
else {
10191019
if (!es6TestLibFileNameSourceFileMap.get(libFileName)) {
1020-
es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget))
1020+
es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget));
10211021
}
10221022
}
10231023
}

src/harness/harnessLanguageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ namespace Harness.LanguageService {
779779
start: 0
780780
});
781781
return prev;
782-
}
782+
};
783783
return proxy;
784784
}
785785
}),

src/harness/unittests/compileOnSave.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ namespace ts.projectSystem {
496496
const emitOutput = host.readFile(path + ".js");
497497
assert.equal(emitOutput, f.content + newLine, "content of emit output should be identical with the input + newline");
498498
}
499-
})
499+
});
500500

501501
it("should emit specified file", () => {
502502
const file1 = {

src/harness/unittests/printer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ts {
99
Harness.Baseline.runBaseline(`printerApi/${prefix}.${name}.js`, () =>
1010
printCallback(createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed, ...options })));
1111
});
12-
}
12+
};
1313
}
1414

1515
describe("printFile", () => {

src/harness/unittests/textStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ namespace ts.textStorage {
6565

6666
ts1.getLineInfo(0);
6767
assert.isTrue(ts1.hasScriptVersionCache(), "have script version cache - 2");
68-
})
68+
});
6969
});
7070
}

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ namespace ts.projectSystem {
628628

629629
checkProjectActualFiles(service.configuredProjects[0], []);
630630
checkProjectActualFiles(service.inferredProjects[0], [f1.path]);
631-
})
631+
});
632632

633633
it("create configured project without file list", () => {
634634
const configFile: FileOrFolder = {
@@ -1181,7 +1181,7 @@ namespace ts.projectSystem {
11811181

11821182
const host = createServerHost([f1, f2, libFile]);
11831183
const service = createProjectService(host);
1184-
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} })
1184+
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} });
11851185

11861186
service.openClientFile(f1.path);
11871187
service.openClientFile(f2.path, "let x: string");
@@ -1213,7 +1213,7 @@ namespace ts.projectSystem {
12131213

12141214
const host = createServerHost([f1, f2, libFile]);
12151215
const service = createProjectService(host);
1216-
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} })
1216+
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} });
12171217

12181218
service.openClientFile(f1.path);
12191219
service.openClientFile(f2.path, "let somelongname: string");
@@ -2040,7 +2040,7 @@ namespace ts.projectSystem {
20402040

20412041
for (const f of [f2, f3]) {
20422042
const scriptInfo = projectService.getScriptInfoForNormalizedPath(server.toNormalizedPath(f.path));
2043-
assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`)
2043+
assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`);
20442044
}
20452045
});
20462046

@@ -2156,7 +2156,7 @@ namespace ts.projectSystem {
21562156
projectFileName,
21572157
rootFiles: [toExternalFile(f1.path)],
21582158
options: {}
2159-
})
2159+
});
21602160
projectService.openClientFile(f1.path, "let x = 1;\nlet y = 2;");
21612161

21622162
projectService.checkNumberOfProjects({ externalProjects: 1 });
@@ -3307,12 +3307,12 @@ namespace ts.projectSystem {
33073307
isCancellationRequested: () => false,
33083308
setRequest: requestId => {
33093309
if (expectedRequestId === undefined) {
3310-
assert.isTrue(false, "unexpected call")
3310+
assert.isTrue(false, "unexpected call");
33113311
}
33123312
assert.equal(requestId, expectedRequestId);
33133313
},
33143314
resetRequest: noop
3315-
}
3315+
};
33163316
const session = createSession(host, /*typingsInstaller*/ undefined, /*projectServiceEventHandler*/ undefined, cancellationToken);
33173317

33183318
expectedRequestId = session.getNextSeq();
@@ -3359,13 +3359,13 @@ namespace ts.projectSystem {
33593359
currentId = requestId;
33603360
},
33613361
resetRequest(requestId) {
3362-
assert.equal(requestId, currentId, "unexpected request id in cancellation")
3362+
assert.equal(requestId, currentId, "unexpected request id in cancellation");
33633363
currentId = undefined;
33643364
},
33653365
isCancellationRequested() {
33663366
return requestToCancel === currentId;
33673367
}
3368-
}
3368+
};
33693369
})();
33703370
const host = createServerHost([f1, config]);
33713371
const session = createSession(host, /*typingsInstaller*/ undefined, () => {}, cancellationToken);

src/harness/unittests/typingsInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace ts.projectSystem {
5656
path: "/a/config.js",
5757
content: "export let x = 1"
5858
};
59-
const typesCache = "/cache"
59+
const typesCache = "/cache";
6060
const typesConfig = {
6161
path: typesCache + "/node_modules/@types/config/index.d.ts",
6262
content: "export let y: number;"
@@ -74,7 +74,7 @@ namespace ts.projectSystem {
7474
super(host, { typesRegistry: createTypesRegistry("config"), globalTypingsCacheLocation: typesCache });
7575
}
7676
installWorker(_requestId: number, _args: string[], _cwd: string, _cb: server.typingsInstaller.RequestCompletedAction) {
77-
assert(false, "should not be called")
77+
assert(false, "should not be called");
7878
}
7979
})();
8080
const service = createProjectService(host, { typingsInstaller: installer });

src/server/editorServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ namespace ts.server {
140140
getScriptKind: _ => undefined,
141141
hasMixedContent: (fileName, extraFileExtensions) => {
142142
const mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, item => item.isMixedContent), item => item.extension);
143-
return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension))
143+
return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension));
144144
}
145145
};
146146

@@ -1377,7 +1377,7 @@ namespace ts.server {
13771377

13781378
// close projects that were missing in the input list
13791379
forEachKey(projectsToClose, externalProjectName => {
1380-
this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true)
1380+
this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true);
13811381
});
13821382

13831383
this.refreshInferredProjects();

0 commit comments

Comments
 (0)