Skip to content

Commit c19c6e1

Browse files
author
Andy Hanson
committed
Merge branch 'master' into duplicatePackageImportFixes
2 parents 2d955a3 + 0923771 commit c19c6e1

File tree

178 files changed

+2657
-791
lines changed

Some content is hidden

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

178 files changed

+2657
-791
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,4 @@ Vyacheslav Pukhanov <[email protected]>
358358
dangoo <[email protected]> # Daniel Gooss
359359
krk <[email protected]> # Kerem Kat
360360
micnic <[email protected]> # Nicu Micleușanu
361+
rflorian <[email protected]> # @rflorian

Jakefile.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const TaskNames = {
5151
configureInsiders: "configure-insiders",
5252
publishInsiders: "publish-insiders",
5353
configureNightly: "configure-nightly",
54-
publishNightly: "publish-nightly"
54+
publishNightly: "publish-nightly",
55+
help: "help"
5556
};
5657

5758
const Paths = {};
@@ -258,6 +259,11 @@ task(TaskNames.publishNightly, [TaskNames.coreBuild, TaskNames.configureNightly,
258259
exec(cmd, () => complete());
259260
}, { async: true });
260261

262+
task(TaskNames.help, function() {
263+
var cmd = "jake --tasks";
264+
exec(cmd, () => complete());
265+
})
266+
261267
task(TaskNames.configureInsiders, [TaskNames.scripts], function () {
262268
const cmd = `${host} ${Paths.scripts.configurePrerelease} insiders ${Paths.packageJson} ${Paths.versionFile}`;
263269
exec(cmd, () => complete());

src/compiler/checker.ts

Lines changed: 135 additions & 42 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2093,7 +2093,7 @@ namespace ts {
20932093
return arg => f(arg) || g(arg);
20942094
}
20952095

2096-
export function assertTypeIsNever(_: never): void { } // tslint:disable-line no-empty
2096+
export function assertType<T>(_: T): void { } // tslint:disable-line no-empty
20972097

20982098
export function singleElementArray<T>(t: T | undefined): T[] | undefined {
20992099
return t === undefined ? undefined : [t];

src/compiler/diagnosticMessages.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@
11961196
"category": "Error",
11971197
"code": 2351
11981198
},
1199-
"Type '{0}' cannot be converted to type '{1}'.": {
1199+
"Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.": {
12001200
"category": "Error",
12011201
"code": 2352
12021202
},
@@ -2421,6 +2421,14 @@
24212421
"category": "Error",
24222422
"code": 2730
24232423
},
2424+
"Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'.": {
2425+
"category": "Error",
2426+
"code": 2731
2427+
},
2428+
"Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension": {
2429+
"category": "Error",
2430+
"code": 2732
2431+
},
24242432

24252433
"Import declaration '{0}' is using private name '{1}'.": {
24262434
"category": "Error",
@@ -3647,6 +3655,10 @@
36473655
"category": "Message",
36483656
"code": 6204
36493657
},
3658+
"All type parameters are unused": {
3659+
"category": "Error",
3660+
"code": 6205
3661+
},
36503662

36513663
"Projects to reference": {
36523664
"category": "Message",
@@ -3913,6 +3925,10 @@
39133925
"category": "Error",
39143926
"code": 7040
39153927
},
3928+
"The containing arrow function captures the global value of 'this' which implicitly has type 'any'.": {
3929+
"category": "Error",
3930+
"code": 7041
3931+
},
39163932
"You cannot rename this element.": {
39173933
"category": "Error",
39183934
"code": 8000
@@ -4196,6 +4212,14 @@
41964212
"category": "Message",
41974213
"code": 90010
41984214
},
4215+
"Remove template tag": {
4216+
"category": "Message",
4217+
"code": 90011
4218+
},
4219+
"Remove type parameters": {
4220+
"category": "Message",
4221+
"code": 90012
4222+
},
41994223
"Import '{0}' from module \"{1}\"": {
42004224
"category": "Message",
42014225
"code": 90013
@@ -4264,6 +4288,14 @@
42644288
"category": "Message",
42654289
"code": 90029
42664290
},
4291+
"Replace 'infer {0}' with 'unknown'": {
4292+
"category": "Message",
4293+
"code": 90030
4294+
},
4295+
"Replace all unused 'infer' with 'unknown'": {
4296+
"category": "Message",
4297+
"code": 90031
4298+
},
42674299
"Convert function to an ES2015 class": {
42684300
"category": "Message",
42694301
"code": 95001

src/compiler/parser.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ namespace ts {
491491
visitNode(cbNode, (node as JSDocCallbackTag).typeExpression);
492492
case SyntaxKind.JSDocThisTag:
493493
return visitNode(cbNode, (node as JSDocThisTag).typeExpression);
494+
case SyntaxKind.JSDocEnumTag:
495+
return visitNode(cbNode, (node as JSDocEnumTag).typeExpression);
494496
case SyntaxKind.JSDocSignature:
495497
return visitNodes(cbNode, cbNodes, node.decorators) ||
496498
visitNodes(cbNode, cbNodes, node.modifiers) ||
@@ -6398,7 +6400,7 @@ namespace ts {
63986400
switch (token()) {
63996401
case SyntaxKind.AtToken:
64006402
if (state === JSDocState.BeginningOfLine || state === JSDocState.SawAsterisk) {
6401-
removeTrailingNewlines(comments);
6403+
removeTrailingWhitespace(comments);
64026404
addTag(parseTag(indent));
64036405
// NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag.
64046406
// Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning
@@ -6458,7 +6460,7 @@ namespace ts {
64586460
nextJSDocToken();
64596461
}
64606462
removeLeadingNewlines(comments);
6461-
removeTrailingNewlines(comments);
6463+
removeTrailingWhitespace(comments);
64626464
return createJSDocComment();
64636465
});
64646466

@@ -6468,8 +6470,8 @@ namespace ts {
64686470
}
64696471
}
64706472

6471-
function removeTrailingNewlines(comments: string[]) {
6472-
while (comments.length && (comments[comments.length - 1] === "\n" || comments[comments.length - 1] === "\r")) {
6473+
function removeTrailingWhitespace(comments: string[]) {
6474+
while (comments.length && comments[comments.length - 1].trim() === "") {
64736475
comments.pop();
64746476
}
64756477
}
@@ -6527,6 +6529,9 @@ namespace ts {
65276529
case "this":
65286530
tag = parseThisTag(atToken, tagName);
65296531
break;
6532+
case "enum":
6533+
tag = parseEnumTag(atToken, tagName);
6534+
break;
65306535
case "arg":
65316536
case "argument":
65326537
case "param":
@@ -6627,7 +6632,7 @@ namespace ts {
66276632
}
66286633

66296634
removeLeadingNewlines(comments);
6630-
removeTrailingNewlines(comments);
6635+
removeTrailingWhitespace(comments);
66316636
return comments.length === 0 ? undefined : comments.join("");
66326637
}
66336638

@@ -6817,6 +6822,15 @@ namespace ts {
68176822
return finishNode(tag);
68186823
}
68196824

6825+
function parseEnumTag(atToken: AtToken, tagName: Identifier): JSDocEnumTag {
6826+
const tag = <JSDocEnumTag>createNode(SyntaxKind.JSDocEnumTag, atToken.pos);
6827+
tag.atToken = atToken;
6828+
tag.tagName = tagName;
6829+
tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
6830+
skipWhitespace();
6831+
return finishNode(tag);
6832+
}
6833+
68206834
function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag {
68216835
const typeExpression = tryParseTypeExpression();
68226836
skipWhitespace();
@@ -6835,7 +6849,7 @@ namespace ts {
68356849
let child: JSDocTypeTag | JSDocPropertyTag | false;
68366850
let jsdocTypeLiteral: JSDocTypeLiteral | undefined;
68376851
let childTypeTag: JSDocTypeTag | undefined;
6838-
const start = scanner.getStartPos();
6852+
const start = atToken.pos;
68396853
while (child = tryParse(() => parseChildPropertyTag())) {
68406854
if (!jsdocTypeLiteral) {
68416855
jsdocTypeLiteral = <JSDocTypeLiteral>createNode(SyntaxKind.JSDocTypeLiteral, start);
@@ -7030,8 +7044,8 @@ namespace ts {
70307044
skipWhitespace();
70317045
const typeParameter = <TypeParameterDeclaration>createNode(SyntaxKind.TypeParameter);
70327046
typeParameter.name = parseJSDocIdentifierName(Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
7033-
skipWhitespace();
70347047
finishNode(typeParameter);
7048+
skipWhitespace();
70357049
typeParameters.push(typeParameter);
70367050
} while (parseOptionalJsdoc(SyntaxKind.CommaToken));
70377051

src/compiler/resolutionCache.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace ts {
5252
getGlobalCache?(): string | undefined;
5353
writeLog(s: string): void;
5454
maxNumberOfFilesToIterateForInvalidation?: number;
55-
getCurrentProgram(): Program;
55+
getCurrentProgram(): Program | undefined;
5656
}
5757

5858
interface DirectoryWatchesOfFailedLookup {
@@ -497,7 +497,8 @@ namespace ts {
497497
}
498498

499499
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions: ResolutionWithFailedLookupLocations[], name: string) {
500-
const updateResolution = resolutionHost.getCurrentProgram().getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ?
500+
const program = resolutionHost.getCurrentProgram();
501+
const updateResolution = program && program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ?
501502
setRefCountToUndefined : watchFailedLookupLocationOfResolution;
502503
resolutions.forEach(updateResolution);
503504
}

src/compiler/transformers/declarations.ts

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

155155
if (node.kind === SyntaxKind.Bundle) {
156156
isBundledEmit = true;
157-
const refs = createMap<SourceFile>();
157+
refs = createMap<SourceFile>();
158158
let hasNoDefaultLib = false;
159159
const bundle = createBundle(map(node.sourceFiles,
160160
sourceFile => {
@@ -1164,6 +1164,17 @@ namespace ts {
11641164
return false;
11651165
}
11661166

1167+
function isScopeMarker(node: Node) {
1168+
return isExportAssignment(node) || isExportDeclaration(node);
1169+
}
1170+
1171+
function hasScopeMarker(node: Node) {
1172+
if (isModuleBlock(node)) {
1173+
return some(node.statements, isScopeMarker);
1174+
}
1175+
return false;
1176+
}
1177+
11671178
function ensureModifiers(node: Node, privateDeclaration?: boolean): ReadonlyArray<Modifier> | undefined {
11681179
const currentFlags = getModifierFlags(node);
11691180
const newFlags = ensureModifierFlags(node, privateDeclaration);
@@ -1178,7 +1189,7 @@ namespace ts {
11781189
let additions = (needsDeclare && !isAlwaysType(node)) ? ModifierFlags.Ambient : ModifierFlags.None;
11791190
const parentIsFile = node.parent.kind === SyntaxKind.SourceFile;
11801191
if (!parentIsFile || (isBundledEmit && parentIsFile && isExternalModule(node.parent as SourceFile))) {
1181-
mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : ModifierFlags.Export) | ModifierFlags.Default | ModifierFlags.Ambient);
1192+
mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : ModifierFlags.Export) | ModifierFlags.Ambient);
11821193
additions = ModifierFlags.None;
11831194
}
11841195
return maskModifierFlags(node, mask, additions);
@@ -1240,6 +1251,11 @@ namespace ts {
12401251

12411252
function maskModifierFlags(node: Node, modifierMask: ModifierFlags = ModifierFlags.All ^ ModifierFlags.Public, modifierAdditions: ModifierFlags = ModifierFlags.None): ModifierFlags {
12421253
let flags = (getModifierFlags(node) & modifierMask) | modifierAdditions;
1254+
if (flags & ModifierFlags.Default && !(flags & ModifierFlags.Export)) {
1255+
// A non-exported default is a nonsequitor - we usually try to remove all export modifiers
1256+
// from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid
1257+
flags ^= ModifierFlags.Export;
1258+
}
12431259
if (flags & ModifierFlags.Default && flags & ModifierFlags.Ambient) {
12441260
flags ^= ModifierFlags.Ambient; // `declare` is never required alongside `default` (and would be an error if printed)
12451261
}

src/compiler/tsbuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ namespace ts {
12681268
// Don't report status on "solution" projects
12691269
break;
12701270
default:
1271-
assertTypeIsNever(status);
1271+
assertType<never>(status);
12721272
}
12731273
}
12741274
}

src/compiler/types.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ namespace ts {
372372
JSDocAugmentsTag,
373373
JSDocClassTag,
374374
JSDocCallbackTag,
375+
JSDocEnumTag,
375376
JSDocParameterTag,
376377
JSDocReturnTag,
377378
JSDocThisTag,
@@ -581,6 +582,7 @@ namespace ts {
581582
| FunctionTypeNode
582583
| ConstructorTypeNode
583584
| JSDocFunctionType
585+
| ExportDeclaration
584586
| EndOfFileToken;
585587

586588
export type HasType =
@@ -858,6 +860,7 @@ namespace ts {
858860
name?: PropertyName;
859861
}
860862

863+
/** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */
861864
export type ObjectLiteralElementLike
862865
= PropertyAssignment
863866
| ShorthandPropertyAssignment
@@ -2202,7 +2205,7 @@ namespace ts {
22022205
name: Identifier;
22032206
}
22042207

2205-
export interface ExportDeclaration extends DeclarationStatement {
2208+
export interface ExportDeclaration extends DeclarationStatement, JSDocContainer {
22062209
kind: SyntaxKind.ExportDeclaration;
22072210
parent: SourceFile | ModuleBlock;
22082211
/** Will not be assigned in the case of `export * from "foo";` */
@@ -2348,6 +2351,11 @@ namespace ts {
23482351
kind: SyntaxKind.JSDocClassTag;
23492352
}
23502353

2354+
export interface JSDocEnumTag extends JSDocTag {
2355+
kind: SyntaxKind.JSDocEnumTag;
2356+
typeExpression?: JSDocTypeExpression;
2357+
}
2358+
23512359
export interface JSDocThisTag extends JSDocTag {
23522360
kind: SyntaxKind.JSDocThisTag;
23532361
typeExpression?: JSDocTypeExpression;
@@ -3564,6 +3572,7 @@ namespace ts {
35643572
Resolving = "__resolving__", // Indicator symbol used to mark partially resolved type aliases
35653573
ExportEquals = "export=", // Export assignment symbol
35663574
Default = "default", // Default export symbol (technically not wholly internal, but included here for usability)
3575+
This = "this",
35673576
}
35683577

35693578
/**
@@ -3680,7 +3689,7 @@ namespace ts {
36803689
/* @internal */
36813690
FreshLiteral = 1 << 25, // Fresh literal or unique type
36823691
/* @internal */
3683-
UnionOfUnitTypes = 1 << 26, // Type is union of unit types
3692+
UnionOfPrimitiveTypes = 1 << 26, // Type is union of primitive types
36843693
/* @internal */
36853694
ContainsWideningType = 1 << 27, // Type is or contains undefined or null widening type
36863695
/* @internal */
@@ -3725,7 +3734,7 @@ namespace ts {
37253734
Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive,
37263735
NotUnionOrUnit = Any | Unknown | ESSymbol | Object | NonPrimitive,
37273736
/* @internal */
3728-
NotUnit = Any | String | Number | Boolean | Enum | ESSymbol | Void | Never | StructuredOrInstantiable,
3737+
NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | StructuredOrInstantiable,
37293738
/* @internal */
37303739
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
37313740
/* @internal */

0 commit comments

Comments
 (0)