Skip to content

Commit 073b69a

Browse files
committed
Merge branch 'master' into jsFileCompilation
2 parents 1ee5022 + f168962 commit 073b69a

File tree

52 files changed

+2045
-313
lines changed

Some content is hidden

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

52 files changed

+2045
-313
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"browserify": "latest",
3636
"istanbul": "latest",
3737
"mocha-fivemat-progress-reporter": "latest",
38-
"tslint": "latest",
38+
"tslint": "next",
39+
"typescript": "next",
3940
"tsd": "latest"
4041
},
4142
"scripts": {

scripts/tslint/booleanTriviaRule.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
2-
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
3-
1+
import * as Lint from "tslint/lib/lint";
2+
import * as ts from "typescript";
43

54
export class Rule extends Lint.Rules.AbstractRule {
65
public static FAILURE_STRING_FACTORY = (name: string, currently: string) => `Tag boolean argument as '${name}' (currently '${currently}')`;
@@ -19,7 +18,7 @@ class BooleanTriviaWalker extends Lint.RuleWalker {
1918

2019
visitCallExpression(node: ts.CallExpression) {
2120
super.visitCallExpression(node);
22-
if (node.arguments) {
21+
if (node.arguments) {
2322
const targetCallSignature = this.checker.getResolvedSignature(node);
2423
if (!!targetCallSignature) {
2524
const targetParameters = targetCallSignature.getParameters();
@@ -37,14 +36,14 @@ class BooleanTriviaWalker extends Lint.RuleWalker {
3736
let triviaContent: string;
3837
const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0);
3938
if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) {
40-
triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); //+/-2 to remove /**/
39+
triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/
4140
}
4241
if (triviaContent !== param.getName()) {
4342
this.addFailure(this.createFailure(arg.getStart(source), arg.getWidth(source), Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent)));
4443
}
4544
}
4645
}
4746
}
48-
}
47+
}
4948
}
5049
}

scripts/tslint/nextLineRule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
2-
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
1+
import * as Lint from "tslint/lib/lint";
2+
import * as ts from "typescript";
33

44
const OPTION_CATCH = "check-catch";
55
const OPTION_ELSE = "check-else";

scripts/tslint/noNullRule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
2-
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
1+
import * as Lint from "tslint/lib/lint";
2+
import * as ts from "typescript";
33

44

55
export class Rule extends Lint.Rules.AbstractRule {

scripts/tslint/preferConstRule.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
2-
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
1+
import * as Lint from "tslint/lib/lint";
2+
import * as ts from "typescript";
33

44

55
export class Rule extends Lint.Rules.AbstractRule {
@@ -101,13 +101,13 @@ class PreferConstWalker extends Lint.RuleWalker {
101101
this.visitBindingLiteralExpression(node as (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression));
102102
}
103103
}
104-
104+
105105
private visitBindingLiteralExpression(node: ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) {
106106
if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) {
107107
const pattern = node as ts.ObjectLiteralExpression;
108108
for (const element of pattern.properties) {
109109
if (element.name.kind === ts.SyntaxKind.Identifier) {
110-
this.markAssignment(element.name as ts.Identifier)
110+
this.markAssignment(element.name as ts.Identifier);
111111
}
112112
else if (isBindingPattern(element.name)) {
113113
this.visitBindingPatternIdentifiers(element.name as ts.BindingPattern);

scripts/tslint/typeOperatorSpacingRule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// <reference path="../../node_modules/tslint/typings/typescriptServices.d.ts" />
2-
/// <reference path="../../node_modules/tslint/lib/tslint.d.ts" />
1+
import * as Lint from "tslint/lib/lint";
2+
import * as ts from "typescript";
33

44

55
export class Rule extends Lint.Rules.AbstractRule {

src/compiler/binder.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,14 @@ namespace ts {
175175
symbol.members = {};
176176
}
177177

178-
if (symbolFlags & SymbolFlags.Value && !symbol.valueDeclaration) {
179-
symbol.valueDeclaration = node;
180-
}
178+
if (symbolFlags & SymbolFlags.Value) {
179+
const valueDeclaration = symbol.valueDeclaration;
180+
if (!valueDeclaration ||
181+
(valueDeclaration.kind !== node.kind && valueDeclaration.kind === SyntaxKind.ModuleDeclaration)) {
182+
// other kinds of value declarations take precedence over modules
183+
symbol.valueDeclaration = node;
184+
}
185+
}
181186
}
182187

183188
// Should not be called on a declaration with a computed property name,

src/compiler/checker.ts

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ namespace ts {
122122

123123
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
124124

125-
const anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false);
126-
const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false);
125+
const anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
126+
const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
127127

128128
const globals: SymbolTable = {};
129129

@@ -200,6 +200,10 @@ namespace ts {
200200
"symbol": {
201201
type: esSymbolType,
202202
flags: TypeFlags.ESSymbol
203+
},
204+
"undefined": {
205+
type: undefinedType,
206+
flags: TypeFlags.ContainsUndefinedOrNull
203207
}
204208
};
205209

@@ -295,7 +299,12 @@ namespace ts {
295299
target.constEnumOnlyModule = false;
296300
}
297301
target.flags |= source.flags;
298-
if (!target.valueDeclaration && source.valueDeclaration) target.valueDeclaration = source.valueDeclaration;
302+
if (source.valueDeclaration &&
303+
(!target.valueDeclaration ||
304+
(target.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && source.valueDeclaration.kind !== SyntaxKind.ModuleDeclaration))) {
305+
// other kinds of value declarations take precedence over modules
306+
target.valueDeclaration = source.valueDeclaration;
307+
}
299308
forEach(source.declarations, node => {
300309
target.declarations.push(node);
301310
});
@@ -2267,7 +2276,7 @@ namespace ts {
22672276
return false;
22682277
}
22692278
resolutionTargets.push(target);
2270-
resolutionResults.push(true);
2279+
resolutionResults.push(/*items*/ true);
22712280
resolutionPropertyNames.push(propertyName);
22722281
return true;
22732282
}
@@ -3339,7 +3348,7 @@ namespace ts {
33393348

33403349
function getDefaultConstructSignatures(classType: InterfaceType): Signature[] {
33413350
if (!hasClassBaseType(classType)) {
3342-
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)];
3351+
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
33433352
}
33443353
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
33453354
const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct);
@@ -3964,7 +3973,7 @@ namespace ts {
39643973
}
39653974

39663975
function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature {
3967-
return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true);
3976+
return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true);
39683977
}
39693978

39703979
function getErasedSignature(signature: Signature): Signature {
@@ -3974,7 +3983,7 @@ namespace ts {
39743983
signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper);
39753984
}
39763985
else {
3977-
signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true);
3986+
signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true);
39783987
}
39793988
}
39803989
return signature.erasedSignatureCache;
@@ -5090,7 +5099,7 @@ namespace ts {
50905099
let result = Ternary.True;
50915100
const sourceTypes = source.types;
50925101
for (const sourceType of sourceTypes) {
5093-
const related = typeRelatedToSomeType(sourceType, target, false);
5102+
const related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false);
50945103
if (!related) {
50955104
return Ternary.False;
50965105
}
@@ -5488,7 +5497,7 @@ namespace ts {
54885497
const saveErrorInfo = errorInfo;
54895498
let related = isRelatedTo(s, t, reportErrors);
54905499
if (!related) {
5491-
related = isRelatedTo(t, s, false);
5500+
related = isRelatedTo(t, s, /*reportErrors*/ false);
54925501
if (!related) {
54935502
if (reportErrors) {
54945503
reportError(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
@@ -5615,7 +5624,7 @@ namespace ts {
56155624
let related: Ternary;
56165625
if (sourceStringType && sourceNumberType) {
56175626
// If we know for sure we're testing both string and numeric index types then only report errors from the second one
5618-
related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors);
5627+
related = isRelatedTo(sourceStringType, targetType, /*reportErrors*/ false) || isRelatedTo(sourceNumberType, targetType, reportErrors);
56195628
}
56205629
else {
56215630
related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors);
@@ -6470,6 +6479,10 @@ namespace ts {
64706479
assumeTrue = !assumeTrue;
64716480
}
64726481
const typeInfo = primitiveTypeInfo[right.text];
6482+
// Don't narrow `undefined`
6483+
if (typeInfo && typeInfo.type === undefinedType) {
6484+
return type;
6485+
}
64736486
// If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive
64746487
if (!!(type.flags & TypeFlags.Any) && typeInfo && assumeTrue) {
64756488
return typeInfo.type;
@@ -11348,11 +11361,17 @@ namespace ts {
1134811361
const errorNode: Node = (<FunctionLikeDeclaration>subsequentNode).name || subsequentNode;
1134911362
// TODO(jfreeman): These are methods, so handle computed name case
1135011363
if (node.name && (<FunctionLikeDeclaration>subsequentNode).name && (<Identifier>node.name).text === (<Identifier>(<FunctionLikeDeclaration>subsequentNode).name).text) {
11351-
// the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members
11352-
Debug.assert(node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature);
11353-
Debug.assert((node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static));
11354-
const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
11355-
error(errorNode, diagnostic);
11364+
const reportError =
11365+
(node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) &&
11366+
(node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static);
11367+
// we can get here in two cases
11368+
// 1. mixed static and instance class members
11369+
// 2. something with the same name was defined before the set of overloads that prevents them from merging
11370+
// here we'll report error only for the first case since for second we should already report error in binder
11371+
if (reportError) {
11372+
const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
11373+
error(errorNode, diagnostic);
11374+
}
1135611375
return;
1135711376
}
1135811377
else if (nodeIsPresent((<FunctionLikeDeclaration>subsequentNode).body)) {

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ namespace ts {
847847
}
848848

849849
export function fail(message?: string): void {
850-
Debug.assert(false, message);
850+
Debug.assert(/*expression*/ false, message);
851851
}
852852
}
853853

0 commit comments

Comments
 (0)