Skip to content

Commit 1763db4

Browse files
committed
Merge remote-tracking branch 'origin/master' into far_display_parts
2 parents 4c847eb + 712e7bf commit 1763db4

32 files changed

+302
-53
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,8 +1023,8 @@ namespace ts {
10231023
}
10241024
}
10251025

1026-
function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration {
1027-
return findMap(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined);
1026+
function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration | undefined {
1027+
return forEach(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined);
10281028
}
10291029

10301030
function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol {
@@ -1191,6 +1191,7 @@ namespace ts {
11911191
if (!links.target) {
11921192
links.target = resolvingSymbol;
11931193
const node = getDeclarationOfAliasSymbol(symbol);
1194+
Debug.assert(!!node);
11941195
const target = getTargetOfAliasDeclaration(node);
11951196
if (links.target === resolvingSymbol) {
11961197
links.target = target || unknownSymbol;
@@ -1226,6 +1227,7 @@ namespace ts {
12261227
if (!links.referenced) {
12271228
links.referenced = true;
12281229
const node = getDeclarationOfAliasSymbol(symbol);
1230+
Debug.assert(!!node);
12291231
if (node.kind === SyntaxKind.ExportAssignment) {
12301232
// export default <symbol>
12311233
checkExpressionCached((<ExportAssignment>node).expression);
@@ -18761,7 +18763,13 @@ namespace ts {
1876118763
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
1876218764
}
1876318765
if (file.symbol && file.symbol.globalExports) {
18764-
mergeSymbolTable(globals, file.symbol.globalExports);
18766+
// Merge in UMD exports with first-in-wins semantics (see #9771)
18767+
const source = file.symbol.globalExports;
18768+
for (const id in source) {
18769+
if (!(id in globals)) {
18770+
globals[id] = source[id];
18771+
}
18772+
}
1876518773
}
1876618774
});
1876718775

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ namespace ts {
885885
function convertCompilerOptionsFromJsonWorker(jsonOptions: any,
886886
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
887887

888-
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
888+
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
889889
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
890890
return options;
891891
}

src/compiler/declarationEmitter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,10 @@ namespace ts {
11321132
// it if it's not a well known symbol. In that case, the text of the name will be exactly
11331133
// what we want, namely the name expression enclosed in brackets.
11341134
writeTextOfNode(currentText, node.name);
1135-
// If optional property emit ?
1136-
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.Parameter) && hasQuestionToken(node)) {
1135+
// If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
1136+
// we don't want to emit property declaration with "?"
1137+
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
1138+
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(node))) && hasQuestionToken(node)) {
11371139
write("?");
11381140
}
11391141
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {

src/compiler/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,7 @@ namespace ts {
23392339
token() === SyntaxKind.LessThanToken ||
23402340
token() === SyntaxKind.QuestionToken ||
23412341
token() === SyntaxKind.ColonToken ||
2342+
token() === SyntaxKind.CommaToken ||
23422343
canParseSemicolon();
23432344
}
23442345
return false;

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ namespace ts {
11011101
// - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
11021102
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
11031103
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
1104-
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
1104+
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
11051105
let currentNodeModulesDepth = 0;
11061106

11071107
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track

src/harness/unittests/convertCompilerOptionsFromJson.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ namespace ts {
403403
{
404404
compilerOptions: <CompilerOptions>{
405405
allowJs: true,
406+
maxNodeModuleJsDepth: 2,
406407
module: ModuleKind.CommonJS,
407408
target: ScriptTarget.ES5,
408409
noImplicitAny: false,
@@ -429,6 +430,7 @@ namespace ts {
429430
{
430431
compilerOptions: <CompilerOptions>{
431432
allowJs: false,
433+
maxNodeModuleJsDepth: 2,
432434
module: ModuleKind.CommonJS,
433435
target: ScriptTarget.ES5,
434436
noImplicitAny: false,
@@ -450,7 +452,8 @@ namespace ts {
450452
{
451453
compilerOptions:
452454
{
453-
allowJs: true
455+
allowJs: true,
456+
maxNodeModuleJsDepth: 2
454457
},
455458
errors: [{
456459
file: undefined,
@@ -469,7 +472,8 @@ namespace ts {
469472
{
470473
compilerOptions:
471474
{
472-
allowJs: true
475+
allowJs: true,
476+
maxNodeModuleJsDepth: 2
473477
},
474478
errors: <Diagnostic[]>[]
475479
}

src/harness/unittests/tsconfigParsing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ namespace ts {
186186
const content = `{
187187
"compilerOptions": {
188188
"allowJs": true
189+
// Some comments
189190
"outDir": "bin"
190191
}
191192
"files": ["file1.ts"]

src/services/services.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,14 @@ namespace ts {
280280
let pos = this.pos;
281281
const useJSDocScanner = this.kind >= SyntaxKind.FirstJSDocTagNode && this.kind <= SyntaxKind.LastJSDocTagNode;
282282
const processNode = (node: Node) => {
283-
if (pos < node.pos) {
283+
const isJSDocTagNode = isJSDocTag(node);
284+
if (!isJSDocTagNode && pos < node.pos) {
284285
pos = this.addSyntheticNodes(children, pos, node.pos, useJSDocScanner);
285286
}
286287
children.push(node);
287-
pos = node.end;
288+
if (!isJSDocTagNode) {
289+
pos = node.end;
290+
}
288291
};
289292
const processNodes = (nodes: NodeArray<Node>) => {
290293
if (pos < nodes.pos) {
@@ -299,10 +302,6 @@ namespace ts {
299302
processNode(jsDocComment);
300303
}
301304
}
302-
// For syntactic classifications, all trivia are classcified together, including jsdoc comments.
303-
// For that to work, the jsdoc comments should still be the leading trivia of the first child.
304-
// Restoring the scanner position ensures that.
305-
pos = this.pos;
306305
forEachChild(this, processNode, processNodes);
307306
if (pos < this.end) {
308307
this.addSyntheticNodes(children, pos, this.end);

src/services/utilities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,8 @@ namespace ts {
930930
const options: TranspileOptions = {
931931
fileName: "config.js",
932932
compilerOptions: {
933-
target: ScriptTarget.ES6
933+
target: ScriptTarget.ES6,
934+
removeComments: true
934935
},
935936
reportDiagnostics: true
936937
};

tests/baselines/reference/declFileConstructors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export declare class ConstructorWithPrivateParameterProperty {
247247
constructor(x: string);
248248
}
249249
export declare class ConstructorWithOptionalParameterProperty {
250-
x?: string;
250+
x: string;
251251
constructor(x?: string);
252252
}
253253
export declare class ConstructorWithParameterInitializer {
@@ -281,7 +281,7 @@ declare class GlobalConstructorWithPrivateParameterProperty {
281281
constructor(x: string);
282282
}
283283
declare class GlobalConstructorWithOptionalParameterProperty {
284-
x?: string;
284+
x: string;
285285
constructor(x?: string);
286286
}
287287
declare class GlobalConstructorWithParameterInitializer {

0 commit comments

Comments
 (0)