Skip to content

Commit b3f0a2a

Browse files
author
zhengbli
committed
Merge branch 'master' into JSDocCommentScaffolding
2 parents 3e59651 + 74dc5a2 commit b3f0a2a

138 files changed

Lines changed: 4161 additions & 953 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.
-46.8 KB
Binary file not shown.
-161 KB
Binary file not shown.
2.35 KB
Binary file not shown.
14.8 KB
Binary file not shown.

doc/spec.md

Lines changed: 117 additions & 45 deletions
Large diffs are not rendered by default.

src/compiler/binder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ namespace ts {
139139
function getDeclarationName(node: Declaration): string {
140140
if (node.name) {
141141
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
142-
return '"' + (<LiteralExpression>node.name).text + '"';
142+
return `"${(<LiteralExpression>node.name).text}"`;
143143
}
144144
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
145145
let nameExpression = (<ComputedPropertyName>node.name).expression;
@@ -830,7 +830,7 @@ namespace ts {
830830

831831
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
832832
// string to contain unicode escapes (as per ES5).
833-
return nodeText === '"use strict"' || nodeText === "'use strict'";
833+
return nodeText === "\"use strict\"" || nodeText === "'use strict'";
834834
}
835835

836836
function bindWorker(node: Node) {
@@ -930,7 +930,7 @@ namespace ts {
930930
function bindSourceFileIfExternalModule() {
931931
setExportContextFlag(file);
932932
if (isExternalModule(file)) {
933-
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"');
933+
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`);
934934
}
935935
}
936936

@@ -1062,4 +1062,4 @@ namespace ts {
10621062
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
10631063
}
10641064
}
1065-
}
1065+
}

src/compiler/checker.ts

Lines changed: 224 additions & 152 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ namespace ts {
335335
* @param fileName The path to the config file
336336
*/
337337
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
338-
let text = '';
338+
let text = "";
339339
try {
340340
text = sys.readFile(fileName);
341341
}
@@ -423,7 +423,7 @@ namespace ts {
423423
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
424424
}
425425
else {
426-
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, 'files', 'Array'));
426+
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array"));
427427
}
428428
}
429429
else {

src/compiler/core.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ namespace ts {
226226
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
227227
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
228228
if (array) {
229-
var count = array.length;
229+
const count = array.length;
230230
if (count > 0) {
231-
var pos = 0;
232-
var result = arguments.length <= 2 ? array[pos++] : initial;
231+
let pos = 0;
232+
let result = arguments.length <= 2 ? array[pos++] : initial;
233233
while (pos < count) {
234234
result = f(<U>result, array[pos++]);
235235
}
@@ -243,9 +243,9 @@ namespace ts {
243243
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
244244
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
245245
if (array) {
246-
var pos = array.length - 1;
246+
let pos = array.length - 1;
247247
if (pos >= 0) {
248-
var result = arguments.length <= 2 ? array[pos--] : initial;
248+
let result = arguments.length <= 2 ? array[pos--] : initial;
249249
while (pos >= 0) {
250250
result = f(<U>result, array[pos--]);
251251
}
@@ -530,7 +530,7 @@ namespace ts {
530530
if (path.lastIndexOf("file:///", 0) === 0) {
531531
return "file:///".length;
532532
}
533-
let idx = path.indexOf('://');
533+
let idx = path.indexOf("://");
534534
if (idx !== -1) {
535535
return idx + "://".length;
536536
}

src/compiler/declarationEmitter.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,14 +750,18 @@ namespace ts {
750750
}
751751

752752
function writeTypeAliasDeclaration(node: TypeAliasDeclaration) {
753+
let prevEnclosingDeclaration = enclosingDeclaration;
754+
enclosingDeclaration = node;
753755
emitJsDocComments(node);
754756
emitModuleElementDeclarationFlags(node);
755757
write("type ");
756758
writeTextOfNode(currentSourceFile, node.name);
759+
emitTypeParameters(node.typeParameters);
757760
write(" = ");
758761
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError);
759762
write(";");
760763
writeLine();
764+
enclosingDeclaration = prevEnclosingDeclaration;
761765

762766
function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
763767
return {
@@ -1497,11 +1501,8 @@ namespace ts {
14971501
// emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void;
14981502
writeTextOfNode(currentSourceFile, bindingElement.propertyName);
14991503
write(": ");
1500-
1501-
// If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern
1502-
emitBindingPattern(<BindingPattern>bindingElement.name);
15031504
}
1504-
else if (bindingElement.name) {
1505+
if (bindingElement.name) {
15051506
if (isBindingPattern(bindingElement.name)) {
15061507
// If it is a nested binding pattern, we will recursively descend into each element and emit each one separately.
15071508
// In the case of rest element, we will omit rest element.

0 commit comments

Comments
 (0)