Skip to content

Commit 1d201c1

Browse files
author
Andy Hanson
committed
Merge branch 'master' into refactor_module_resolution
2 parents 7c53a1d + db0ee4f commit 1d201c1

Some content is hidden

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

42 files changed

+306
-222
lines changed

Jakefile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
448448
options += " --stripInternal";
449449
}
450450

451+
options += " --target es5";
452+
451453
var cmd = host + " " + compilerPath + " " + options + " ";
452454
cmd = cmd + sources.join(" ");
453455
console.log(cmd + "\n");

src/compiler/checker.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ namespace ts {
368368
return emitResolver;
369369
}
370370

371-
function error(location: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
371+
function error(location: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): void {
372372
const diagnostic = location
373373
? createDiagnosticForNode(location, message, arg0, arg1, arg2)
374374
: createCompilerDiagnostic(message, arg0, arg1, arg2);
@@ -1054,7 +1054,7 @@ namespace ts {
10541054
if (node.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
10551055
return resolveExternalModuleSymbol(resolveExternalModuleName(node, getExternalModuleImportEqualsDeclarationExpression(node)));
10561056
}
1057-
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>node.moduleReference, node);
1057+
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>node.moduleReference);
10581058
}
10591059

10601060
function getTargetOfImportClause(node: ImportClause): Symbol {
@@ -1267,7 +1267,7 @@ namespace ts {
12671267
}
12681268

12691269
// This function is only for imports with entity names
1270-
function getSymbolOfPartOfRightHandSideOfImportEquals(entityName: EntityName, importDeclaration: ImportEqualsDeclaration, dontResolveAlias?: boolean): Symbol {
1270+
function getSymbolOfPartOfRightHandSideOfImportEquals(entityName: EntityName, dontResolveAlias?: boolean): Symbol {
12711271
// There are three things we might try to look for. In the following examples,
12721272
// the search term is enclosed in |...|:
12731273
//
@@ -2589,7 +2589,7 @@ namespace ts {
25892589
}
25902590
}
25912591

2592-
function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
2592+
function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node) {
25932593
if (typeParameters && typeParameters.length) {
25942594
writePunctuation(writer, SyntaxKind.LessThanToken);
25952595
let flags = TypeFormatFlags.InFirstTypeArgument;
@@ -4801,7 +4801,7 @@ namespace ts {
48014801
const typeParameters = classType ? classType.localTypeParameters :
48024802
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) :
48034803
getTypeParametersFromJSDocTemplate(declaration);
4804-
const returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType);
4804+
const returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType);
48054805
const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ?
48064806
createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) :
48074807
undefined;
@@ -4811,7 +4811,7 @@ namespace ts {
48114811
return links.resolvedSignature;
48124812
}
48134813

4814-
function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, minArgumentCount: number, isJSConstructSignature: boolean, classType: Type) {
4814+
function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, isJSConstructSignature: boolean, classType: Type) {
48154815
if (isJSConstructSignature) {
48164816
return getTypeFromTypeNode(declaration.parameters[0].type);
48174817
}
@@ -5176,10 +5176,7 @@ namespace ts {
51765176
return undefined;
51775177
}
51785178

5179-
function resolveTypeReferenceName(
5180-
node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference,
5181-
typeReferenceName: EntityNameExpression | EntityName) {
5182-
5179+
function resolveTypeReferenceName(typeReferenceName: EntityNameExpression | EntityName) {
51835180
if (!typeReferenceName) {
51845181
return unknownSymbol;
51855182
}
@@ -5217,7 +5214,7 @@ namespace ts {
52175214
let type: Type;
52185215
if (node.kind === SyntaxKind.JSDocTypeReference) {
52195216
const typeReferenceName = getTypeReferenceName(node);
5220-
symbol = resolveTypeReferenceName(node, typeReferenceName);
5217+
symbol = resolveTypeReferenceName(typeReferenceName);
52215218
type = getTypeReferenceType(node, symbol);
52225219
}
52235220
else {
@@ -6679,8 +6676,8 @@ namespace ts {
66796676
}
66806677
if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union ||
66816678
source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) {
6682-
if (result = eachTypeRelatedToSomeType(<UnionOrIntersectionType>source, <UnionOrIntersectionType>target, /*reportErrors*/ false)) {
6683-
if (result &= eachTypeRelatedToSomeType(<UnionOrIntersectionType>target, <UnionOrIntersectionType>source, /*reportErrors*/ false)) {
6679+
if (result = eachTypeRelatedToSomeType(<UnionOrIntersectionType>source, <UnionOrIntersectionType>target)) {
6680+
if (result &= eachTypeRelatedToSomeType(<UnionOrIntersectionType>target, <UnionOrIntersectionType>source)) {
66846681
return result;
66856682
}
66866683
}
@@ -6741,7 +6738,7 @@ namespace ts {
67416738
return false;
67426739
}
67436740

6744-
function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType, reportErrors: boolean): Ternary {
6741+
function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary {
67456742
let result = Ternary.True;
67466743
const sourceTypes = source.types;
67476744
for (const sourceType of sourceTypes) {
@@ -11778,7 +11775,7 @@ namespace ts {
1177811775
// If the effective argument is 'undefined', then it is an argument that is present but is synthetic.
1177911776
if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) {
1178011777
const paramType = getTypeAtPosition(signature, i);
11781-
let argType = getEffectiveArgumentType(node, i, arg);
11778+
let argType = getEffectiveArgumentType(node, i);
1178211779

1178311780
// If the effective argument type is 'undefined', there is no synthetic type
1178411781
// for the argument. In that case, we should check the argument.
@@ -11864,7 +11861,7 @@ namespace ts {
1186411861
if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) {
1186511862
// Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter)
1186611863
const paramType = getTypeAtPosition(signature, i);
11867-
let argType = getEffectiveArgumentType(node, i, arg);
11864+
let argType = getEffectiveArgumentType(node, i);
1186811865

1186911866
// If the effective argument type is 'undefined', there is no synthetic type
1187011867
// for the argument. In that case, we should check the argument.
@@ -12157,7 +12154,7 @@ namespace ts {
1215712154
/**
1215812155
* Gets the effective argument type for an argument in a call expression.
1215912156
*/
12160-
function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number, arg: Expression): Type {
12157+
function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number): Type {
1216112158
// Decorators provide special arguments, a tagged template expression provides
1216212159
// a special first argument, and string literals get string literal types
1216312160
// unless we're reporting errors
@@ -13562,15 +13559,15 @@ namespace ts {
1356213559
return booleanType;
1356313560
}
1356413561

13565-
function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type {
13562+
function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type): Type {
1356613563
const properties = node.properties;
1356713564
for (const p of properties) {
13568-
checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper);
13565+
checkObjectLiteralDestructuringPropertyAssignment(sourceType, p);
1356913566
}
1357013567
return sourceType;
1357113568
}
1357213569

13573-
function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, contextualMapper?: TypeMapper) {
13570+
function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike) {
1357413571
if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) {
1357513572
const name = <PropertyName>(<PropertyAssignment>property).name;
1357613573
if (name.kind === SyntaxKind.ComputedPropertyName) {
@@ -13685,7 +13682,7 @@ namespace ts {
1368513682
target = (<BinaryExpression>target).left;
1368613683
}
1368713684
if (target.kind === SyntaxKind.ObjectLiteralExpression) {
13688-
return checkObjectLiteralAssignment(<ObjectLiteralExpression>target, sourceType, contextualMapper);
13685+
return checkObjectLiteralAssignment(<ObjectLiteralExpression>target, sourceType);
1368913686
}
1369013687
if (target.kind === SyntaxKind.ArrayLiteralExpression) {
1369113688
return checkArrayLiteralAssignment(<ArrayLiteralExpression>target, sourceType, contextualMapper);
@@ -18594,7 +18591,7 @@ namespace ts {
1859418591
// Since we already checked for ExportAssignment, this really could only be an Import
1859518592
const importEqualsDeclaration = <ImportEqualsDeclaration>getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration);
1859618593
Debug.assert(importEqualsDeclaration !== undefined);
18597-
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>entityName, importEqualsDeclaration, /*dontResolveAlias*/ true);
18594+
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>entityName, /*dontResolveAlias*/ true);
1859818595
}
1859918596

1860018597
if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
@@ -19977,7 +19974,7 @@ namespace ts {
1997719974
}
1997819975
}
1997919976

19980-
function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>, file: SourceFile): boolean {
19977+
function checkGrammarTypeParameterList(typeParameters: NodeArray<TypeParameterDeclaration>, file: SourceFile): boolean {
1998119978
if (checkGrammarForDisallowedTrailingComma(typeParameters)) {
1998219979
return true;
1998319980
}
@@ -20028,7 +20025,7 @@ namespace ts {
2002820025
function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
2002920026
// Prevent cascading error by short-circuit
2003020027
const file = getSourceFileOfNode(node);
20031-
return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) ||
20028+
return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) ||
2003220029
checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file);
2003320030
}
2003420031

@@ -20214,7 +20211,7 @@ namespace ts {
2021420211
}
2021520212
}
2021620213

20217-
function checkGrammarForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage): boolean {
20214+
function checkGrammarForInvalidQuestionMark(questionToken: Node, message: DiagnosticMessage): boolean {
2021820215
if (questionToken) {
2021920216
return grammarErrorOnNode(questionToken, message);
2022020217
}
@@ -20260,7 +20257,7 @@ namespace ts {
2026020257
let currentKind: number;
2026120258
if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) {
2026220259
// Grammar checking for computedPropertyName and shorthandPropertyAssignment
20263-
checkGrammarForInvalidQuestionMark(prop, (<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
20260+
checkGrammarForInvalidQuestionMark((<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
2026420261
if (name.kind === SyntaxKind.NumericLiteral) {
2026520262
checkGrammarNumericLiteral(<NumericLiteral>name);
2026620263
}
@@ -20444,7 +20441,7 @@ namespace ts {
2044420441
}
2044520442

2044620443
if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) {
20447-
if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) {
20444+
if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) {
2044820445
return true;
2044920446
}
2045020447
else if (node.body === undefined) {

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,7 @@ namespace ts {
515515

516516
/* @internal */
517517
export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic {
518-
const namesOfType: string[] = [];
519-
for (const key in opt.type) {
520-
namesOfType.push(` '${key}'`);
521-
}
518+
const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", ");
522519
return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType);
523520
}
524521

src/compiler/comments.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ namespace ts {
188188
}
189189
}
190190

191-
function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
191+
function emitLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
192192
if (!hasWrittenComment) {
193193
emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos);
194194
hasWrittenComment = true;
@@ -211,7 +211,7 @@ namespace ts {
211211
forEachTrailingCommentToEmit(pos, emitTrailingComment);
212212
}
213213

214-
function emitTrailingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
214+
function emitTrailingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
215215
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
216216
if (!writer.isAtStartOfLine()) {
217217
writer.write(" ");
@@ -242,7 +242,7 @@ namespace ts {
242242
}
243243
}
244244

245-
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
245+
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
246246
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
247247

248248
emitPos(commentPos);

src/compiler/core.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ namespace ts {
903903
return t => compose(a(t));
904904
}
905905
else {
906-
return t => u => u;
906+
return _ => u => u;
907907
}
908908
}
909909

@@ -940,10 +940,10 @@ namespace ts {
940940
}
941941
}
942942

943-
function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string {
943+
function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string {
944944
baseIndex = baseIndex || 0;
945945

946-
return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]);
946+
return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]);
947947
}
948948

949949
export let localizedDiagnosticMessages: Map<string> = undefined;
@@ -952,7 +952,7 @@ namespace ts {
952952
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
953953
}
954954

955-
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
955+
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
956956
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
957957
const end = start + length;
958958

@@ -982,7 +982,7 @@ namespace ts {
982982
}
983983

984984
/* internal */
985-
export function formatMessage(dummy: any, message: DiagnosticMessage): string {
985+
export function formatMessage(_dummy: any, message: DiagnosticMessage): string {
986986
let text = getLocaleSpecificMessage(message);
987987

988988
if (arguments.length > 2) {
@@ -992,7 +992,7 @@ namespace ts {
992992
return text;
993993
}
994994

995-
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
995+
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
996996
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
997997
let text = getLocaleSpecificMessage(message);
998998

@@ -1623,7 +1623,7 @@ namespace ts {
16231623
basePaths: string[];
16241624
}
16251625

1626-
export function getFileMatcherPatterns(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
1626+
export function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
16271627
path = normalizePath(path);
16281628
currentDirectory = normalizePath(currentDirectory);
16291629
const absolutePath = combinePaths(currentDirectory, path);
@@ -1640,7 +1640,7 @@ namespace ts {
16401640
path = normalizePath(path);
16411641
currentDirectory = normalizePath(currentDirectory);
16421642

1643-
const patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
1643+
const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
16441644

16451645
const regexFlag = useCaseSensitiveFileNames ? "" : "i";
16461646
const includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag);
@@ -1870,11 +1870,11 @@ namespace ts {
18701870
this.declarations = undefined;
18711871
}
18721872

1873-
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
1873+
function Type(this: Type, _checker: TypeChecker, flags: TypeFlags) {
18741874
this.flags = flags;
18751875
}
18761876

1877-
function Signature(checker: TypeChecker) {
1877+
function Signature() {
18781878
}
18791879

18801880
function Node(this: Node, kind: SyntaxKind, pos: number, end: number) {
@@ -1907,9 +1907,6 @@ namespace ts {
19071907
}
19081908

19091909
export namespace Debug {
1910-
declare var process: any;
1911-
declare var require: any;
1912-
19131910
export let currentAssertionLevel = AssertionLevel.None;
19141911

19151912
export function shouldAssert(level: AssertionLevel): boolean {

0 commit comments

Comments
 (0)