Skip to content

Commit 6a63c0d

Browse files
committed
Merge remote-tracking branch 'origin/master' into pathMappingModuleResolution
2 parents 2dbf621 + 383cbf0 commit 6a63c0d

135 files changed

Lines changed: 1492 additions & 224 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.

Jakefile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ compileFile(word2mdJs,
544544
// The generated spec.md; built for the 'generate-spec' task
545545
file(specMd, [word2mdJs, specWord], function () {
546546
var specWordFullPath = path.resolve(specWord);
547-
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd;
547+
var specMDFullPath = path.resolve(specMd);
548+
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + '"' + specMDFullPath + '"';
548549
console.log(cmd);
549550
child_process.exec(cmd, function () {
550551
complete();

src/compiler/checker.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15017,6 +15017,35 @@ namespace ts {
1501715017
return getReferencedValueSymbol(node) === argumentsSymbol;
1501815018
}
1501915019

15020+
function moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean {
15021+
let moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
15022+
if (!moduleSymbol) {
15023+
// module not found - be conservative
15024+
return true;
15025+
}
15026+
15027+
const hasExportAssignment = getExportAssignmentSymbol(moduleSymbol) !== undefined;
15028+
// if module has export assignment then 'resolveExternalModuleSymbol' will return resolved symbol for export assignment
15029+
// otherwise it will return moduleSymbol itself
15030+
moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
15031+
15032+
const symbolLinks = getSymbolLinks(moduleSymbol);
15033+
if (symbolLinks.exportsSomeValue === undefined) {
15034+
// for export assignments - check if resolved symbol for RHS is itself a value
15035+
// otherwise - check if at least one export is value
15036+
symbolLinks.exportsSomeValue = hasExportAssignment
15037+
? !!(moduleSymbol.flags & SymbolFlags.Value)
15038+
: forEachValue(getExportsOfModule(moduleSymbol), isValue);
15039+
}
15040+
15041+
return symbolLinks.exportsSomeValue;
15042+
15043+
function isValue(s: Symbol): boolean {
15044+
s = resolveSymbol(s);
15045+
return s && !!(s.flags & SymbolFlags.Value);
15046+
}
15047+
}
15048+
1502015049
// When resolved as an expression identifier, if the given node references an exported entity, return the declaration
1502115050
// node of the exported entity's container. Otherwise, return undefined.
1502215051
function getReferencedExportContainer(node: Identifier): SourceFile | ModuleDeclaration | EnumDeclaration {
@@ -15322,6 +15351,7 @@ namespace ts {
1532215351
getReferencedValueDeclaration,
1532315352
getTypeReferenceSerializationKind,
1532415353
isOptionalParameter,
15354+
moduleExportsSomeValue,
1532515355
isArgumentsLocalBinding,
1532615356
getExternalModuleFileFromDeclaration
1532715357
};
@@ -15969,6 +15999,13 @@ namespace ts {
1596915999
return grammarErrorOnNode((<ShorthandPropertyAssignment>prop).equalsToken, Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
1597016000
}
1597116001

16002+
// Modifiers are never allowed on properties except for 'async' on a method declaration
16003+
forEach(prop.modifiers, mod => {
16004+
if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) {
16005+
grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
16006+
}
16007+
});
16008+
1597216009
// ECMA-262 11.1.5 Object Initialiser
1597316010
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
1597416011
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@
435435
"category": "Error",
436436
"code": 1147
437437
},
438-
"Cannot compile modules unless the '--module' flag is provided.": {
438+
"Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.": {
439439
"category": "Error",
440440
"code": 1148
441441
},

src/compiler/emitter.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
499499
let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
500500
let exportSpecifiers: Map<ExportSpecifier[]>;
501501
let exportEquals: ExportAssignment;
502-
let hasExportStars: boolean;
502+
let hasExportStarsToExportValues: boolean;
503503

504504
let detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[];
505505

@@ -574,7 +574,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
574574
externalImports = undefined;
575575
exportSpecifiers = undefined;
576576
exportEquals = undefined;
577-
hasExportStars = undefined;
577+
hasExportStarsToExportValues = undefined;
578578
detachedCommentsInfo = undefined;
579579
sourceMapData = undefined;
580580
isEs6Module = false;
@@ -1453,6 +1453,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
14531453
case SyntaxKind.ForInStatement:
14541454
case SyntaxKind.ForOfStatement:
14551455
case SyntaxKind.IfStatement:
1456+
case SyntaxKind.JsxClosingElement:
14561457
case SyntaxKind.JsxSelfClosingElement:
14571458
case SyntaxKind.JsxOpeningElement:
14581459
case SyntaxKind.JsxSpreadAttribute:
@@ -6230,15 +6231,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
62306231
}
62316232
else {
62326233
// export * from "foo"
6233-
writeLine();
6234-
write("__export(");
6235-
if (modulekind !== ModuleKind.AMD) {
6236-
emitRequire(getExternalModuleName(node));
6237-
}
6238-
else {
6239-
write(generatedName);
6234+
if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) {
6235+
writeLine();
6236+
write("__export(");
6237+
if (modulekind !== ModuleKind.AMD) {
6238+
emitRequire(getExternalModuleName(node));
6239+
}
6240+
else {
6241+
write(generatedName);
6242+
}
6243+
write(");");
62406244
}
6241-
write(");");
62426245
}
62436246
emitEnd(node);
62446247
}
@@ -6326,7 +6329,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
63266329
externalImports = [];
63276330
exportSpecifiers = {};
63286331
exportEquals = undefined;
6329-
hasExportStars = false;
6332+
hasExportStarsToExportValues = false;
63306333
for (const node of sourceFile.statements) {
63316334
switch (node.kind) {
63326335
case SyntaxKind.ImportDeclaration:
@@ -6349,8 +6352,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
63496352
if ((<ExportDeclaration>node).moduleSpecifier) {
63506353
if (!(<ExportDeclaration>node).exportClause) {
63516354
// export * from "mod"
6352-
externalImports.push(<ExportDeclaration>node);
6353-
hasExportStars = true;
6355+
if (resolver.moduleExportsSomeValue((<ExportDeclaration>node).moduleSpecifier)) {
6356+
externalImports.push(<ExportDeclaration>node);
6357+
hasExportStarsToExportValues = true;
6358+
}
63546359
}
63556360
else if (resolver.isValueAliasDeclaration(node)) {
63566361
// export { x, y } from "mod" where at least one export is a value symbol
@@ -6376,7 +6381,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
63766381
}
63776382

63786383
function emitExportStarHelper() {
6379-
if (hasExportStars) {
6384+
if (hasExportStarsToExportValues) {
63806385
writeLine();
63816386
write("function __export(m) {");
63826387
increaseIndent();
@@ -6454,7 +6459,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
64546459
// should always win over entries with similar names that were added via star exports
64556460
// to support this we store names of local/indirect exported entries in a set.
64566461
// this set is used to filter names brought by star expors.
6457-
if (!hasExportStars) {
6462+
if (!hasExportStarsToExportValues) {
64586463
// local names set is needed only in presence of star exports
64596464
return undefined;
64606465
}
@@ -6879,6 +6884,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
68796884
write("});");
68806885
}
68816886
else {
6887+
// collectExternalModuleInfo prefilters star exports to keep only ones that export values
6888+
// this means that check 'resolver.moduleExportsSomeValue' is redundant and can be omitted here
68826889
writeLine();
68836890
// export * from 'foo'
68846891
// emit as:
@@ -7147,7 +7154,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
71477154
externalImports = undefined;
71487155
exportSpecifiers = undefined;
71497156
exportEquals = undefined;
7150-
hasExportStars = false;
7157+
hasExportStarsToExportValues = false;
71517158
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
71527159
emitEmitHelpers(node);
71537160
emitCaptureThisForNodeIfNecessary(node);
@@ -7371,7 +7378,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
73717378
externalImports = undefined;
73727379
exportSpecifiers = undefined;
73737380
exportEquals = undefined;
7374-
hasExportStars = false;
7381+
hasExportStarsToExportValues = false;
73757382
emitEmitHelpers(node);
73767383
emitCaptureThisForNodeIfNecessary(node);
73777384
emitLinesStartingAt(node.statements, startIndex);

src/compiler/parser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3639,7 +3639,7 @@ namespace ts {
36393639

36403640
parseExpected(SyntaxKind.OpenBraceToken);
36413641
if (token !== SyntaxKind.CloseBraceToken) {
3642-
node.expression = parseExpression();
3642+
node.expression = parseAssignmentExpressionOrHigher();
36433643
}
36443644
if (inExpressionContext) {
36453645
parseExpected(SyntaxKind.CloseBraceToken);
@@ -3981,6 +3981,7 @@ namespace ts {
39813981
}
39823982
else {
39833983
const propertyAssignment = <PropertyAssignment>createNode(SyntaxKind.PropertyAssignment, fullStart);
3984+
propertyAssignment.modifiers = modifiers;
39843985
propertyAssignment.name = propertyName;
39853986
propertyAssignment.questionToken = questionToken;
39863987
parseExpected(SyntaxKind.ColonToken);

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ namespace ts {
16491649
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
16501650
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
16511651
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
1652-
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
1652+
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
16531653
}
16541654

16551655
// Cannot specify module gen target of es6 when below es6

src/compiler/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,7 @@ namespace ts {
18871887
getReferencedValueDeclaration(reference: Identifier): Declaration;
18881888
getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind;
18891889
isOptionalParameter(node: ParameterDeclaration): boolean;
1890+
moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean;
18901891
isArgumentsLocalBinding(node: Identifier): boolean;
18911892
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile;
18921893
}
@@ -2005,6 +2006,7 @@ namespace ts {
20052006
exportsChecked?: boolean; // True if exports of external module have been checked
20062007
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
20072008
bindingElement?: BindingElement; // Binding element associated with property symbol
2009+
exportsSomeValue?: boolean; // true if module exports some value (not just types)
20082010
}
20092011

20102012
/* @internal */

src/lib/dom.generated.d.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6923,7 +6923,7 @@ interface IDBDatabase extends EventTarget {
69236923
onerror: (ev: Event) => any;
69246924
version: string;
69256925
close(): void;
6926-
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
6926+
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
69276927
deleteObjectStore(name: string): void;
69286928
transaction(storeNames: any, mode?: string): IDBTransaction;
69296929
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
@@ -6948,10 +6948,11 @@ declare var IDBFactory: {
69486948
}
69496949

69506950
interface IDBIndex {
6951-
keyPath: string;
6951+
keyPath: string | string[];
69526952
name: string;
69536953
objectStore: IDBObjectStore;
69546954
unique: boolean;
6955+
multiEntry: boolean;
69556956
count(key?: any): IDBRequest;
69566957
get(key: any): IDBRequest;
69576958
getKey(key: any): IDBRequest;
@@ -6988,7 +6989,7 @@ interface IDBObjectStore {
69886989
add(value: any, key?: any): IDBRequest;
69896990
clear(): IDBRequest;
69906991
count(key?: any): IDBRequest;
6991-
createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex;
6992+
createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex;
69926993
delete(key: any): IDBRequest;
69936994
deleteIndex(indexName: string): void;
69946995
get(key: any): IDBRequest;
@@ -12575,6 +12576,16 @@ interface XMLHttpRequestEventTarget {
1257512576
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
1257612577
}
1257712578

12579+
interface IDBObjectStoreParameters {
12580+
keyPath?: string | string[];
12581+
autoIncrement?: boolean;
12582+
}
12583+
12584+
interface IDBIndexParameters {
12585+
unique?: boolean;
12586+
multiEntry?: boolean;
12587+
}
12588+
1257812589
interface NodeListOf<TNode extends Node> extends NodeList {
1257912590
length: number;
1258012591
item(index: number): TNode;
@@ -12610,6 +12621,15 @@ interface ProgressEventInit extends EventInit {
1261012621
total?: number;
1261112622
}
1261212623

12624+
interface HTMLTemplateElement extends HTMLElement {
12625+
content: DocumentFragment;
12626+
}
12627+
12628+
declare var HTMLTemplateElement: {
12629+
prototype: HTMLTemplateElement;
12630+
new(): HTMLTemplateElement;
12631+
}
12632+
1261312633
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
1261412634

1261512635
interface ErrorEventHandler {

src/lib/webworker.generated.d.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ interface IDBDatabase extends EventTarget {
311311
onerror: (ev: Event) => any;
312312
version: string;
313313
close(): void;
314-
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
314+
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
315315
deleteObjectStore(name: string): void;
316316
transaction(storeNames: any, mode?: string): IDBTransaction;
317317
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
@@ -336,10 +336,11 @@ declare var IDBFactory: {
336336
}
337337

338338
interface IDBIndex {
339-
keyPath: string;
339+
keyPath: string | string[];
340340
name: string;
341341
objectStore: IDBObjectStore;
342342
unique: boolean;
343+
multiEntry: boolean;
343344
count(key?: any): IDBRequest;
344345
get(key: any): IDBRequest;
345346
getKey(key: any): IDBRequest;
@@ -376,7 +377,7 @@ interface IDBObjectStore {
376377
add(value: any, key?: any): IDBRequest;
377378
clear(): IDBRequest;
378379
count(key?: any): IDBRequest;
379-
createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex;
380+
createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex;
380381
delete(key: any): IDBRequest;
381382
deleteIndex(indexName: string): void;
382383
get(key: any): IDBRequest;
@@ -892,6 +893,16 @@ interface WorkerUtils extends Object, WindowBase64 {
892893
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
893894
}
894895

896+
interface IDBObjectStoreParameters {
897+
keyPath?: string | string[];
898+
autoIncrement?: boolean;
899+
}
900+
901+
interface IDBIndexParameters {
902+
unique?: boolean;
903+
multiEntry?: boolean;
904+
}
905+
895906
interface BlobPropertyBag {
896907
type?: string;
897908
endings?: string;

0 commit comments

Comments
 (0)