Skip to content

Commit d5c18a6

Browse files
author
Armando Aguirre
authored
Merge branch 'master' into AddDefinitionAndBoundSpan
2 parents c4a675e + a89c055 commit d5c18a6

File tree

150 files changed

+3276
-811
lines changed

Some content is hidden

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

150 files changed

+3276
-811
lines changed

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: 170 additions & 64 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/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ namespace ts {
21312131
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
21322132
}
21332133

2134-
if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) {
2134+
if (options.noImplicitUseStrict && getStrictOptionValue(options, "alwaysStrict")) {
21352135
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
21362136
}
21372137

@@ -2360,7 +2360,7 @@ namespace ts {
23602360
return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
23612361
}
23622362
function needAllowJs() {
2363-
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;
23642364
}
23652365
}
23662366

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,

src/compiler/tsc.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,12 @@ namespace ts {
4343
return s;
4444
}
4545

46-
function isJSONSupported() {
47-
return typeof JSON === "object" && typeof JSON.parse === "function";
48-
}
49-
5046
export function executeCommandLine(args: string[]): void {
5147
const commandLine = parseCommandLine(args);
5248

5349
// Configuration file name (if any)
5450
let configFileName: string;
5551
if (commandLine.options.locale) {
56-
if (!isJSONSupported()) {
57-
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
58-
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
59-
}
6052
validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
6153
}
6254

@@ -84,10 +76,6 @@ namespace ts {
8476
}
8577

8678
if (commandLine.options.project) {
87-
if (!isJSONSupported()) {
88-
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"));
89-
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
90-
}
9179
if (commandLine.fileNames.length !== 0) {
9280
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
9381
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
@@ -109,7 +97,7 @@ namespace ts {
10997
}
11098
}
11199
}
112-
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
100+
else if (commandLine.fileNames.length === 0) {
113101
const searchPath = normalizePath(sys.getCurrentDirectory());
114102
configFileName = findConfigFile(searchPath, sys.fileExists);
115103
}

src/compiler/types.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ namespace ts {
362362
JSDocFunctionType,
363363
JSDocVariadicType,
364364
JSDocComment,
365+
JSDocTypeLiteral,
365366
JSDocTag,
366367
JSDocAugmentsTag,
367368
JSDocClassTag,
@@ -371,7 +372,6 @@ namespace ts {
371372
JSDocTemplateTag,
372373
JSDocTypedefTag,
373374
JSDocPropertyTag,
374-
JSDocTypeLiteral,
375375

376376
// Synthesized list
377377
SyntaxList,
@@ -413,9 +413,9 @@ namespace ts {
413413
LastBinaryOperator = CaretEqualsToken,
414414
FirstNode = QualifiedName,
415415
FirstJSDocNode = JSDocTypeExpression,
416-
LastJSDocNode = JSDocTypeLiteral,
416+
LastJSDocNode = JSDocPropertyTag,
417417
FirstJSDocTagNode = JSDocTag,
418-
LastJSDocTagNode = JSDocTypeLiteral
418+
LastJSDocTagNode = JSDocPropertyTag
419419
}
420420

421421
export const enum NodeFlags {
@@ -3327,6 +3327,7 @@ namespace ts {
33273327
ObjectLiteral = 1 << 7, // Originates in an object literal
33283328
EvolvingArray = 1 << 8, // Evolving array type
33293329
ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties
3330+
ContainsSpread = 1 << 10, // Object literal contains spread operation
33303331
ClassOrInterface = Class | Interface
33313332
}
33323333

@@ -3609,6 +3610,14 @@ namespace ts {
36093610
compareTypes: TypeComparer; // Type comparer function
36103611
}
36113612

3613+
/* @internal */
3614+
export interface WideningContext {
3615+
parent?: WideningContext; // Parent context
3616+
propertyName?: __String; // Name of property in parent
3617+
siblings?: Type[]; // Types of siblings
3618+
resolvedPropertyNames?: __String[]; // Property names occurring in sibling object literals
3619+
}
3620+
36123621
/* @internal */
36133622
export const enum SpecialPropertyAssignmentKind {
36143623
None,

0 commit comments

Comments
 (0)