Skip to content

Commit 26ca98c

Browse files
committed
Merge branch 'master' into dynamicNames
2 parents ec90dbc + a89c055 commit 26ca98c

174 files changed

Lines changed: 4125 additions & 936 deletions

File tree

Some content is hidden

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

issue_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
44

55
<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->
6-
**TypeScript Version:** 2.6.0-dev.201xxxxx
6+
**TypeScript Version:** 2.7.0-dev.201xxxxx
77

88
**Code**
99

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace ts {
192192
return bindSourceFile;
193193

194194
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
195-
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !file.isDeclarationFile) {
195+
if (getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
196196
// bind in strict mode source files with alwaysStrict option
197197
return true;
198198
}

src/compiler/checker.ts

Lines changed: 186 additions & 83 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,13 @@ namespace ts {
11381138
reportInvalidOptionValue(option && option.type !== "number");
11391139
return Number((<NumericLiteral>valueExpression).text);
11401140

1141+
case SyntaxKind.PrefixUnaryExpression:
1142+
if ((<PrefixUnaryExpression>valueExpression).operator !== SyntaxKind.MinusToken || (<PrefixUnaryExpression>valueExpression).operand.kind !== SyntaxKind.NumericLiteral) {
1143+
break; // not valid JSON syntax
1144+
}
1145+
reportInvalidOptionValue(option && option.type !== "number");
1146+
return -Number((<NumericLiteral>(<PrefixUnaryExpression>valueExpression).operand).text);
1147+
11411148
case SyntaxKind.ObjectLiteralExpression:
11421149
reportInvalidOptionValue(option && option.type !== "object");
11431150
const objectLiteralExpression = <ObjectLiteralExpression>valueExpression;

src/compiler/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,12 @@ namespace ts {
17101710
return moduleResolution;
17111711
}
17121712

1713+
export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "alwaysStrict";
1714+
1715+
export function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean {
1716+
return compilerOptions[flag] === undefined ? compilerOptions.strict : compilerOptions[flag];
1717+
}
1718+
17131719
export function hasZeroOrOneAsteriskCharacter(str: string): boolean {
17141720
let seenAsterisk = false;
17151721
for (let i = 0; i < str.length; i++) {

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4727,7 +4727,7 @@ namespace ts {
47274727
parseExpected(SyntaxKind.OpenParenToken);
47284728
node.expression = allowInAnd(parseExpression);
47294729
parseExpected(SyntaxKind.CloseParenToken);
4730-
node.statement = parseStatement();
4730+
node.statement = doInsideOfContext(NodeFlags.InWithStatement, parseStatement);
47314731
return finishNode(node);
47324732
}
47334733

src/compiler/program.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,10 @@ namespace ts {
10491049
// update fileName -> file mapping
10501050
for (let i = 0; i < newSourceFiles.length; i++) {
10511051
filesByName.set(filePaths[i], newSourceFiles[i]);
1052+
// Set the file as found during node modules search if it was found that way in old progra,
1053+
if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) {
1054+
sourceFilesFoundSearchingNodeModules.set(filePaths[i], true);
1055+
}
10521056
}
10531057

10541058
files = newSourceFiles;
@@ -2127,7 +2131,7 @@ namespace ts {
21272131
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
21282132
}
21292133

2130-
if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) {
2134+
if (options.noImplicitUseStrict && getStrictOptionValue(options, "alwaysStrict")) {
21312135
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
21322136
}
21332137

@@ -2356,7 +2360,7 @@ namespace ts {
23562360
return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
23572361
}
23582362
function needAllowJs() {
2359-
return options.allowJs || !options.noImplicitAny ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type;
2363+
return options.allowJs || !getStrictOptionValue(options, "noImplicitAny") ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type;
23602364
}
23612365
}
23622366

src/compiler/transformers/module/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace ts {
9191
startLexicalEnvironment();
9292

9393
const statements: Statement[] = [];
94-
const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile));
94+
const ensureUseStrict = getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile));
9595
const statementOffset = addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor);
9696

9797
if (shouldEmitUnderscoreUnderscoreESModule()) {

src/compiler/transformers/module/system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ namespace ts {
225225
startLexicalEnvironment();
226226

227227
// Add any prologue directives.
228-
const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile));
228+
const ensureUseStrict = getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile));
229229
const statementOffset = addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor);
230230

231231
// var __moduleName = context_1 && context_1.id;

src/compiler/transformers/ts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace ts {
4545

4646
const resolver = context.getEmitResolver();
4747
const compilerOptions = context.getCompilerOptions();
48-
const strictNullChecks = typeof compilerOptions.strictNullChecks === "undefined" ? compilerOptions.strict : compilerOptions.strictNullChecks;
48+
const strictNullChecks = getStrictOptionValue(compilerOptions, "strictNullChecks");
4949
const languageVersion = getEmitScriptTarget(compilerOptions);
5050
const moduleKind = getEmitModuleKind(compilerOptions);
5151

@@ -521,7 +521,7 @@ namespace ts {
521521
}
522522

523523
function visitSourceFile(node: SourceFile) {
524-
const alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) &&
524+
const alwaysStrict = getStrictOptionValue(compilerOptions, "alwaysStrict") &&
525525
!(isExternalModule(node) && moduleKind >= ModuleKind.ES2015);
526526
return updateSourceFileNode(
527527
node,

0 commit comments

Comments
 (0)