Merge branch 'master' into glob2

This commit is contained in:
Ron Buckton 2016-01-04 12:24:44 -08:00
commit cde12efec5
221 changed files with 5662 additions and 2204 deletions

View file

@ -108,17 +108,6 @@ var serverCoreSources = [
return path.join(serverDirectory, f);
});
var scriptSources = [
"tslint/booleanTriviaRule.ts",
"tslint/nextLineRule.ts",
"tslint/noNullRule.ts",
"tslint/preferConstRule.ts",
"tslint/typeOperatorSpacingRule.ts",
"tslint/noInOperatorRule.ts"
].map(function (f) {
return path.join(scriptsDirectory, f);
});
var serverSources = serverCoreSources.concat(servicesSources);
var languageServiceLibrarySources = [
@ -880,7 +869,8 @@ var tslintRules = ([
"preferConstRule",
"booleanTriviaRule",
"typeOperatorSpacingRule",
"noInOperatorRule"
"noInOperatorRule",
"noIncrementDecrementRule"
]);
var tslintRulesFiles = tslintRules.map(function(p) {
return path.join(tslintRuleDir, p + ".ts");
@ -923,10 +913,19 @@ function lintFileAsync(options, path, cb) {
});
}
var servicesLintTargets = [
"services.ts",
"outliningElementsCollector.ts",
"navigateTo.ts",
"patternMatcher.ts",
].map(function (s) {
return path.join(servicesDirectory, s);
});
var lintTargets = compilerSources
.concat(harnessCoreSources)
.concat(serverCoreSources)
.concat(scriptSources);
.concat(tslintRulesFiles)
.concat(servicesLintTargets);
desc("Runs tslint on the compiler sources");
task("lint", ["build-rules"], function() {

7
doc/README.md Normal file
View file

@ -0,0 +1,7 @@
This directory contains miscellaneous documentation such as the TypeScript language specification and logo.
If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook).
# Spec Contributions
The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats.
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests.

BIN
doc/images/image1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
doc/images/image2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
doc/images/image3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

BIN
doc/images/image4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -262,7 +262,7 @@ function f() {
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screen shot.
/
  ![](images/image1.png)
In this example, the programmer benefits from type inference without providing type annotations. Some beneficial tools, however, do require the programmer to provide type annotations. In TypeScript, we can express a parameter requirement as in the following code fragment.
@ -410,7 +410,7 @@ This signature denotes that a function may be passed as the parameter of the '$'
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot.
/
  ![](images/image2.png)
Section [3.3](#3.3) provides additional information about object types.
@ -627,7 +627,7 @@ An important goal of TypeScript is to provide accurate and straightforward types
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
/
  ![](images/image3.png)
The following code fragment uses this feature. Because the 'span' variable is inferred to have the type 'HTMLSpanElement', the code can reference without static error the 'isMultiline' property of 'span'.
@ -638,7 +638,7 @@ span.isMultiLine = false; // OK: HTMLSpanElement has isMultiline property
In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
/
  ![](images/image4.png)
Section [3.9.2.4](#3.9.2.4) provides details on how to use string literals in function signatures.

View file

@ -26,7 +26,9 @@ class BooleanTriviaWalker extends Lint.RuleWalker {
for (let index = 0; index < targetParameters.length; index++) {
const param = targetParameters[index];
const arg = node.arguments[index];
if (!(arg && param)) continue;
if (!(arg && param)) {
continue;
}
const argType = this.checker.getContextualType(arg);
if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) {
@ -38,7 +40,9 @@ class BooleanTriviaWalker extends Lint.RuleWalker {
if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) {
triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/
}
if (triviaContent !== param.getName()) {
const paramName = param.getName();
if (triviaContent !== paramName && triviaContent !== paramName + ":") {
this.addFailure(this.createFailure(arg.getStart(source), arg.getWidth(source), Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent)));
}
}

View file

@ -0,0 +1,37 @@
import * as Lint from "tslint/lib/lint";
import * as ts from "typescript";
export class Rule extends Lint.Rules.AbstractRule {
public static POSTFIX_FAILURE_STRING = "Don't use '++' or '--' postfix operators outside statements or for loops.";
public static PREFIX_FAILURE_STRING = "Don't use '++' or '--' prefix operators.";
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new IncrementDecrementWalker(sourceFile, this.getOptions()));
}
}
class IncrementDecrementWalker extends Lint.RuleWalker {
visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) {
super.visitPostfixUnaryExpression(node);
if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) {
this.visitIncrementDecrement(node);
}
}
visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) {
super.visitPrefixUnaryExpression(node);
if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.PREFIX_FAILURE_STRING));
}
}
visitIncrementDecrement(node: ts.UnaryExpression) {
if (node.parent && (node.parent.kind === ts.SyntaxKind.ExpressionStatement ||
node.parent.kind === ts.SyntaxKind.ForStatement)) {
return;
}
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.POSTFIX_FAILURE_STRING));
}
}

View file

@ -1,235 +0,0 @@
// word2md - Word to Markdown conversion tool
//
// word2md converts a Microsoft Word document to Markdown formatted text. The tool uses the
// Word Automation APIs to start an instance of Word and access the contents of the document
// being converted. The tool must be run using the cscript.exe script host and requires Word
// to be installed on the target machine. The name of the document to convert must be specified
// as a command line argument and the resulting Markdown is written to standard output. The
// tool recognizes the specific Word styles used in the TypeScript Language Specification.
var sys = (function () {
var fileStream = new ActiveXObject("ADODB.Stream");
fileStream.Type = 2 /*text*/;
var binaryStream = new ActiveXObject("ADODB.Stream");
binaryStream.Type = 1 /*binary*/;
var args = [];
for (var i = 0; i < WScript.Arguments.length; i++) {
args[i] = WScript.Arguments.Item(i);
}
return {
args: args,
createObject: function (typeName) { return new ActiveXObject(typeName); },
write: function (s) {
WScript.StdOut.Write(s);
},
writeFile: function (fileName, data) {
fileStream.Open();
binaryStream.Open();
try {
// Write characters in UTF-8 encoding
fileStream.Charset = "utf-8";
fileStream.WriteText(data);
// We don't want the BOM, skip it by setting the starting location to 3 (size of BOM).
fileStream.Position = 3;
fileStream.CopyTo(binaryStream);
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
}
finally {
binaryStream.Close();
fileStream.Close();
}
}
};
})();
function convertDocumentToMarkdown(doc) {
var result = "";
var lastStyle;
var lastInTable;
var tableColumnCount;
var tableCellIndex;
var columnAlignment = [];
function setProperties(target, properties) {
for (var name in properties) {
if (properties.hasOwnProperty(name)) {
var value = properties[name];
if (typeof value === "object") {
setProperties(target[name], value);
}
else {
target[name] = value;
}
}
}
}
function findReplace(findText, findOptions, replaceText, replaceOptions) {
var find = doc.range().find;
find.clearFormatting();
setProperties(find, findOptions);
var replace = find.replacement;
replace.clearFormatting();
setProperties(replace, replaceOptions);
find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2);
}
function fixHyperlinks() {
var count = doc.hyperlinks.count;
for (var i = 0; i < count; i++) {
var hyperlink = doc.hyperlinks.item(i + 1);
var address = hyperlink.address;
if (address && address.length > 0) {
var textToDisplay = hyperlink.textToDisplay;
hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")";
}
}
}
function write(s) {
result += s;
}
function writeTableHeader() {
for (var i = 0; i < tableColumnCount - 1; i++) {
switch (columnAlignment[i]) {
case 1:
write("|:---:");
break;
case 2:
write("|---:");
break;
default:
write("|---");
}
}
write("|\n");
}
function trimEndFormattingMarks(text) {
var i = text.length;
while (i > 0 && text.charCodeAt(i - 1) < 0x20)
i--;
return text.substr(0, i);
}
function writeBlockEnd() {
switch (lastStyle) {
case "Code":
write("```\n\n");
break;
case "List Paragraph":
case "Table":
case "TOC":
write("\n");
break;
}
}
function writeParagraph(p) {
var text = p.range.text;
var style = p.style.nameLocal;
var inTable = p.range.tables.count > 0;
var level = 1;
var sectionBreak = text.indexOf("\x0C") >= 0;
text = trimEndFormattingMarks(text);
if (inTable) {
style = "Table";
}
else if (style.match(/\s\d$/)) {
level = +style.substr(style.length - 1);
style = style.substr(0, style.length - 2);
}
if (lastStyle && style !== lastStyle) {
writeBlockEnd();
}
switch (style) {
case "Heading":
case "Appendix":
var section = p.range.listFormat.listString;
write("####".substr(0, level) + ' <a name="' + section + '"/>' + section + " " + text + "\n\n");
break;
case "Normal":
if (text.length) {
write(text + "\n\n");
}
break;
case "List Paragraph":
write(" ".substr(0, p.range.listFormat.listLevelNumber * 2 - 2) + "* " + text + "\n");
break;
case "Grammar":
write("&emsp;&emsp;" + text.replace(/\s\s\s/g, "&emsp;").replace(/\x0B/g, " \n&emsp;&emsp;&emsp;") + "\n\n");
break;
case "Code":
if (lastStyle !== "Code") {
write("```TypeScript\n");
}
else {
write("\n");
}
write(text.replace(/\x0B/g, " \n") + "\n");
break;
case "Table":
if (!lastInTable) {
tableColumnCount = p.range.tables.item(1).columns.count + 1;
tableCellIndex = 0;
}
if (tableCellIndex < tableColumnCount) {
columnAlignment[tableCellIndex] = p.alignment;
}
write("|" + text);
tableCellIndex++;
if (tableCellIndex % tableColumnCount === 0) {
write("\n");
if (tableCellIndex === tableColumnCount) {
writeTableHeader();
}
}
break;
case "TOC Heading":
write("## " + text + "\n\n");
break;
case "TOC":
var strings = text.split("\t");
write(" ".substr(0, level * 2 - 2) + "* [" + strings[0] + " " + strings[1] + "](#" + strings[0] + ")\n");
break;
}
if (sectionBreak) {
write("<br/>\n\n");
}
lastStyle = style;
lastInTable = inTable;
}
function writeDocument() {
var title = doc.builtInDocumentProperties.item(1) + "";
if (title.length) {
write("# " + title + "\n\n");
}
for (var p = doc.paragraphs.first; p; p = p.next()) {
writeParagraph(p);
}
writeBlockEnd();
}
findReplace("<", {}, "&lt;", {});
findReplace("&lt;", { style: "Code" }, "<", {});
findReplace("&lt;", { style: "Code Fragment" }, "<", {});
findReplace("&lt;", { style: "Terminal" }, "<", {});
findReplace("", { font: { subscript: true } }, "<sub>^&</sub>", { font: { subscript: false } });
findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 /* default font */ });
findReplace("", { style: "Production" }, "*^&*", { style: -66 /* default font */ });
findReplace("", { style: "Terminal" }, "`^&`", { style: -66 /* default font */ });
findReplace("", { font: { bold: true, italic: true } }, "***^&***", { font: { bold: false, italic: false } });
findReplace("", { font: { italic: true } }, "*^&*", { font: { italic: false } });
doc.fields.toggleShowCodes();
findReplace("^19 REF", {}, "[^&](#^&)", {});
doc.fields.toggleShowCodes();
fixHyperlinks();
writeDocument();
result = result.replace(/\x85/g, "\u2026");
result = result.replace(/\x96/g, "\u2013");
result = result.replace(/\x97/g, "\u2014");
return result;
}
function main(args) {
if (args.length !== 2) {
sys.write("Syntax: word2md <inputfile> <outputfile>\n");
return;
}
var app = sys.createObject("Word.Application");
var doc = app.documents.open(args[0]);
sys.writeFile(args[1], convertDocumentToMarkdown(doc));
doc.close(false);
app.quit();
}
main(sys.args);
//# sourceMappingURL=file:///c:/ts/scripts/word2md.js.map

View file

@ -72,6 +72,9 @@ module Word {
listFormat: ListFormat;
tables: Tables;
text: string;
textRetrievalMode: {
includeHiddenText: boolean;
}
words: Ranges;
}
@ -258,13 +261,27 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
function writeParagraph(p: Word.Paragraph) {
var text = p.range.text;
var range = p.range;
var text = range.text;
var style = p.style.nameLocal;
var inTable = p.range.tables.count > 0;
var inTable = range.tables.count > 0;
var level = 1;
var sectionBreak = text.indexOf("\x0C") >= 0;
text = trimEndFormattingMarks(text);
if (text === "/") {
// An inline image shows up in the text as a "/". When we see a paragraph
// consisting of nothing but "/", we check to see if the paragraph contains
// hidden text and, if so, emit that instead. The hidden text is assumed to
// contain an appropriate markdown image link.
range.textRetrievalMode.includeHiddenText = true;
var fullText = range.text;
range.textRetrievalMode.includeHiddenText = false;
if (text !== fullText) {
text = "&emsp;&emsp;" + fullText.substr(1);
}
}
if (inTable) {
style = "Table";
}
@ -280,7 +297,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
case "Heading":
case "Appendix":
var section = p.range.listFormat.listString;
var section = range.listFormat.listString;
write("####".substr(0, level) + ' <a name="' + section + '"/>' + section + " " + text + "\n\n");
break;
@ -291,7 +308,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
break;
case "List Paragraph":
write(" ".substr(0, p.range.listFormat.listLevelNumber * 2 - 2) + "* " + text + "\n");
write(" ".substr(0, range.listFormat.listLevelNumber * 2 - 2) + "* " + text + "\n");
break;
case "Grammar":
@ -310,7 +327,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
case "Table":
if (!lastInTable) {
tableColumnCount = p.range.tables.item(1).columns.count + 1;
tableColumnCount = range.tables.item(1).columns.count + 1;
tableCellIndex = 0;
}
if (tableCellIndex < tableColumnCount) {

View file

@ -1499,10 +1499,7 @@ namespace ts {
// If this is a property-parameter, then also declare the property symbol into the
// containing class.
if (node.flags & NodeFlags.AccessibilityModifier &&
node.parent.kind === SyntaxKind.Constructor &&
isClassLike(node.parent.parent)) {
if (isParameterPropertyDeclaration(node)) {
const classDeclaration = <ClassLikeDeclaration>node.parent.parent;
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
}

File diff suppressed because it is too large Load diff

View file

@ -334,7 +334,8 @@ namespace ts {
function parseStrings(args: string[]) {
let i = 0;
while (i < args.length) {
let s = args[i++];
let s = args[i];
i++;
if (s.charCodeAt(0) === CharacterCodes.at) {
parseResponseFile(s.slice(1));
}
@ -356,18 +357,21 @@ namespace ts {
switch (opt.type) {
case "number":
options[opt.name] = parseInt(args[i++]);
options[opt.name] = parseInt(args[i]);
i++;
break;
case "boolean":
options[opt.name] = true;
break;
case "string":
options[opt.name] = args[i++] || "";
options[opt.name] = args[i] || "";
i++;
break;
// If not a primitive, the possible types are specified in what is effectively a map of options.
default:
let map = <Map<number>>opt.type;
let key = (args[i++] || "").toLowerCase();
let key = (args[i] || "").toLowerCase();
i++;
if (hasProperty(map, key)) {
options[opt.name] = map[key];
}

View file

@ -253,9 +253,11 @@ namespace ts {
const count = array.length;
if (count > 0) {
let pos = 0;
let result = arguments.length <= 2 ? array[pos++] : initial;
let result = arguments.length <= 2 ? array[pos] : initial;
pos++;
while (pos < count) {
result = f(<U>result, array[pos++]);
result = f(<U>result, array[pos]);
pos++;
}
return <U>result;
}
@ -269,9 +271,11 @@ namespace ts {
if (array) {
let pos = array.length - 1;
if (pos >= 0) {
let result = arguments.length <= 2 ? array[pos--] : initial;
let result = arguments.length <= 2 ? array[pos] : initial;
pos--;
while (pos >= 0) {
result = f(<U>result, array[pos--]);
result = f(<U>result, array[pos]);
pos--;
}
return <U>result;
}
@ -1121,23 +1125,6 @@ namespace ts {
return <T>(removeFileExtension(path) + newExtension);
}
const backslashOrDoubleQuote = /[\"\\]/g;
const escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
const escapedCharsMap: Map<string> = {
"\0": "\\0",
"\t": "\\t",
"\v": "\\v",
"\f": "\\f",
"\b": "\\b",
"\r": "\\r",
"\n": "\\n",
"\\": "\\\\",
"\"": "\\\"",
"\u2028": "\\u2028", // lineSeparator
"\u2029": "\\u2029", // paragraphSeparator
"\u0085": "\\u0085" // nextLine
};
export interface ObjectAllocator {
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;

View file

@ -501,7 +501,8 @@ namespace ts {
}
let count = 0;
while (true) {
const name = baseName + "_" + (++count);
count++;
const name = baseName + "_" + count;
if (!hasProperty(currentIdentifiers, name)) {
return name;
}
@ -1534,14 +1535,6 @@ namespace ts {
}
function emitBindingElement(bindingElement: BindingElement) {
function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
const diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
return diagnosticMessage !== undefined ? {
diagnosticMessage,
errorNode: bindingElement,
typeName: bindingElement.name
} : undefined;
}
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
// If bindingElement is an omittedExpression (i.e. containing elision),

View file

@ -795,6 +795,10 @@
"category": "Error",
"code": 1248
},
"A decorator can only decorate a method implementation, not an overload.": {
"category": "Error",
"code": 1249
},
"'with' statements are not allowed in an async function block.": {
"category": "Error",
"code": 1300
@ -1691,7 +1695,7 @@
"category": "Error",
"code": 2528
},
"JSX element attributes type '{0}' must be an object type.": {
"JSX element attributes type '{0}' may not be a union type.": {
"category": "Error",
"code": 2600
},
@ -1759,6 +1763,14 @@
"category": "Error",
"code": 2658
},
"'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.": {
"category": "Error",
"code": 2659
},
"'super' can only be referenced in members of derived classes or object literal expressions.": {
"category": "Error",
"code": 2660
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000

View file

@ -779,12 +779,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
function emitTrailingCommaIfPresent(nodeList: NodeArray<Node>): void {
if (nodeList.hasTrailingComma) {
write(",");
}
}
function emitLinePreservingList(parent: Node, nodes: NodeArray<Node>, allowTrailingComma: boolean, spacesBetweenBraces: boolean) {
Debug.assert(nodes.length > 0);
@ -2451,7 +2445,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitPrefixUnaryExpression(node: PrefixUnaryExpression) {
const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand);
const exportChanged = (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) &&
isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand);
if (exportChanged) {
// emit
@ -3248,10 +3243,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
function emitDownLevelForOfStatement(node: ForOfStatement) {
emitLoop(node, emitDownLevelForOfStatementWorker);
}
function emitDownLevelForOfStatementWorker(node: ForOfStatement, loop: ConvertedLoop) {
// The following ES6 code:
//
@ -4289,22 +4280,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// TODO (yuisu) : we should not have special cases to condition emitting comments
// but have one place to fix check for these conditions.
if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature &&
node.parent && node.parent.kind !== SyntaxKind.PropertyAssignment &&
node.parent.kind !== SyntaxKind.CallExpression) {
// 1. Methods will emit the comments as part of emitting method declaration
const { kind, parent } = node;
if (kind !== SyntaxKind.MethodDeclaration &&
kind !== SyntaxKind.MethodSignature &&
parent &&
parent.kind !== SyntaxKind.PropertyAssignment &&
parent.kind !== SyntaxKind.CallExpression &&
parent.kind !== SyntaxKind.ArrayLiteralExpression) {
// 1. Methods will emit comments at their assignment declaration sites.
//
// 2. If the function is a property of object literal, emitting leading-comments
// is done by emitNodeWithoutSourceMap which then call this function.
// In particular, we would like to avoid emit comments twice in following case:
// For example:
// is done by emitNodeWithoutSourceMap which then call this function.
// In particular, we would like to avoid emit comments twice in following case:
//
// var obj = {
// id:
// /*comment*/ () => void
// }
//
// 3. If the function is an argument in call expression, emitting of comments will be
// taken care of in emit list of arguments inside of emitCallexpression
// taken care of in emit list of arguments inside of 'emitCallExpression'.
//
// 4. If the function is in an array literal, 'emitLinePreservingList' will take care
// of leading comments.
emitLeadingComments(node);
}
@ -4331,12 +4329,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
emitSignatureAndBody(node);
if (modulekind !== ModuleKind.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
if (modulekind !== ModuleKind.ES6 && kind === SyntaxKind.FunctionDeclaration && parent === currentSourceFile && node.name) {
emitExportMemberAssignments((<FunctionDeclaration>node).name);
}
emitEnd(node);
if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) {
if (kind !== SyntaxKind.MethodDeclaration && kind !== SyntaxKind.MethodSignature) {
emitTrailingComments(node);
}
}
@ -5466,7 +5464,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
});
leadingComma = true;
}
++parameterIndex;
parameterIndex++;
}
}
return argumentsWritten;
@ -6490,7 +6488,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
let started = false;
if (exportedDeclarations) {
for (let i = 0; i < exportedDeclarations.length; ++i) {
for (let i = 0; i < exportedDeclarations.length; i++) {
// write name of exported declaration, i.e 'export var x...'
writeExportedName(exportedDeclarations[i]);
}
@ -6606,7 +6604,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
writeLine();
write("var ");
const seen: Map<string> = {};
for (let i = 0; i < hoistedVars.length; ++i) {
for (let i = 0; i < hoistedVars.length; i++) {
const local = hoistedVars[i];
const name = local.kind === SyntaxKind.Identifier
? <Identifier>local
@ -6818,7 +6816,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitSetters(exportStarFunction: string, dependencyGroups: DependencyGroup[]) {
write("setters:[");
for (let i = 0; i < dependencyGroups.length; ++i) {
for (let i = 0; i < dependencyGroups.length; i++) {
if (i !== 0) {
write(",");
}
@ -6866,7 +6864,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(`${exportFunctionForFile}({`);
writeLine();
increaseIndent();
for (let i = 0, len = (<ExportDeclaration>entry).exportClause.elements.length; i < len; ++i) {
for (let i = 0, len = (<ExportDeclaration>entry).exportClause.elements.length; i < len; i++) {
if (i !== 0) {
write(",");
writeLine();
@ -6911,7 +6909,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("execute: function() {");
increaseIndent();
writeLine();
for (let i = startIndex; i < node.statements.length; ++i) {
for (let i = startIndex; i < node.statements.length; i++) {
const statement = node.statements[i];
switch (statement.kind) {
// - function declarations are not emitted because they were already hoisted
@ -6973,7 +6971,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
const groupIndices: Map<number> = {};
const dependencyGroups: DependencyGroup[] = [];
for (let i = 0; i < externalImports.length; ++i) {
for (let i = 0; i < externalImports.length; i++) {
const text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName);
if (hasProperty(groupIndices, text)) {
// deduplicate/group entries in dependency list by the dependency name
@ -6992,7 +6990,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(text);
}
write(`], function(${exportFunctionForFile}) {`);
write(`], function(${exportFunctionForFile}, __moduleName) {`);
writeLine();
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
@ -7223,7 +7221,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// Replace entities like &nbsp;
result = result.replace(/&(\w+);/g, function(s: any, m: string) {
if (entities[m] !== undefined) {
return String.fromCharCode(entities[m]);
const ch = String.fromCharCode(entities[m]);
// &quot; needs to be escaped
return ch === "\"" ? "\\\"" : ch;
}
else {
return s;
@ -7296,7 +7296,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitDirectivePrologues(statements: Node[], startWithNewLine: boolean, ensureUseStrict?: boolean): number {
let foundUseStrict = false;
for (let i = 0; i < statements.length; ++i) {
for (let i = 0; i < statements.length; i++) {
if (isPrologueDirective(statements[i])) {
if (isUseStrictPrologue(statements[i] as ExpressionStatement)) {
foundUseStrict = true;
@ -7318,7 +7318,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function writeLines(text: string): void {
const lines = text.split(/\r\n|\r|\n/g);
for (let i = 0; i < lines.length; ++i) {
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.length) {
writeLine();

View file

@ -771,10 +771,6 @@ namespace ts {
return doInsideOfContext(ParserContextFlags.Yield, func);
}
function doOutsideOfYieldContext<T>(func: () => T): T {
return doOutsideOfContext(ParserContextFlags.Yield, func);
}
function doInDecoratorContext<T>(func: () => T): T {
return doInsideOfContext(ParserContextFlags.Decorator, func);
}
@ -791,10 +787,6 @@ namespace ts {
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
}
function doOutsideOfYieldAndAwaitContext<T>(func: () => T): T {
return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
}
function inContext(flags: ParserContextFlags) {
return (contextFlags & flags) !== 0;
}
@ -851,10 +843,6 @@ namespace ts {
return token = scanner.scan();
}
function getTokenPos(pos: number): number {
return skipTrivia(sourceText, pos);
}
function reScanGreaterToken(): SyntaxKind {
return token = scanner.reScanGreaterToken();
}
@ -2644,10 +2632,6 @@ namespace ts {
isStartOfExpression();
}
function allowInAndParseExpression(): Expression {
return allowInAnd(parseExpression);
}
function parseExpression(): Expression {
// Expression[in]:
// AssignmentExpression[in]
@ -3962,7 +3946,6 @@ namespace ts {
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
const tokenIsIdentifier = isIdentifier();
const nameToken = token;
const propertyName = parsePropertyName();
// Disallowing of optional property assignments happens in the grammar checker.
@ -5104,10 +5087,6 @@ namespace ts {
return undefined;
}
function parseHeritageClausesWorker() {
return parseList(ParsingContext.HeritageClauses, parseHeritageClause);
}
function parseHeritageClause() {
if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) {
const node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
@ -5253,12 +5232,6 @@ namespace ts {
return nextToken() === SyntaxKind.SlashToken;
}
function nextTokenIsCommaOrFromKeyword() {
nextToken();
return token === SyntaxKind.CommaToken ||
token === SyntaxKind.FromKeyword;
}
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
parseExpected(SyntaxKind.ImportKeyword);
const afterImportPos = scanner.getStartPos();
@ -5751,13 +5724,6 @@ namespace ts {
return finishNode(parameter);
}
function parseJSDocOptionalType(type: JSDocType): JSDocOptionalType {
const result = <JSDocOptionalType>createNode(SyntaxKind.JSDocOptionalType, type.pos);
nextToken();
result.type = type;
return finishNode(result);
}
function parseJSDocTypeReference(): JSDocTypeReference {
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
result.name = parseSimplePropertyName();

View file

@ -495,7 +495,7 @@ namespace ts {
const moduleNames = map(newSourceFile.imports, name => name.text);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory));
// ensure that module resolution results are still correct
for (let i = 0; i < moduleNames.length; ++i) {
for (let i = 0; i < moduleNames.length; i++) {
const newResolution = resolutions[i];
const oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]);
const resolutionChanged = oldResolution
@ -523,7 +523,7 @@ namespace ts {
}
// update fileName -> file mapping
for (let i = 0, len = newSourceFiles.length; i < len; ++i) {
for (let i = 0, len = newSourceFiles.length; i < len; i++) {
filesByName.set(filePaths[i], newSourceFiles[i]);
}
@ -573,8 +573,11 @@ namespace ts {
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
// get any preEmit diagnostics, not just the ones
if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) {
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
if (options.noEmitOnError) {
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
if (preEmitDiagnostics.length > 0) {
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
}
}
// Create the emit resolver outside of the "emitTime" tracking code below. That way
@ -1070,7 +1073,7 @@ namespace ts {
file.resolvedModules = {};
const moduleNames = map(file.imports, name => name.text);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
for (let i = 0; i < file.imports.length; ++i) {
for (let i = 0; i < file.imports.length; i++) {
const resolution = resolutions[i];
setResolvedModule(file, moduleNames[i], resolution);
if (resolution && !options.noResolve) {

View file

@ -288,7 +288,8 @@ namespace ts {
let pos = 0;
let lineStart = 0;
while (pos < text.length) {
const ch = text.charCodeAt(pos++);
const ch = text.charCodeAt(pos);
pos++;
switch (ch) {
case CharacterCodes.carriageReturn:
if (text.charCodeAt(pos) === CharacterCodes.lineFeed) {
@ -823,7 +824,8 @@ namespace ts {
}
function scanString(): string {
const quote = text.charCodeAt(pos++);
const quote = text.charCodeAt(pos);
pos++;
let result = "";
let start = pos;
while (true) {
@ -933,7 +935,8 @@ namespace ts {
error(Diagnostics.Unexpected_end_of_text);
return "";
}
const ch = text.charCodeAt(pos++);
const ch = text.charCodeAt(pos);
pos++;
switch (ch) {
case CharacterCodes._0:
return "\0";
@ -1182,7 +1185,8 @@ namespace ts {
}
return pos += 2, token = SyntaxKind.ExclamationEqualsToken;
}
return pos++, token = SyntaxKind.ExclamationToken;
pos++;
return token = SyntaxKind.ExclamationToken;
case CharacterCodes.doubleQuote:
case CharacterCodes.singleQuote:
tokenValue = scanString();
@ -1193,7 +1197,8 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.PercentEqualsToken;
}
return pos++, token = SyntaxKind.PercentToken;
pos++;
return token = SyntaxKind.PercentToken;
case CharacterCodes.ampersand:
if (text.charCodeAt(pos + 1) === CharacterCodes.ampersand) {
return pos += 2, token = SyntaxKind.AmpersandAmpersandToken;
@ -1201,11 +1206,14 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.AmpersandEqualsToken;
}
return pos++, token = SyntaxKind.AmpersandToken;
pos++;
return token = SyntaxKind.AmpersandToken;
case CharacterCodes.openParen:
return pos++, token = SyntaxKind.OpenParenToken;
pos++;
return token = SyntaxKind.OpenParenToken;
case CharacterCodes.closeParen:
return pos++, token = SyntaxKind.CloseParenToken;
pos++;
return token = SyntaxKind.CloseParenToken;
case CharacterCodes.asterisk:
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.AsteriskEqualsToken;
@ -1216,7 +1224,8 @@ namespace ts {
}
return pos += 2, token = SyntaxKind.AsteriskAsteriskToken;
}
return pos++, token = SyntaxKind.AsteriskToken;
pos++;
return token = SyntaxKind.AsteriskToken;
case CharacterCodes.plus:
if (text.charCodeAt(pos + 1) === CharacterCodes.plus) {
return pos += 2, token = SyntaxKind.PlusPlusToken;
@ -1224,9 +1233,11 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.PlusEqualsToken;
}
return pos++, token = SyntaxKind.PlusToken;
pos++;
return token = SyntaxKind.PlusToken;
case CharacterCodes.comma:
return pos++, token = SyntaxKind.CommaToken;
pos++;
return token = SyntaxKind.CommaToken;
case CharacterCodes.minus:
if (text.charCodeAt(pos + 1) === CharacterCodes.minus) {
return pos += 2, token = SyntaxKind.MinusMinusToken;
@ -1234,7 +1245,8 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.MinusEqualsToken;
}
return pos++, token = SyntaxKind.MinusToken;
pos++;
return token = SyntaxKind.MinusToken;
case CharacterCodes.dot:
if (isDigit(text.charCodeAt(pos + 1))) {
tokenValue = scanNumber();
@ -1243,7 +1255,8 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.dot && text.charCodeAt(pos + 2) === CharacterCodes.dot) {
return pos += 3, token = SyntaxKind.DotDotDotToken;
}
return pos++, token = SyntaxKind.DotToken;
pos++;
return token = SyntaxKind.DotToken;
case CharacterCodes.slash:
// Single-line comment
if (text.charCodeAt(pos + 1) === CharacterCodes.slash) {
@ -1301,7 +1314,8 @@ namespace ts {
return pos += 2, token = SyntaxKind.SlashEqualsToken;
}
return pos++, token = SyntaxKind.SlashToken;
pos++;
return token = SyntaxKind.SlashToken;
case CharacterCodes._0:
if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.X || text.charCodeAt(pos + 1) === CharacterCodes.x)) {
@ -1354,9 +1368,11 @@ namespace ts {
tokenValue = scanNumber();
return token = SyntaxKind.NumericLiteral;
case CharacterCodes.colon:
return pos++, token = SyntaxKind.ColonToken;
pos++;
return token = SyntaxKind.ColonToken;
case CharacterCodes.semicolon:
return pos++, token = SyntaxKind.SemicolonToken;
pos++;
return token = SyntaxKind.SemicolonToken;
case CharacterCodes.lessThan:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
@ -1382,7 +1398,8 @@ namespace ts {
text.charCodeAt(pos + 2) !== CharacterCodes.asterisk) {
return pos += 2, token = SyntaxKind.LessThanSlashToken;
}
return pos++, token = SyntaxKind.LessThanToken;
pos++;
return token = SyntaxKind.LessThanToken;
case CharacterCodes.equals:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
@ -1403,7 +1420,8 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.greaterThan) {
return pos += 2, token = SyntaxKind.EqualsGreaterThanToken;
}
return pos++, token = SyntaxKind.EqualsToken;
pos++;
return token = SyntaxKind.EqualsToken;
case CharacterCodes.greaterThan:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
@ -1415,20 +1433,26 @@ namespace ts {
}
}
return pos++, token = SyntaxKind.GreaterThanToken;
pos++;
return token = SyntaxKind.GreaterThanToken;
case CharacterCodes.question:
return pos++, token = SyntaxKind.QuestionToken;
pos++;
return token = SyntaxKind.QuestionToken;
case CharacterCodes.openBracket:
return pos++, token = SyntaxKind.OpenBracketToken;
pos++;
return token = SyntaxKind.OpenBracketToken;
case CharacterCodes.closeBracket:
return pos++, token = SyntaxKind.CloseBracketToken;
pos++;
return token = SyntaxKind.CloseBracketToken;
case CharacterCodes.caret:
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.CaretEqualsToken;
}
return pos++, token = SyntaxKind.CaretToken;
pos++;
return token = SyntaxKind.CaretToken;
case CharacterCodes.openBrace:
return pos++, token = SyntaxKind.OpenBraceToken;
pos++;
return token = SyntaxKind.OpenBraceToken;
case CharacterCodes.bar:
if (text.charCodeAt(pos + 1) === CharacterCodes.bar) {
return pos += 2, token = SyntaxKind.BarBarToken;
@ -1436,13 +1460,17 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.BarEqualsToken;
}
return pos++, token = SyntaxKind.BarToken;
pos++;
return token = SyntaxKind.BarToken;
case CharacterCodes.closeBrace:
return pos++, token = SyntaxKind.CloseBraceToken;
pos++;
return token = SyntaxKind.CloseBraceToken;
case CharacterCodes.tilde:
return pos++, token = SyntaxKind.TildeToken;
pos++;
return token = SyntaxKind.TildeToken;
case CharacterCodes.at:
return pos++, token = SyntaxKind.AtToken;
pos++;
return token = SyntaxKind.AtToken;
case CharacterCodes.backslash:
let cookedChar = peekUnicodeEscape();
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
@ -1451,7 +1479,8 @@ namespace ts {
return token = getIdentifierToken();
}
error(Diagnostics.Invalid_character);
return pos++, token = SyntaxKind.Unknown;
pos++;
return token = SyntaxKind.Unknown;
default:
if (isIdentifierStart(ch, languageVersion)) {
pos++;
@ -1472,7 +1501,8 @@ namespace ts {
continue;
}
error(Diagnostics.Invalid_character);
return pos++, token = SyntaxKind.Unknown;
pos++;
return token = SyntaxKind.Unknown;
}
}
}
@ -1489,10 +1519,12 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.GreaterThanGreaterThanEqualsToken;
}
return pos++, token = SyntaxKind.GreaterThanGreaterThanToken;
pos++;
return token = SyntaxKind.GreaterThanGreaterThanToken;
}
if (text.charCodeAt(pos) === CharacterCodes.equals) {
return pos++, token = SyntaxKind.GreaterThanEqualsToken;
pos++;
return token = SyntaxKind.GreaterThanEqualsToken;
}
}
return token;

View file

@ -14,7 +14,6 @@ namespace ts {
reset(): void;
}
const nop = <(...args: any[]) => any>Function.prototype;
let nullSourceMapWriter: SourceMapWriter;
export function getNullSourceMapWriter(): SourceMapWriter {

View file

@ -211,7 +211,6 @@ namespace ts {
const _fs = require("fs");
const _path = require("path");
const _os = require("os");
const _tty = require("tty");
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
@ -306,10 +305,6 @@ namespace ts {
// time dynamically to match the large reference set?
const watchedFileSet = createWatchedFileSet();
function isNode4OrLater(): Boolean {
return parseInt(process.version.charAt(1)) >= 4;
}
const platform: string = _os.platform();
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
@ -506,4 +501,4 @@ namespace ts {
return undefined; // Unsupported host
}
})();
}
}

View file

@ -1195,7 +1195,7 @@ namespace ts {
// @kind(SyntaxKind.CaseClause)
export interface CaseClause extends Node {
expression?: Expression;
expression: Expression;
statements: NodeArray<Statement>;
}
@ -1731,6 +1731,7 @@ namespace ts {
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolAtLocation(node: Node): Symbol;
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol;
getTypeAtLocation(node: Node): Type;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;

View file

@ -92,7 +92,7 @@ namespace ts {
return false;
}
for (let i = 0; i < array1.length; ++i) {
for (let i = 0; i < array1.length; i++) {
const equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
if (!equals) {
return false;
@ -775,26 +775,38 @@ namespace ts {
}
}
export function getSuperContainer(node: Node, includeFunctions: boolean): Node {
/**
* Given an super call\property node returns a closest node where either
* - super call\property is legal in the node and not legal in the parent node the node.
* i.e. super call is legal in constructor but not legal in the class body.
* - node is arrow function (so caller might need to call getSuperContainer in case if he needs to climb higher)
* - super call\property is definitely illegal in the node (but might be legal in some subnode)
* i.e. super property access is illegal in function declaration but can be legal in the statement list
*/
export function getSuperContainer(node: Node, stopOnFunctions: boolean): Node {
while (true) {
node = node.parent;
if (!node) return node;
if (!node) {
return node;
}
switch (node.kind) {
case SyntaxKind.ComputedPropertyName:
// If the grandparent node is an object literal (as opposed to a class),
// then the computed property is not a 'super' container.
// A computed property name in a class needs to be a super container
// so that we can error on it.
if (isClassLike(node.parent.parent)) {
return node;
}
// If this is a computed property, then the parent should not
// make it a super container. The parent might be a property
// in an object literal, like a method or accessor. But in order for
// such a parent to be a super container, the reference must be in
// the *body* of the container.
node = node.parent;
break;
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
if (!stopOnFunctions) {
continue;
}
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return node;
case SyntaxKind.Decorator:
// Decorators are always applied outside of the body of a class or method.
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
@ -808,20 +820,6 @@ namespace ts {
node = node.parent;
}
break;
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
if (!includeFunctions) {
continue;
}
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return node;
}
}
}
@ -1886,8 +1884,8 @@ namespace ts {
writeTextOfNode,
writeLiteral,
writeLine,
increaseIndent: () => indent++,
decreaseIndent: () => indent--,
increaseIndent: () => { indent++; },
decreaseIndent: () => { indent--; },
getIndent: () => indent,
getTextPos: () => output.length,
getLine: () => lineCount + 1,
@ -2748,4 +2746,8 @@ namespace ts {
}
}
}
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
}
}

View file

@ -251,7 +251,6 @@ class CompilerBaselineRunner extends RunnerBase {
const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true);
const pullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ false);
const fullResults: ts.Map<TypeWriterResult[]> = {};
const pullResults: ts.Map<TypeWriterResult[]> = {};

View file

@ -321,11 +321,6 @@ namespace FourSlash {
PlaceOpenBraceOnNewLineForControlBlocks: false,
};
this.testData.files.forEach(file => {
const fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), "").substr(1);
const fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf("."));
});
// Open the first file by default
this.openFile(0);
}
@ -732,7 +727,7 @@ namespace FourSlash {
// Count only the references in local files. Filter the ones in lib and other files.
ts.forEach(references, entry => {
if (localFiles.some((fileName) => fileName === entry.fileName)) {
++referencesCount;
referencesCount++;
}
});
}
@ -762,10 +757,6 @@ namespace FourSlash {
return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition);
}
private assertionMessage(name: string, actualValue: any, expectedValue: any) {
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
}
public getSyntacticDiagnostics(expected: string) {
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
@ -910,7 +901,6 @@ namespace FourSlash {
}
public verifyCurrentParameterSpanIs(parameter: string) {
const activeSignature = this.getActiveSignatureHelpItem();
const activeParameter = this.getActiveParameter();
assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter);
}
@ -1103,7 +1093,7 @@ namespace FourSlash {
const emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on
const allFourSlashFiles = this.testData.files;
for (let idx = 0; idx < allFourSlashFiles.length; ++idx) {
for (let idx = 0; idx < allFourSlashFiles.length; idx++) {
const file = allFourSlashFiles[idx];
if (file.fileOptions[metadataOptionNames.emitThisFile] === "true") {
// Find a file with the flag emitThisFile turned on
@ -1863,7 +1853,7 @@ namespace FourSlash {
let item: ts.NavigateToItem = null;
// Count only the match that match the same MatchKind
for (let i = 0; i < items.length; ++i) {
for (let i = 0; i < items.length; i++) {
item = items[i];
if (!matchKind || item.matchKind === matchKind) {
actual++;
@ -2189,9 +2179,6 @@ namespace FourSlash {
}
}
// TOOD: should these just use the Harness's stdout/stderr?
const fsOutput = new Harness.Compiler.WriterAggregator();
const fsErrors = new Harness.Compiler.WriterAggregator();
export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) {
const content = Harness.IO.readFile(fileName);
runFourSlashTestContent(basePath, testType, content, fileName);
@ -2782,6 +2769,10 @@ namespace FourSlashInterface {
this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative);
}
public assertHasRanges(ranges: FourSlash.Range[]) {
assert(ranges.length !== 0, "Array of ranges is expected to be non-empty");
}
public completionListIsEmpty() {
this.state.verifyCompletionListIsEmpty(this.negative);
}

View file

@ -32,7 +32,6 @@
// this will work in the browser via browserify
var _chai: typeof chai = require("chai");
var assert: typeof _chai.assert = _chai.assert;
var expect: typeof _chai.expect = _chai.expect;
declare var __dirname: string; // Node-specific
var global = <any>Function("return this").call(null);
/* tslint:enable:no-var-keyword */
@ -514,7 +513,6 @@ namespace Harness {
}
const folder: any = fso.GetFolder(path);
const paths: string[] = [];
return filesInFolder(folder, path);
};
@ -618,7 +616,6 @@ namespace Harness {
export const getExecutingFilePath = () => "";
export const exit = (exitCode: number) => {};
const supportsCodePage = () => false;
export let log = (s: string) => console.log(s);
namespace Http {
@ -628,18 +625,6 @@ namespace Harness {
}
/// Ask the server to use node's path.resolve to resolve the given path
function getResolvedPathFromServer(path: string) {
const xhr = new XMLHttpRequest();
try {
xhr.open("GET", path + "?resolve", /*async*/ false);
xhr.send();
}
catch (e) {
return { status: 404, responseText: null };
}
return waitForXHR(xhr);
}
export interface XHRResponse {
status: number;

View file

@ -322,13 +322,6 @@ namespace Harness.LanguageService {
class LanguageServiceShimProxy implements ts.LanguageService {
constructor(private shim: ts.LanguageServiceShim) {
}
private unwrappJSONCallResult(result: string): any {
const parsedResult = JSON.parse(result);
if (parsedResult.error) {
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
}
return parsedResult.result;
}
cleanupSemanticCache(): void {
this.shim.cleanupSemanticCache();
}

View file

@ -306,25 +306,6 @@ namespace Playback {
}
}
const pathEquivCache: any = {};
function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) {
const key = left + "-~~-" + right;
function areSame(a: string, b: string) {
return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase();
}
function check() {
if (Harness.Path.getFileName(left).toLowerCase() === Harness.Path.getFileName(right).toLowerCase()) {
return areSame(left, right) || areSame(wrapper.resolvePath(left), right) || areSame(left, wrapper.resolvePath(right)) || areSame(wrapper.resolvePath(left), wrapper.resolvePath(right));
}
}
if (pathEquivCache.hasOwnProperty(key)) {
return pathEquivCache[key];
}
else {
return pathEquivCache[key] = check();
}
}
function noOpReplay(name: string) {
// console.log("Swallowed write operation during replay: " + name);
}

View file

@ -316,9 +316,10 @@ class ProjectRunner extends RunnerBase {
// If the generated output file resides in the parent folder or is rooted path,
// we need to instead create files that can live in the project reference folder
// but make sure extension of these files matches with the fileName the compiler asked to write
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
diskRelativeName = "diskFile" + nonSubfolderDiskFiles +
(Harness.Compiler.isDTS(fileName) ? ".d.ts" :
Harness.Compiler.isJS(fileName) ? ".js" : ".js.map");
nonSubfolderDiskFiles++;
}
if (Harness.Compiler.isJS(fileName)) {

View file

@ -263,13 +263,11 @@ namespace ts.server {
}
resolvePath(path: string): string {
const start = new Date().getTime();
const result = this.host.resolvePath(path);
return result;
}
fileExists(path: string): boolean {
const start = new Date().getTime();
const result = this.host.fileExists(path);
return result;
}
@ -325,32 +323,6 @@ namespace ts.server {
}
}
// assumes normalized paths
function getAbsolutePath(filename: string, directory: string) {
const rootLength = ts.getRootLength(filename);
if (rootLength > 0) {
return filename;
}
else {
const splitFilename = filename.split("/");
const splitDir = directory.split("/");
let i = 0;
let dirTail = 0;
const sflen = splitFilename.length;
while ((i < sflen) && (splitFilename[i].charAt(0) == ".")) {
const dots = splitFilename[i];
if (dots == "..") {
dirTail++;
}
else if (dots != ".") {
return undefined;
}
i++;
}
return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join("/");
}
}
export interface ProjectOptions {
// these fields can be present in the project file
files?: string[];
@ -516,7 +488,7 @@ namespace ts.server {
// number becomes 0 for a watcher, then we should close it.
directoryWatchersRefCount: ts.Map<number> = {};
hostConfiguration: HostConfiguration;
timerForDetectingProjectFilelistChanges: Map<NodeJS.Timer> = {};
timerForDetectingProjectFileListChanges: Map<NodeJS.Timer> = {};
constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) {
// ts.disableIncrementalParsing = true;
@ -571,21 +543,22 @@ namespace ts.server {
}
this.log("Detected source file changes: " + fileName);
this.startTimerForDetectingProjectFilelistChanges(project);
this.startTimerForDetectingProjectFileListChanges(project);
}
startTimerForDetectingProjectFilelistChanges(project: Project) {
if (this.timerForDetectingProjectFilelistChanges[project.projectFilename]) {
clearTimeout(this.timerForDetectingProjectFilelistChanges[project.projectFilename]);
startTimerForDetectingProjectFileListChanges(project: Project) {
if (this.timerForDetectingProjectFileListChanges[project.projectFilename]) {
clearTimeout(this.timerForDetectingProjectFileListChanges[project.projectFilename]);
}
this.timerForDetectingProjectFilelistChanges[project.projectFilename] = setTimeout(
() => this.handleProjectFilelistChanges(project),
this.timerForDetectingProjectFileListChanges[project.projectFilename] = setTimeout(
() => this.handleProjectFileListChanges(project),
250
);
}
handleProjectFilelistChanges(project: Project) {
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename);
handleProjectFileListChanges(project: Project) {
const { projectOptions } = this.configFileToProjectOptions(project.projectFilename);
const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
@ -613,7 +586,8 @@ namespace ts.server {
this.log("Detected newly added tsconfig file: " + fileName);
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(fileName);
const { projectOptions } = this.configFileToProjectOptions(fileName);
const rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f));
const openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName));
@ -748,7 +722,8 @@ namespace ts.server {
else {
for (const directory of project.directoriesWatchedForTsconfig) {
// if the ref count for this directory watcher drops to 0, it's time to close it
if (!(--project.projectService.directoryWatchersRefCount[directory])) {
project.projectService.directoryWatchersRefCount[directory]--;
if (!project.projectService.directoryWatchersRefCount[directory]) {
this.log("Close directory watcher for: " + directory);
project.projectService.directoryWatchersForTsconfig[directory].close();
delete project.projectService.directoryWatchersForTsconfig[directory];
@ -1113,7 +1088,6 @@ namespace ts.server {
* Close file whose contents is managed by the client
* @param filename is absolute pathname
*/
closeClientFile(filename: string) {
const info = ts.lookUp(this.filenameToScriptInfo, filename);
if (info) {
@ -1780,7 +1754,8 @@ namespace ts.server {
let count = 1;
let pos = 0;
this.index.every((ll, s, len) => {
starts[count++] = pos;
starts[count] = pos;
count++;
pos += ll.text.length;
return true;
}, 0);
@ -1788,9 +1763,9 @@ namespace ts.server {
}
getLineMapper() {
return ((line: number) => {
return (line: number) => {
return this.index.lineNumberToInfo(line).offset;
});
};
}
getTextChangeRangeSinceVersion(scriptVersion: number) {
@ -2046,7 +2021,8 @@ namespace ts.server {
while (adjustedStart >= childCharCount) {
this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart);
adjustedStart -= childCharCount;
child = this.children[++childIndex];
childIndex++;
child = this.children[childIndex];
childCharCount = child.charCount();
}
// Case I: both start and end of range in same subtree
@ -2061,14 +2037,16 @@ namespace ts.server {
return;
}
let adjustedLength = rangeLength - (childCharCount - adjustedStart);
child = this.children[++childIndex];
childIndex++;
child = this.children[childIndex];
childCharCount = child.charCount();
while (adjustedLength > childCharCount) {
if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) {
return;
}
adjustedLength -= childCharCount;
child = this.children[++childIndex];
childIndex++;
child = this.children[childIndex];
childCharCount = child.charCount();
}
if (adjustedLength > 0) {
@ -2192,7 +2170,8 @@ namespace ts.server {
if (childIndex < clen) {
splitNode = new LineNode();
while (childIndex < clen) {
splitNode.add(this.children[childIndex++]);
splitNode.add(this.children[childIndex]);
childIndex++;
}
splitNode.updateCounts();
}
@ -2233,7 +2212,9 @@ namespace ts.server {
let nodeIndex = 0;
childIndex++;
while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) {
this.children[childIndex++] = nodes[nodeIndex++];
this.children[childIndex] = nodes[nodeIndex];
childIndex++;
nodeIndex++;
}
let splitNodes: LineNode[] = [];
let splitNodeCount = 0;
@ -2246,7 +2227,8 @@ namespace ts.server {
}
let splitNode = <LineNode>splitNodes[0];
while (nodeIndex < nodeCount) {
splitNode.add(nodes[nodeIndex++]);
splitNode.add(nodes[nodeIndex]);
nodeIndex++;
if (splitNode.children.length === lineCollectionCapacity) {
splitNodeIndex++;
splitNode = <LineNode>splitNodes[splitNodeIndex];

View file

@ -4,9 +4,7 @@
/* tslint:disable:no-null */
namespace ts.server {
const nodeproto: typeof NodeJS._debugger = require("_debugger");
const readline: NodeJS.ReadLine = require("readline");
const path: NodeJS.Path = require("path");
const fs: typeof NodeJS.fs = require("fs");
const rl = readline.createInterface({

View file

@ -129,9 +129,6 @@ namespace ts.server {
export class Session {
protected projectService: ProjectService;
private pendingOperation = false;
private fileHash: ts.Map<number> = {};
private nextFileId = 1;
private errorTimer: any; /*NodeJS.Timer | number*/
private immediateId: any;
private changeSeq = 0;
@ -239,11 +236,6 @@ namespace ts.server {
}
}
private errorCheck(file: string, project: Project) {
this.syntacticCheck(file, project);
this.semanticCheck(file, project);
}
private reloadProjects() {
this.projectService.reloadProjects();
}
@ -271,7 +263,8 @@ namespace ts.server {
let index = 0;
const checkOne = () => {
if (matchSeq(seq)) {
const checkSpec = checkList[index++];
const checkSpec = checkList[index];
index++;
if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) {
this.syntacticCheck(checkSpec.fileName, checkSpec.project);
this.immediateId = setImmediate(() => {
@ -901,7 +894,7 @@ namespace ts.server {
}
getDiagnosticsForProject(delay: number, fileName: string) {
const { configFileName, fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
const { fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
// No need to analyze lib.d.ts
let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0);

View file

@ -360,7 +360,9 @@ namespace ts.formatting {
range: TextRange,
inheritedIndentation: number): number {
if (rangeOverlapsWithStartEnd(range, startPos, endPos)) {
if (rangeOverlapsWithStartEnd(range, startPos, endPos) ||
rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) {
if (inheritedIndentation !== Constants.Unknown) {
return inheritedIndentation;
}

View file

@ -450,8 +450,9 @@ namespace ts.formatting {
case SyntaxKind.ConditionalExpression:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.JsxElement:
case SyntaxKind.JsxOpeningElement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.JsxExpression:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
@ -467,6 +468,7 @@ namespace ts.formatting {
return false;
}
/* @internal */
export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) {
let childKind = child ? child.kind : SyntaxKind.Unknown;
switch (parent.kind) {
@ -484,6 +486,8 @@ namespace ts.formatting {
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return childKind !== SyntaxKind.Block;
case SyntaxKind.JsxElement:
return childKind !== SyntaxKind.JsxClosingElement;
}
// No explicit rule for given nodes so the result will follow the default value argument
return indentByDefault;

View file

@ -3,19 +3,19 @@ namespace ts.NavigateTo {
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };
export function getNavigateToItems(program: Program, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[] {
let patternMatcher = createPatternMatcher(searchValue);
const patternMatcher = createPatternMatcher(searchValue);
let rawItems: RawNavigateToItem[] = [];
// This means "compare in a case insensitive manner."
let baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
const baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
forEach(program.getSourceFiles(), sourceFile => {
cancellationToken.throwIfCancellationRequested();
let nameToDeclarations = sourceFile.getNamedDeclarations();
for (let name in nameToDeclarations) {
let declarations = getProperty(nameToDeclarations, name);
const nameToDeclarations = sourceFile.getNamedDeclarations();
for (const name in nameToDeclarations) {
const declarations = getProperty(nameToDeclarations, name);
if (declarations) {
// First do a quick check to see if the name of the declaration matches the
// last portion of the (possibly) dotted name they're searching for.
@ -25,11 +25,11 @@ namespace ts.NavigateTo {
continue;
}
for (let declaration of declarations) {
for (const declaration of declarations) {
// It was a match! If the pattern has dots in it, then also see if the
// declaration container matches as well.
if (patternMatcher.patternContainsDots) {
let containers = getContainers(declaration);
const containers = getContainers(declaration);
if (!containers) {
return undefined;
}
@ -41,8 +41,8 @@ namespace ts.NavigateTo {
}
}
let fileName = sourceFile.fileName;
let matchKind = bestMatchKind(matches);
const fileName = sourceFile.fileName;
const matchKind = bestMatchKind(matches);
rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration });
}
}
@ -54,7 +54,7 @@ namespace ts.NavigateTo {
rawItems = rawItems.slice(0, maxResultCount);
}
let items = map(rawItems, createNavigateToItem);
const items = map(rawItems, createNavigateToItem);
return items;
@ -62,7 +62,7 @@ namespace ts.NavigateTo {
Debug.assert(matches.length > 0);
// This is a case sensitive match, only if all the submatches were case sensitive.
for (let match of matches) {
for (const match of matches) {
if (!match.isCaseSensitive) {
return false;
}
@ -86,16 +86,16 @@ namespace ts.NavigateTo {
function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]) {
if (declaration && declaration.name) {
let text = getTextOfIdentifierOrLiteral(declaration.name);
const text = getTextOfIdentifierOrLiteral(declaration.name);
if (text !== undefined) {
containers.unshift(text);
}
else if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
return tryAddComputedPropertyName((<ComputedPropertyName>declaration.name).expression, containers, /*includeLastPortion:*/ true);
return tryAddComputedPropertyName((<ComputedPropertyName>declaration.name).expression, containers, /*includeLastPortion*/ true);
}
else {
// Don't know how to add this.
return false
return false;
}
}
@ -106,7 +106,7 @@ namespace ts.NavigateTo {
//
// [X.Y.Z]() { }
function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean {
let text = getTextOfIdentifierOrLiteral(expression);
const text = getTextOfIdentifierOrLiteral(expression);
if (text !== undefined) {
if (includeLastPortion) {
containers.unshift(text);
@ -115,24 +115,24 @@ namespace ts.NavigateTo {
}
if (expression.kind === SyntaxKind.PropertyAccessExpression) {
let propertyAccess = <PropertyAccessExpression>expression;
const propertyAccess = <PropertyAccessExpression>expression;
if (includeLastPortion) {
containers.unshift(propertyAccess.name.text);
}
return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true);
return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true);
}
return false;
}
function getContainers(declaration: Declaration) {
let containers: string[] = [];
const containers: string[] = [];
// First, if we started with a computed property name, then add all but the last
// portion into the container array.
if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
if (!tryAddComputedPropertyName((<ComputedPropertyName>declaration.name).expression, containers, /*includeLastPortion:*/ false)) {
if (!tryAddComputedPropertyName((<ComputedPropertyName>declaration.name).expression, containers, /*includeLastPortion*/ false)) {
return undefined;
}
}
@ -155,8 +155,8 @@ namespace ts.NavigateTo {
Debug.assert(matches.length > 0);
let bestMatchKind = PatternMatchKind.camelCase;
for (let match of matches) {
let kind = match.kind;
for (const match of matches) {
const kind = match.kind;
if (kind < bestMatchKind) {
bestMatchKind = kind;
}
@ -171,13 +171,13 @@ namespace ts.NavigateTo {
// We first sort case insensitively. So "Aaa" will come before "bar".
// Then we sort case sensitively, so "aaa" will come before "Aaa".
return i1.matchKind - i2.matchKind ||
i1.name.localeCompare(i2.name, undefined, baseSensitivity) ||
i1.name.localeCompare(i2.name, undefined, baseSensitivity) ||
i1.name.localeCompare(i2.name);
}
function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem {
let declaration = rawItem.declaration;
let container = <Declaration>getContainerNode(declaration);
const declaration = rawItem.declaration;
const container = <Declaration>getContainerNode(declaration);
return {
name: rawItem.name,
kind: getNodeKind(declaration),

View file

@ -1,180 +1,179 @@
/* @internal */
namespace ts {
export module OutliningElementsCollector {
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
let elements: OutliningSpan[] = [];
let collapseText = "...";
namespace ts.OutliningElementsCollector {
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
const elements: OutliningSpan[] = [];
const collapseText = "...";
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
if (hintSpanNode && startElement && endElement) {
let span: OutliningSpan = {
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
if (hintSpanNode && startElement && endElement) {
const span: OutliningSpan = {
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
}
function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) {
if (commentSpan) {
let span: OutliningSpan = {
textSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
hintSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) {
if (commentSpan) {
const span: OutliningSpan = {
textSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
hintSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
}
function addOutliningForLeadingCommentsForNode(n: Node) {
let comments = ts.getLeadingCommentRangesOfNode(n, sourceFile);
function addOutliningForLeadingCommentsForNode(n: Node) {
const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile);
if (comments) {
let firstSingleLineCommentStart = -1;
let lastSingleLineCommentEnd = -1;
let isFirstSingleLineComment = true;
let singleLineCommentCount = 0;
if (comments) {
let firstSingleLineCommentStart = -1;
let lastSingleLineCommentEnd = -1;
let isFirstSingleLineComment = true;
let singleLineCommentCount = 0;
for (let currentComment of comments) {
for (const currentComment of comments) {
// For single line comments, combine consecutive ones (2 or more) into
// a single span from the start of the first till the end of the last
if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) {
if (isFirstSingleLineComment) {
firstSingleLineCommentStart = currentComment.pos;
}
isFirstSingleLineComment = false;
lastSingleLineCommentEnd = currentComment.end;
singleLineCommentCount++;
// For single line comments, combine consecutive ones (2 or more) into
// a single span from the start of the first till the end of the last
if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) {
if (isFirstSingleLineComment) {
firstSingleLineCommentStart = currentComment.pos;
}
else if (currentComment.kind === SyntaxKind.MultiLineCommentTrivia) {
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
addOutliningSpanComments(currentComment, /*autoCollapse*/ false);
isFirstSingleLineComment = false;
lastSingleLineCommentEnd = currentComment.end;
singleLineCommentCount++;
}
else if (currentComment.kind === SyntaxKind.MultiLineCommentTrivia) {
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
addOutliningSpanComments(currentComment, /*autoCollapse*/ false);
singleLineCommentCount = 0;
lastSingleLineCommentEnd = -1;
isFirstSingleLineComment = true;
singleLineCommentCount = 0;
lastSingleLineCommentEnd = -1;
isFirstSingleLineComment = true;
}
}
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
}
}
function combineAndAddMultipleSingleLineComments(count: number, start: number, end: number) {
// Only outline spans of two or more consecutive single line comments
if (count > 1) {
const multipleSingleLineComments = {
pos: start,
end: end,
kind: SyntaxKind.SingleLineCommentTrivia
};
addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false);
}
}
function autoCollapse(node: Node) {
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
}
let depth = 0;
const maxDepth = 20;
function walk(n: Node): void {
if (depth > maxDepth) {
return;
}
if (isDeclaration(n)) {
addOutliningForLeadingCommentsForNode(n);
}
switch (n.kind) {
case SyntaxKind.Block:
if (!isFunctionBlock(n)) {
const parent = n.parent;
const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
// to be the entire span of the parent.
if (parent.kind === SyntaxKind.DoStatement ||
parent.kind === SyntaxKind.ForInStatement ||
parent.kind === SyntaxKind.ForOfStatement ||
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
parent.kind === SyntaxKind.WithStatement ||
parent.kind === SyntaxKind.CatchClause) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
break;
}
}
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
}
}
function combineAndAddMultipleSingleLineComments(count: number, start: number, end: number) {
// Only outline spans of two or more consecutive single line comments
if (count > 1) {
let multipleSingleLineComments = {
pos: start,
end: end,
kind: SyntaxKind.SingleLineCommentTrivia
}
addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false);
}
}
function autoCollapse(node: Node) {
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
}
let depth = 0;
let maxDepth = 20;
function walk(n: Node): void {
if (depth > maxDepth) {
return;
}
if (isDeclaration(n)) {
addOutliningForLeadingCommentsForNode(n);
}
switch (n.kind) {
case SyntaxKind.Block:
if (!isFunctionBlock(n)) {
let parent = n.parent;
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
// to be the entire span of the parent.
if (parent.kind === SyntaxKind.DoStatement ||
parent.kind === SyntaxKind.ForInStatement ||
parent.kind === SyntaxKind.ForOfStatement ||
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
parent.kind === SyntaxKind.WithStatement ||
parent.kind === SyntaxKind.CatchClause) {
if (parent.kind === SyntaxKind.TryStatement) {
// Could be the try-block, or the finally-block.
const tryStatement = <TryStatement>parent;
if (tryStatement.tryBlock === n) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
break;
}
if (parent.kind === SyntaxKind.TryStatement) {
// Could be the try-block, or the finally-block.
let tryStatement = <TryStatement>parent;
if (tryStatement.tryBlock === n) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
else if (tryStatement.finallyBlock === n) {
const finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
if (finallyKeyword) {
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
break;
}
else if (tryStatement.finallyBlock === n) {
let finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
if (finallyKeyword) {
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
break;
}
}
// fall through.
}
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
let span = createTextSpanFromBounds(n.getStart(), n.end);
elements.push({
textSpan: span,
hintSpan: span,
bannerText: collapseText,
autoCollapse: autoCollapse(n)
});
break;
// fall through.
}
// Fallthrough.
case SyntaxKind.ModuleBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
const span = createTextSpanFromBounds(n.getStart(), n.end);
elements.push({
textSpan: span,
hintSpan: span,
bannerText: collapseText,
autoCollapse: autoCollapse(n)
});
break;
}
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.CaseBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ArrayLiteralExpression:
let openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
let closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
break;
// Fallthrough.
case SyntaxKind.ModuleBlock: {
const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
break;
}
depth++;
forEachChild(n, walk);
depth--;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.CaseBlock: {
const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ArrayLiteralExpression:
const openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
const closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
break;
}
walk(sourceFile);
return elements;
depth++;
forEachChild(n, walk);
depth--;
}
walk(sourceFile);
return elements;
}
}

View file

@ -8,10 +8,10 @@ namespace ts {
camelCase
}
// Information about a match made by the pattern matcher between a candidate and the
// Information about a match made by the pattern matcher between a candidate and the
// search pattern.
export interface PatternMatch {
// What kind of match this was. Exact matches are better than prefix matches which are
// What kind of match this was. Exact matches are better than prefix matches which are
// better than substring matches which are better than CamelCase matches.
kind: PatternMatchKind;
@ -19,7 +19,7 @@ namespace ts {
// it was a better match.
camelCaseWeight?: number;
// If this was a match where all constituent parts of the candidate and search pattern
// If this was a match where all constituent parts of the candidate and search pattern
// matched case sensitively or case insensitively. Case sensitive matches of the kind
// are better matches than insensitive matches.
isCaseSensitive: boolean;
@ -35,7 +35,7 @@ namespace ts {
// once you no longer need it.
export interface PatternMatcher {
// Used to match a candidate against the last segment of a possibly dotted pattern. This
// is useful as a quick check to prevent having to compute a container before calling
// is useful as a quick check to prevent having to compute a container before calling
// "getMatches".
//
// For example, if the search pattern is "ts.c.SK" and the candidate is "SyntaxKind", then
@ -55,8 +55,8 @@ namespace ts {
}
// First we break up the pattern given by dots. Each portion of the pattern between the
// dots is a 'Segment'. The 'Segment' contains information about the entire section of
// text between the dots, as well as information about any individual 'Words' that we
// dots is a 'Segment'. The 'Segment' contains information about the entire section of
// text between the dots, as well as information about any individual 'Words' that we
// can break the segment into. A 'Word' is simply a contiguous sequence of characters
// that can appear in a typescript identifier. So "GetKeyword" would be one word, while
// "Get Keyword" would be two words. Once we have the individual 'words', we break those
@ -64,20 +64,20 @@ namespace ts {
// word, it make character spans corresponding to "U", "I" and "Element". These spans
// are then used when doing camel cased matches against candidate patterns.
interface Segment {
// Information about the entire piece of text between the dots. For example, if the
// text between the dots is 'GetKeyword', then TotalTextChunk.Text will be 'GetKeyword' and
// Information about the entire piece of text between the dots. For example, if the
// text between the dots is 'GetKeyword', then TotalTextChunk.Text will be 'GetKeyword' and
// TotalTextChunk.CharacterSpans will correspond to 'Get', 'Keyword'.
totalTextChunk: TextChunk;
// Information about the subwords compromising the total word. For example, if the
// text between the dots is 'GetFoo KeywordBar', then the subwords will be 'GetFoo'
// and 'KeywordBar'. Those individual words will have CharacterSpans of ('Get' and
// 'Foo') and('Keyword' and 'Bar') respectively.
// Information about the subwords compromising the total word. For example, if the
// text between the dots is 'GetFoo KeywordBar', then the subwords will be 'GetFoo'
// and 'KeywordBar'. Those individual words will have CharacterSpans of ('Get' and
// 'Foo') and('Keyword' and 'Bar') respectively.
subWordTextChunks: TextChunk[];
}
// Information about a chunk of text from the pattern. The chunk is a piece of text, with
// cached information about the character spans within in. Character spans are used for
// Information about a chunk of text from the pattern. The chunk is a piece of text, with
// cached information about the character spans within in. Character spans are used for
// camel case matching.
interface TextChunk {
// The text of the chunk. This should be a contiguous sequence of character that could
@ -92,9 +92,9 @@ namespace ts {
// for something entirely lowercase or not.
isLowerCase: boolean;
// The spans in this text chunk that we think are of interest and should be matched
// The spans in this text chunk that we think are of interest and should be matched
// independently. For example, if the chunk is for "UIElement" the the spans of interest
// correspond to "U", "I" and "Element". If "UIElement" isn't found as an exaxt, prefix.
// correspond to "U", "I" and "Element". If "UIElement" isn't found as an exact, prefix.
// or substring match, then the character spans will be used to attempt a camel case match.
characterSpans: TextSpan[];
}
@ -110,20 +110,19 @@ namespace ts {
export function createPatternMatcher(pattern: string): PatternMatcher {
// We'll often see the same candidate string many times when searching (For example, when
// we see the name of a module that is used everywhere, or the name of an overload). As
// such, we cache the information we compute about the candidate for the life of this
// we see the name of a module that is used everywhere, or the name of an overload). As
// such, we cache the information we compute about the candidate for the life of this
// pattern matcher so we don't have to compute it multiple times.
let stringToWordSpans: Map<TextSpan[]> = {};
const stringToWordSpans: Map<TextSpan[]> = {};
pattern = pattern.trim();
let fullPatternSegment = createSegment(pattern);
let dotSeparatedSegments = pattern.split(".").map(p => createSegment(p.trim()));
let invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);
const dotSeparatedSegments = pattern.split(".").map(p => createSegment(p.trim()));
const invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);
return {
getMatches,
getMatchesForLastSegmentOfPattern,
getMatchesForLastSegmentOfPattern,
patternContainsDots: dotSeparatedSegments.length > 1
};
@ -131,7 +130,7 @@ namespace ts {
function skipMatch(candidate: string) {
return invalidPattern || !candidate;
}
function getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[] {
if (skipMatch(candidate)) {
return undefined;
@ -148,7 +147,7 @@ namespace ts {
// First, check that the last part of the dot separated pattern matches the name of the
// candidate. If not, then there's no point in proceeding and doing the more
// expensive work.
let candidateMatch = matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
const candidateMatch = matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
if (!candidateMatch) {
return undefined;
}
@ -165,16 +164,16 @@ namespace ts {
// So far so good. Now break up the container for the candidate and check if all
// the dotted parts match up correctly.
let totalMatch = candidateMatch;
const totalMatch = candidateMatch;
for (let i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1;
i >= 0;
i--, j--) {
i -= 1, j -= 1) {
let segment = dotSeparatedSegments[i];
let containerName = candidateContainers[j];
const segment = dotSeparatedSegments[i];
const containerName = candidateContainers[j];
let containerMatch = matchSegment(containerName, segment);
const containerMatch = matchSegment(containerName, segment);
if (!containerMatch) {
// This container didn't match the pattern piece. So there's no match at all.
return undefined;
@ -197,7 +196,7 @@ namespace ts {
}
function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch {
let index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
const index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
if (index === 0) {
if (chunk.text.length === candidate.length) {
// a) Check if the part matches the candidate entirely, in an case insensitive or
@ -211,18 +210,18 @@ namespace ts {
}
}
let isLowercase = chunk.isLowerCase;
const isLowercase = chunk.isLowerCase;
if (isLowercase) {
if (index > 0) {
// c) If the part is entirely lowercase, then check if it is contained anywhere in the
// candidate in a case insensitive manner. If so, return that there was a substring
// match.
// match.
//
// Note: We only have a substring match if the lowercase part is prefix match of some
// word part. That way we don't match something like 'Class' when the user types 'a'.
// But we would match 'FooAttribute' (since 'Attribute' starts with 'a').
let wordSpans = getWordSpans(candidate);
for (let span of wordSpans) {
const wordSpans = getWordSpans(candidate);
for (const span of wordSpans) {
if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) {
return createPatternMatch(PatternMatchKind.substring, punctuationStripped,
/*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false));
@ -242,7 +241,7 @@ namespace ts {
if (!isLowercase) {
// e) If the part was not entirely lowercase, then attempt a camel cased match as well.
if (chunk.characterSpans.length > 0) {
let candidateParts = getWordSpans(candidate);
const candidateParts = getWordSpans(candidate);
let camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false);
if (camelCaseWeight !== undefined) {
return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight);
@ -259,8 +258,8 @@ namespace ts {
// f) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries?
// We could check every character boundary start of the candidate for the pattern. However, that's
// an m * n operation in the wost case. Instead, find the first instance of the pattern
// substring, and see if it starts on a capital letter. It seems unlikely that the user will try to
// an m * n operation in the wost case. Instead, find the first instance of the pattern
// substring, and see if it starts on a capital letter. It seems unlikely that the user will try to
// filter the list based on a substring that starts on a capital letter and also with a lowercase one.
// (Pattern: fogbar, Candidate: quuxfogbarFogBar).
if (chunk.text.length < candidate.length) {
@ -275,7 +274,7 @@ namespace ts {
function containsSpaceOrAsterisk(text: string): boolean {
for (let i = 0; i < text.length; i++) {
let ch = text.charCodeAt(i);
const ch = text.charCodeAt(i);
if (ch === CharacterCodes.space || ch === CharacterCodes.asterisk) {
return true;
}
@ -293,7 +292,7 @@ namespace ts {
// Note: if the segment contains a space or an asterisk then we must assume that it's a
// multi-word segment.
if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) {
let match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false);
const match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false);
if (match) {
return [match];
}
@ -317,7 +316,7 @@ namespace ts {
//
// c) If the word is entirely lowercase, then check if it is contained anywhere in the
// candidate in a case insensitive manner. If so, return that there was a substring
// match.
// match.
//
// Note: We only have a substring match if the lowercase part is prefix match of
// some word part. That way we don't match something like 'Class' when the user
@ -331,17 +330,17 @@ namespace ts {
// e) If the word was not entirely lowercase, then attempt a camel cased match as
// well.
//
// f) The word is all lower case. Is it a case insensitive substring of the candidate starting
// f) The word is all lower case. Is it a case insensitive substring of the candidate starting
// on a part boundary of the candidate?
//
// Only if all words have some sort of match is the pattern considered matched.
let subWordTextChunks = segment.subWordTextChunks;
const subWordTextChunks = segment.subWordTextChunks;
let matches: PatternMatch[] = undefined;
for (let subWordTextChunk of subWordTextChunks) {
for (const subWordTextChunk of subWordTextChunks) {
// Try to match the candidate with this word
let result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
const result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
if (!result) {
return undefined;
}
@ -354,18 +353,18 @@ namespace ts {
}
function partStartsWith(candidate: string, candidateSpan: TextSpan, pattern: string, ignoreCase: boolean, patternSpan?: TextSpan): boolean {
let patternPartStart = patternSpan ? patternSpan.start : 0;
let patternPartLength = patternSpan ? patternSpan.length : pattern.length;
const patternPartStart = patternSpan ? patternSpan.start : 0;
const patternPartLength = patternSpan ? patternSpan.length : pattern.length;
if (patternPartLength > candidateSpan.length) {
// Pattern part is longer than the candidate part. There can never be a match.
return false;
}
if (ignoreCase) {
for (let i = 0; i < patternPartLength; i++) {
let ch1 = pattern.charCodeAt(patternPartStart + i);
let ch2 = candidate.charCodeAt(candidateSpan.start + i);
const ch1 = pattern.charCodeAt(patternPartStart + i);
const ch2 = candidate.charCodeAt(candidateSpan.start + i);
if (toLowerCase(ch1) !== toLowerCase(ch2)) {
return false;
}
@ -373,8 +372,8 @@ namespace ts {
}
else {
for (let i = 0; i < patternPartLength; i++) {
let ch1 = pattern.charCodeAt(patternPartStart + i);
let ch2 = candidate.charCodeAt(candidateSpan.start + i);
const ch1 = pattern.charCodeAt(patternPartStart + i);
const ch2 = candidate.charCodeAt(candidateSpan.start + i);
if (ch1 !== ch2) {
return false;
}
@ -385,12 +384,12 @@ namespace ts {
}
function tryCamelCaseMatch(candidate: string, candidateParts: TextSpan[], chunk: TextChunk, ignoreCase: boolean): number {
let chunkCharacterSpans = chunk.characterSpans;
const chunkCharacterSpans = chunk.characterSpans;
// Note: we may have more pattern parts than candidate parts. This is because multiple
// pattern parts may match a candidate part. For example "SiUI" against "SimpleUI".
// We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U
// and I will both match in UI.
// and I will both match in UI.
let currentCandidate = 0;
let currentChunkSpan = 0;
@ -426,14 +425,14 @@ namespace ts {
// Consider the case of matching SiUI against SimpleUIElement. The candidate parts
// will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si'
// against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to
// still keep matching pattern parts against that candidate part.
// still keep matching pattern parts against that candidate part.
for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) {
let chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan];
const chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan];
if (gotOneMatchThisCandidate) {
// We've already gotten one pattern part match in this candidate. We will
// only continue trying to consumer pattern parts if the last part and this
// part are both upper case.
// part are both upper case.
if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) ||
!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) {
break;
@ -470,55 +469,11 @@ namespace ts {
}
}
// Helper function to compare two matches to determine which is better. Matches are first
// ordered by kind (so all prefix matches always beat all substring matches). Then, if the
// match is a camel case match, the relative weights of the match are used to determine
// which is better (with a greater weight being better). Then if the match is of the same
// type, then a case sensitive match is considered better than an insensitive one.
function patternMatchCompareTo(match1: PatternMatch, match2: PatternMatch): number {
return compareType(match1, match2) ||
compareCamelCase(match1, match2) ||
compareCase(match1, match2) ||
comparePunctuation(match1, match2);
}
function comparePunctuation(result1: PatternMatch, result2: PatternMatch) {
// Consider a match to be better if it was successful without stripping punctuation
// versus a match that had to strip punctuation to succeed.
if (result1.punctuationStripped !== result2.punctuationStripped) {
return result1.punctuationStripped ? 1 : -1;
}
return 0;
}
function compareCase(result1: PatternMatch, result2: PatternMatch) {
if (result1.isCaseSensitive !== result2.isCaseSensitive) {
return result1.isCaseSensitive ? -1 : 1;
}
return 0;
}
function compareType(result1: PatternMatch, result2: PatternMatch) {
return result1.kind - result2.kind;
}
function compareCamelCase(result1: PatternMatch, result2: PatternMatch) {
if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) {
// Swap the values here. If result1 has a higher weight, then we want it to come
// first.
return result2.camelCaseWeight - result1.camelCaseWeight;
}
return 0;
}
function createSegment(text: string): Segment {
return {
totalTextChunk: createTextChunk(text),
subWordTextChunks: breakPatternIntoTextChunks(text)
}
};
}
// A segment is considered invalid if we couldn't find any words in it.
@ -536,9 +491,9 @@ namespace ts {
return false;
}
// TODO: find a way to determine this for any unicode characters in a
// TODO: find a way to determine this for any unicode characters in a
// non-allocating manner.
let str = String.fromCharCode(ch);
const str = String.fromCharCode(ch);
return str === str.toUpperCase();
}
@ -553,22 +508,12 @@ namespace ts {
}
// TODO: find a way to determine this for any unicode characters in a
// TODO: find a way to determine this for any unicode characters in a
// non-allocating manner.
let str = String.fromCharCode(ch);
const str = String.fromCharCode(ch);
return str === str.toLowerCase();
}
function containsUpperCaseLetter(string: string): boolean {
for (let i = 0, n = string.length; i < n; i++) {
if (isUpperCaseLetter(string.charCodeAt(i))) {
return true;
}
}
return false;
}
function startsWith(string: string, search: string) {
for (let i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
@ -593,8 +538,8 @@ namespace ts {
// Assumes 'value' is already lowercase.
function startsWithIgnoringCase(string: string, value: string, start: number): boolean {
for (let i = 0, n = value.length; i < n; i++) {
let ch1 = toLowerCase(string.charCodeAt(i + start));
let ch2 = value.charCodeAt(i);
const ch1 = toLowerCase(string.charCodeAt(i + start));
const ch2 = value.charCodeAt(i);
if (ch1 !== ch2) {
return false;
@ -614,7 +559,7 @@ namespace ts {
return ch;
}
// TODO: find a way to compute this for any unicode characters in a
// TODO: find a way to compute this for any unicode characters in a
// non-allocating manner.
return String.fromCharCode(ch).toLowerCase().charCodeAt(0);
}
@ -629,16 +574,17 @@ namespace ts {
}
function breakPatternIntoTextChunks(pattern: string): TextChunk[] {
let result: TextChunk[] = [];
const result: TextChunk[] = [];
let wordStart = 0;
let wordLength = 0;
for (let i = 0; i < pattern.length; i++) {
let ch = pattern.charCodeAt(i);
const ch = pattern.charCodeAt(i);
if (isWordChar(ch)) {
if (wordLength++ === 0) {
if (wordLength === 0) {
wordStart = i;
}
wordLength++;
}
else {
if (wordLength > 0) {
@ -656,13 +602,13 @@ namespace ts {
}
function createTextChunk(text: string): TextChunk {
let textLowerCase = text.toLowerCase();
const textLowerCase = text.toLowerCase();
return {
text,
textLowerCase,
isLowerCase: text === textLowerCase,
characterSpans: breakIntoCharacterSpans(text)
}
};
}
/* @internal */ export function breakIntoCharacterSpans(identifier: string): TextSpan[] {
@ -674,15 +620,15 @@ namespace ts {
}
function breakIntoSpans(identifier: string, word: boolean): TextSpan[] {
let result: TextSpan[] = [];
const result: TextSpan[] = [];
let wordStart = 0;
for (let i = 1, n = identifier.length; i < n; i++) {
let lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
let currentIsDigit = isDigit(identifier.charCodeAt(i));
const lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
const currentIsDigit = isDigit(identifier.charCodeAt(i));
let hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
let hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
const hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
const hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
if (charIsPunctuation(identifier.charCodeAt(i - 1)) ||
charIsPunctuation(identifier.charCodeAt(i)) ||
@ -738,7 +684,7 @@ namespace ts {
function isAllPunctuation(identifier: string, start: number, end: number): boolean {
for (let i = start; i < end; i++) {
let ch = identifier.charCodeAt(i);
const ch = identifier.charCodeAt(i);
// We don't consider _ or $ as punctuation as there may be things with that name.
if (!charIsPunctuation(ch) || ch === CharacterCodes._ || ch === CharacterCodes.$) {
@ -759,8 +705,8 @@ namespace ts {
// etc.
if (index !== wordStart &&
index + 1 < identifier.length) {
let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
let nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
const currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
const nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
if (currentIsUpper && nextIsLower) {
// We have a transition from an upper to a lower letter here. But we only
@ -786,12 +732,12 @@ namespace ts {
}
function transitionFromLowerToUpper(identifier: string, word: boolean, index: number): boolean {
let lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
const lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
const currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
// See if the casing indicates we're starting a new word. Note: if we're breaking on
// words, then just seeing an upper case character isn't enough. Instead, it has to
// be uppercase and the previous character can't be uppercase.
// be uppercase and the previous character can't be uppercase.
//
// For example, breaking "AddMetadata" on words would make: Add Metadata
//
@ -802,7 +748,7 @@ namespace ts {
// on characters would be: A M
//
// We break the search string on characters. But we break the symbol name on words.
let transition = word
const transition = word
? (currentIsUpper && !lastIsUpper)
: currentIsUpper;
return transition;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts(4,8): error TS4033: Property 'f' of exported interface has or is using private name 'T'.
==== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts (1 errors) ====
type T = { x : number }
export interface I {
f: T;
~
!!! error TS4033: Property 'f' of exported interface has or is using private name 'T'.
}

View file

@ -17,7 +17,7 @@ module M {
//// [aliasesInSystemModule1.js]
System.register(['foo'], function(exports_1) {
System.register(['foo'], function(exports_1, __moduleName) {
"use strict";
var alias;
var cls, cls2, x, y, z, M;

View file

@ -16,7 +16,7 @@ module M {
}
//// [aliasesInSystemModule2.js]
System.register(["foo"], function(exports_1) {
System.register(["foo"], function(exports_1, __moduleName) {
"use strict";
var foo_1;
var cls, cls2, x, y, z, M;

View file

@ -10,7 +10,7 @@ export class Foo {
}
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var Foo;
return {
@ -26,7 +26,7 @@ System.register([], function(exports_1) {
}
});
//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, __moduleName) {
"use strict";
var b_1;
var x;

View file

@ -11,7 +11,7 @@ export class Foo {
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var Foo;
return {
@ -27,7 +27,7 @@ System.register([], function(exports_1) {
}
});
//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, __moduleName) {
"use strict";
var b_1;
var x;

View file

@ -12,7 +12,7 @@ export var x = new Foo();
//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, __moduleName) {
"use strict";
var b_1;
var x;

View file

@ -12,7 +12,7 @@ export var x = new Foo();
//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, __moduleName) {
"use strict";
var b_1;
var x;

View file

@ -7,7 +7,7 @@ export default class {}
export default function() {}
//// [a.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var default_1;
return {
@ -20,7 +20,7 @@ System.register([], function(exports_1) {
}
});
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
function default_1() { }
exports_1("default", default_1);

View file

@ -0,0 +1,31 @@
//// [arrayLiteralComments.ts]
var testArrayWithFunc = [
// Function comment
function() {
let x = 1;
},
// String comment
'1',
// Numeric comment
2,
// Object comment
{ a: 1 },
// Array comment
[1, 2, 3]
]
//// [arrayLiteralComments.js]
var testArrayWithFunc = [
// Function comment
function () {
var x = 1;
},
// String comment
'1',
// Numeric comment
2,
// Object comment
{ a: 1 },
// Array comment
[1, 2, 3]
];

View file

@ -0,0 +1,21 @@
=== tests/cases/compiler/arrayLiteralComments.ts ===
var testArrayWithFunc = [
>testArrayWithFunc : Symbol(testArrayWithFunc, Decl(arrayLiteralComments.ts, 0, 3))
// Function comment
function() {
let x = 1;
>x : Symbol(x, Decl(arrayLiteralComments.ts, 3, 11))
},
// String comment
'1',
// Numeric comment
2,
// Object comment
{ a: 1 },
>a : Symbol(a, Decl(arrayLiteralComments.ts, 10, 5))
// Array comment
[1, 2, 3]
]

View file

@ -0,0 +1,36 @@
=== tests/cases/compiler/arrayLiteralComments.ts ===
var testArrayWithFunc = [
>testArrayWithFunc : ((() => void) | string | number | { a: number; } | number[])[]
>[ // Function comment function() { let x = 1; }, // String comment '1', // Numeric comment 2, // Object comment { a: 1 }, // Array comment [1, 2, 3]] : ((() => void) | string | number | { a: number; } | number[])[]
// Function comment
function() {
>function() { let x = 1; } : () => void
let x = 1;
>x : number
>1 : number
},
// String comment
'1',
>'1' : string
// Numeric comment
2,
>2 : number
// Object comment
{ a: 1 },
>{ a: 1 } : { a: number; }
>a : number
>1 : number
// Array comment
[1, 2, 3]
>[1, 2, 3] : number[]
>1 : number
>2 : number
>3 : number
]

View file

@ -144,7 +144,7 @@ for (const y = 0; y < 1;) {
//// [capturedLetConstInLoop4.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var v0, v00, v1, v2, v3, v4, v5, v6, v7, v8, v0_c, v00_c, v1_c, v2_c, v3_c, v4_c, v5_c, v6_c, v7_c, v8_c;
//======let

View file

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2466: 'super' cannot be referenced in a computed property name.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts (1 errors) ====
@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11
//treatment of other similar violations.
[(super(), "prop")]() { }
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
!!! error TS2466: 'super' cannot be referenced in a computed property name.
};
}
}

View file

@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2466: 'super' cannot be referenced in a computed property name.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts (1 errors) ====
@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11
//treatment of other similar violations.
[(super(), "prop")]() { }
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
!!! error TS2466: 'super' cannot be referenced in a computed property name.
};
}
}

View file

@ -1,37 +0,0 @@
//// [conformanceFunctionOverloads.ts]
// Function overloads do not emit code
// Function overload signature with optional parameter
// Function overload signature with optional parameter
// Function overloads with generic and non-generic overloads
// Function overloads whose only difference is returning different unconstrained generic parameters
// Function overloads whose only difference is returning different constrained generic parameters
// Function overloads that differ only by type parameter constraints
// Function overloads with matching accessibility
// Function overloads with matching export
// Function overloads with more params than implementation signature
// Function overloads where return types are same infinitely recursive type reference
//// [conformanceFunctionOverloads.js]
// Function overloads do not emit code
// Function overload signature with optional parameter
// Function overload signature with optional parameter
// Function overloads with generic and non-generic overloads
// Function overloads whose only difference is returning different unconstrained generic parameters
// Function overloads whose only difference is returning different constrained generic parameters
// Function overloads that differ only by type parameter constraints
// Function overloads with matching accessibility
// Function overloads with matching export
// Function overloads with more params than implementation signature
// Function overloads where return types are same infinitely recursive type reference

View file

@ -1,25 +0,0 @@
=== tests/cases/conformance/functions/conformanceFunctionOverloads.ts ===
// Function overloads do not emit code
No type information for this code.
No type information for this code.// Function overload signature with optional parameter
No type information for this code.
No type information for this code.// Function overload signature with optional parameter
No type information for this code.
No type information for this code.// Function overloads with generic and non-generic overloads
No type information for this code.
No type information for this code.// Function overloads whose only difference is returning different unconstrained generic parameters
No type information for this code.
No type information for this code.// Function overloads whose only difference is returning different constrained generic parameters
No type information for this code.
No type information for this code.// Function overloads that differ only by type parameter constraints
No type information for this code.
No type information for this code.// Function overloads with matching accessibility
No type information for this code.
No type information for this code.// Function overloads with matching export
No type information for this code.
No type information for this code.// Function overloads with more params than implementation signature
No type information for this code.
No type information for this code.// Function overloads where return types are same infinitely recursive type reference
No type information for this code.
No type information for this code.
No type information for this code.

View file

@ -1,25 +0,0 @@
=== tests/cases/conformance/functions/conformanceFunctionOverloads.ts ===
// Function overloads do not emit code
No type information for this code.
No type information for this code.// Function overload signature with optional parameter
No type information for this code.
No type information for this code.// Function overload signature with optional parameter
No type information for this code.
No type information for this code.// Function overloads with generic and non-generic overloads
No type information for this code.
No type information for this code.// Function overloads whose only difference is returning different unconstrained generic parameters
No type information for this code.
No type information for this code.// Function overloads whose only difference is returning different constrained generic parameters
No type information for this code.
No type information for this code.// Function overloads that differ only by type parameter constraints
No type information for this code.
No type information for this code.// Function overloads with matching accessibility
No type information for this code.
No type information for this code.// Function overloads with matching export
No type information for this code.
No type information for this code.// Function overloads with more params than implementation signature
No type information for this code.
No type information for this code.// Function overloads where return types are same infinitely recursive type reference
No type information for this code.
No type information for this code.
No type information for this code.

View file

@ -13,7 +13,7 @@ var decorator: ClassDecorator;
export default class {}
//// [a.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -35,7 +35,7 @@ System.register([], function(exports_1) {
}
});
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

View file

@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts (1 errors) ====
@ -9,7 +9,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10
class C extends S {
@super.decorator
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
method() { }
}
}

View file

@ -0,0 +1,13 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethodOverload1.ts(4,5): error TS1249: A decorator can only decorate a method implementation, not an overload.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethodOverload1.ts (1 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec
~
!!! error TS1249: A decorator can only decorate a method implementation, not an overload.
method()
method() { }
}

View file

@ -0,0 +1,16 @@
//// [decoratorOnClassMethodOverload1.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec
method()
method() { }
}
//// [decoratorOnClassMethodOverload1.js]
var C = (function () {
function C() {
}
C.prototype.method = function () { };
return C;
}());

View file

@ -0,0 +1,25 @@
//// [decoratorOnClassMethodOverload2.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
method()
@dec
method() { }
}
//// [decoratorOnClassMethodOverload2.js]
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var C = (function () {
function C() {
}
C.prototype.method = function () { };
__decorate([
dec
], C.prototype, "method", null);
return C;
}());

View file

@ -0,0 +1,24 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethodOverload2.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : Symbol(dec, Decl(decoratorOnClassMethodOverload2.ts, 0, 0))
>T : Symbol(T, Decl(decoratorOnClassMethodOverload2.ts, 0, 21))
>target : Symbol(target, Decl(decoratorOnClassMethodOverload2.ts, 0, 24))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodOverload2.ts, 0, 36))
>descriptor : Symbol(descriptor, Decl(decoratorOnClassMethodOverload2.ts, 0, 57))
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, --, --))
>T : Symbol(T, Decl(decoratorOnClassMethodOverload2.ts, 0, 21))
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, --, --))
>T : Symbol(T, Decl(decoratorOnClassMethodOverload2.ts, 0, 21))
class C {
>C : Symbol(C, Decl(decoratorOnClassMethodOverload2.ts, 0, 126))
method()
>method : Symbol(method, Decl(decoratorOnClassMethodOverload2.ts, 2, 9), Decl(decoratorOnClassMethodOverload2.ts, 3, 12))
@dec
>dec : Symbol(dec, Decl(decoratorOnClassMethodOverload2.ts, 0, 0))
method() { }
>method : Symbol(method, Decl(decoratorOnClassMethodOverload2.ts, 2, 9), Decl(decoratorOnClassMethodOverload2.ts, 3, 12))
}

View file

@ -0,0 +1,24 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethodOverload2.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
method()
>method : () => any
@dec
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
method() { }
>method : () => any
}

View file

@ -8,7 +8,7 @@ export default function foo() {}
//// [a.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var Foo;
return {
@ -21,7 +21,7 @@ System.register([], function(exports_1) {
}
});
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
function foo() { }
exports_1("default", foo);

View file

@ -1,6 +1,6 @@
tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/compiler/emitThisInSuperMethodCall.ts (3 errors) ====
@ -15,7 +15,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super'
function inner() {
super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
};
}
@ -24,7 +24,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super'
() => {
super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
}
}
@ -32,7 +32,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super'
function inner() {
super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
}
}

View file

@ -0,0 +1,129 @@
tests/cases/compiler/enumAssignmentCompat3.ts(68,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
Property 'd' is missing in type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(70,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
Property 'd' is missing in type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(71,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
tests/cases/compiler/enumAssignmentCompat3.ts(75,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
Property 'c' is missing in type 'Ab.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(76,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
Property 'a' is missing in type 'Cd.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(77,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
tests/cases/compiler/enumAssignmentCompat3.ts(82,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(83,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2322: Type 'Merged.E' is not assignable to type 'First.E'.
Property 'd' is missing in type 'First.E'.
==== tests/cases/compiler/enumAssignmentCompat3.ts (9 errors) ====
namespace First {
export enum E {
a, b, c,
}
}
namespace Abc {
export enum E {
a, b, c,
}
export enum Nope {
a, b, c,
}
}
namespace Abcd {
export enum E {
a, b, c, d,
}
}
namespace Ab {
export enum E {
a, b,
}
}
namespace Cd {
export enum E {
c, d,
}
}
namespace Const {
export const enum E {
a, b, c,
}
}
namespace Decl {
export declare enum E {
a, b, c = 3,
}
}
namespace Merged {
export enum E {
a, b,
}
export enum E {
c = 3, d,
}
}
namespace Merged2 {
export enum E {
a, b, c
}
export module E {
export let d = 5;
}
}
var abc: First.E;
var secondAbc: Abc.E;
var secondAbcd: Abcd.E;
var secondAb: Ab.E;
var secondCd: Cd.E;
var nope: Abc.Nope;
var k: Const.E;
var decl: Decl.E;
var merged: Merged.E;
var merged2: Merged2.E;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
~~~
!!! error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
!!! error TS2322: Property 'd' is missing in type 'First.E'.
abc = secondAb; // ok
abc = secondCd; // missing 'd'
~~~
!!! error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
!!! error TS2322: Property 'd' is missing in type 'First.E'.
abc = nope; // nope!
~~~
!!! error TS2322: Type 'Nope' is not assignable to type 'E'.
abc = decl; // ok
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
~~~~~~~~
!!! error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
!!! error TS2322: Property 'c' is missing in type 'Ab.E'.
secondCd = abc; // missing 'a' and 'b'
~~~~~~~~
!!! error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
!!! error TS2322: Property 'a' is missing in type 'Cd.E'.
nope = abc; // nope!
~~~~
!!! error TS2322: Type 'E' is not assignable to type 'Nope'.
decl = abc; // ok
// const is only assignable to itself
k = k;
abc = k; // error
~~~
!!! error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
k = abc;
~
!!! error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
// merged enums compare all their members
abc = merged; // missing 'd'
~~~
!!! error TS2322: Type 'Merged.E' is not assignable to type 'First.E'.
!!! error TS2322: Property 'd' is missing in type 'First.E'.
merged = abc; // ok
abc = merged2; // ok
merged2 = abc; // ok

View file

@ -0,0 +1,202 @@
//// [enumAssignmentCompat3.ts]
namespace First {
export enum E {
a, b, c,
}
}
namespace Abc {
export enum E {
a, b, c,
}
export enum Nope {
a, b, c,
}
}
namespace Abcd {
export enum E {
a, b, c, d,
}
}
namespace Ab {
export enum E {
a, b,
}
}
namespace Cd {
export enum E {
c, d,
}
}
namespace Const {
export const enum E {
a, b, c,
}
}
namespace Decl {
export declare enum E {
a, b, c = 3,
}
}
namespace Merged {
export enum E {
a, b,
}
export enum E {
c = 3, d,
}
}
namespace Merged2 {
export enum E {
a, b, c
}
export module E {
export let d = 5;
}
}
var abc: First.E;
var secondAbc: Abc.E;
var secondAbcd: Abcd.E;
var secondAb: Ab.E;
var secondCd: Cd.E;
var nope: Abc.Nope;
var k: Const.E;
var decl: Decl.E;
var merged: Merged.E;
var merged2: Merged2.E;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
abc = secondCd; // missing 'd'
abc = nope; // nope!
abc = decl; // ok
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!
decl = abc; // ok
// const is only assignable to itself
k = k;
abc = k; // error
k = abc;
// merged enums compare all their members
abc = merged; // missing 'd'
merged = abc; // ok
abc = merged2; // ok
merged2 = abc; // ok
//// [enumAssignmentCompat3.js]
var First;
(function (First) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
E[E["c"] = 2] = "c";
})(First.E || (First.E = {}));
var E = First.E;
})(First || (First = {}));
var Abc;
(function (Abc) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
E[E["c"] = 2] = "c";
})(Abc.E || (Abc.E = {}));
var E = Abc.E;
(function (Nope) {
Nope[Nope["a"] = 0] = "a";
Nope[Nope["b"] = 1] = "b";
Nope[Nope["c"] = 2] = "c";
})(Abc.Nope || (Abc.Nope = {}));
var Nope = Abc.Nope;
})(Abc || (Abc = {}));
var Abcd;
(function (Abcd) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
E[E["c"] = 2] = "c";
E[E["d"] = 3] = "d";
})(Abcd.E || (Abcd.E = {}));
var E = Abcd.E;
})(Abcd || (Abcd = {}));
var Ab;
(function (Ab) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
})(Ab.E || (Ab.E = {}));
var E = Ab.E;
})(Ab || (Ab = {}));
var Cd;
(function (Cd) {
(function (E) {
E[E["c"] = 0] = "c";
E[E["d"] = 1] = "d";
})(Cd.E || (Cd.E = {}));
var E = Cd.E;
})(Cd || (Cd = {}));
var Decl;
(function (Decl) {
})(Decl || (Decl = {}));
var Merged;
(function (Merged) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
})(Merged.E || (Merged.E = {}));
var E = Merged.E;
(function (E) {
E[E["c"] = 3] = "c";
E[E["d"] = 4] = "d";
})(Merged.E || (Merged.E = {}));
var E = Merged.E;
})(Merged || (Merged = {}));
var Merged2;
(function (Merged2) {
(function (E) {
E[E["a"] = 0] = "a";
E[E["b"] = 1] = "b";
E[E["c"] = 2] = "c";
})(Merged2.E || (Merged2.E = {}));
var E = Merged2.E;
var E;
(function (E) {
E.d = 5;
})(E = Merged2.E || (Merged2.E = {}));
})(Merged2 || (Merged2 = {}));
var abc;
var secondAbc;
var secondAbcd;
var secondAb;
var secondCd;
var nope;
var k;
var decl;
var merged;
var merged2;
abc = secondAbc; // ok
abc = secondAbcd; // missing 'd'
abc = secondAb; // ok
abc = secondCd; // missing 'd'
abc = nope; // nope!
abc = decl; // ok
secondAbc = abc; // ok
secondAbcd = abc; // ok
secondAb = abc; // missing 'c'
secondCd = abc; // missing 'a' and 'b'
nope = abc; // nope!
decl = abc; // ok
// const is only assignable to itself
k = k;
abc = k; // error
k = abc;
// merged enums compare all their members
abc = merged; // missing 'd'
merged = abc; // ok
abc = merged2; // ok
merged2 = abc; // ok

View file

@ -1,12 +1,12 @@
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(4,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(9,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(14,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(18,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(22,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(26,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(9,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(14,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(18,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(26,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
@ -27,50 +27,50 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T
fn() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
//super call in class accessor (get and set) with no base type
get foo() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
return null;
}
set foo(v) {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
//super call in class member initializer with no base type
p = super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
//super call in static class member function with no base type
static fn() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
//super call in static class member initializer with no base type
static k = super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
//super call in static class accessor (get and set) with no base type
static get q() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
return null;
}
static set q(n) {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
}

View file

@ -15,8 +15,8 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
@ -34,8 +34,8 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts (38 errors) ====
@ -147,12 +147,12 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
function inner() {
super.publicFunc();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
var x = {
test: function () { return super.publicFunc(); }
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
}
}
@ -239,7 +239,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
// In object literal
var obj = { n: super.wat, p: super.foo() };
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.

View file

@ -15,7 +15,7 @@ export default class A
//// [es5-system.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var A;
return {

View file

@ -35,7 +35,7 @@ export let h1: D = new D;
//// [exportNonInitializedVariablesSystem.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var a, b, c, d, A, e, f, B, C, a1, b1, c1, d1, D, e1, f1, g1, h1;
return {

View file

@ -13,7 +13,7 @@ export * from "file1";
var x = 1;
//// [file0.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var v;
return {
@ -24,7 +24,7 @@ System.register([], function(exports_1) {
}
});
//// [file1.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
return {
setters:[],
@ -33,7 +33,7 @@ System.register([], function(exports_1) {
}
});
//// [file2.js]
System.register(["file0"], function(exports_1) {
System.register(["file0"], function(exports_1, __moduleName) {
"use strict";
var x;
function exportStar_1(m) {

View file

@ -9,7 +9,7 @@ export * from "file1"
export var x = 1;
//// [file1.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
return {
setters:[],
@ -18,7 +18,7 @@ System.register([], function(exports_1) {
}
});
//// [file2.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var x;
return {

View file

@ -9,7 +9,7 @@ export * from "file1"
var x = 1;
//// [file1.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
return {
setters:[],
@ -18,7 +18,7 @@ System.register([], function(exports_1) {
}
});
//// [file2.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var x;
return {

View file

@ -0,0 +1,10 @@
tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid01.ts(1,10): error TS2394: Overload signature is not compatible with function implementation.
==== tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid01.ts (1 errors) ====
function f(x: string): number;
~
!!! error TS2394: Overload signature is not compatible with function implementation.
function f(x: string): void {
return;
}

View file

@ -0,0 +1,10 @@
//// [functionOverloadCompatibilityWithVoid01.ts]
function f(x: string): number;
function f(x: string): void {
return;
}
//// [functionOverloadCompatibilityWithVoid01.js]
function f(x) {
return;
}

View file

@ -0,0 +1,10 @@
//// [functionOverloadCompatibilityWithVoid02.ts]
function f(x: string): void;
function f(x: string): number {
return 0;
}
//// [functionOverloadCompatibilityWithVoid02.js]
function f(x) {
return 0;
}

View file

@ -0,0 +1,11 @@
=== tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid02.ts ===
function f(x: string): void;
>f : Symbol(f, Decl(functionOverloadCompatibilityWithVoid02.ts, 0, 0), Decl(functionOverloadCompatibilityWithVoid02.ts, 0, 28))
>x : Symbol(x, Decl(functionOverloadCompatibilityWithVoid02.ts, 0, 11))
function f(x: string): number {
>f : Symbol(f, Decl(functionOverloadCompatibilityWithVoid02.ts, 0, 0), Decl(functionOverloadCompatibilityWithVoid02.ts, 0, 28))
>x : Symbol(x, Decl(functionOverloadCompatibilityWithVoid02.ts, 1, 11))
return 0;
}

View file

@ -0,0 +1,12 @@
=== tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid02.ts ===
function f(x: string): void;
>f : (x: string) => void
>x : string
function f(x: string): number {
>f : (x: string) => void
>x : string
return 0;
>0 : number
}

View file

@ -0,0 +1,10 @@
//// [functionOverloadCompatibilityWithVoid03.ts]
function f(x: string): void;
function f(x: string): void {
return;
}
//// [functionOverloadCompatibilityWithVoid03.js]
function f(x) {
return;
}

View file

@ -0,0 +1,11 @@
=== tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid03.ts ===
function f(x: string): void;
>f : Symbol(f, Decl(functionOverloadCompatibilityWithVoid03.ts, 0, 0), Decl(functionOverloadCompatibilityWithVoid03.ts, 0, 28))
>x : Symbol(x, Decl(functionOverloadCompatibilityWithVoid03.ts, 0, 11))
function f(x: string): void {
>f : Symbol(f, Decl(functionOverloadCompatibilityWithVoid03.ts, 0, 0), Decl(functionOverloadCompatibilityWithVoid03.ts, 0, 28))
>x : Symbol(x, Decl(functionOverloadCompatibilityWithVoid03.ts, 1, 11))
return;
}

View file

@ -0,0 +1,11 @@
=== tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid03.ts ===
function f(x: string): void;
>f : (x: string) => void
>x : string
function f(x: string): void {
>f : (x: string) => void
>x : string
return;
}

View file

@ -1,10 +0,0 @@
tests/cases/compiler/functionOverloads22.ts(2,10): error TS2394: Overload signature is not compatible with function implementation.
==== tests/cases/compiler/functionOverloads22.ts (1 errors) ====
function foo(bar:number):{a:number;}[];
function foo(bar:string):{a:number; b:string;}[];
~~~
!!! error TS2394: Overload signature is not compatible with function implementation.
function foo(bar:any):{a:any;b?:any;}[] { return [{a:""}] }

View file

@ -0,0 +1,19 @@
=== tests/cases/compiler/functionOverloads22.ts ===
function foo(bar:number):{a:number;}[];
>foo : Symbol(foo, Decl(functionOverloads22.ts, 0, 0), Decl(functionOverloads22.ts, 0, 39), Decl(functionOverloads22.ts, 1, 49))
>bar : Symbol(bar, Decl(functionOverloads22.ts, 0, 13))
>a : Symbol(a, Decl(functionOverloads22.ts, 0, 26))
function foo(bar:string):{a:number; b:string;}[];
>foo : Symbol(foo, Decl(functionOverloads22.ts, 0, 0), Decl(functionOverloads22.ts, 0, 39), Decl(functionOverloads22.ts, 1, 49))
>bar : Symbol(bar, Decl(functionOverloads22.ts, 1, 13))
>a : Symbol(a, Decl(functionOverloads22.ts, 1, 26))
>b : Symbol(b, Decl(functionOverloads22.ts, 1, 35))
function foo(bar:any):{a:any;b?:any;}[] { return [{a:""}] }
>foo : Symbol(foo, Decl(functionOverloads22.ts, 0, 0), Decl(functionOverloads22.ts, 0, 39), Decl(functionOverloads22.ts, 1, 49))
>bar : Symbol(bar, Decl(functionOverloads22.ts, 2, 13))
>a : Symbol(a, Decl(functionOverloads22.ts, 2, 23))
>b : Symbol(b, Decl(functionOverloads22.ts, 2, 29))
>a : Symbol(a, Decl(functionOverloads22.ts, 2, 51))

View file

@ -0,0 +1,22 @@
=== tests/cases/compiler/functionOverloads22.ts ===
function foo(bar:number):{a:number;}[];
>foo : { (bar: number): { a: number; }[]; (bar: string): { a: number; b: string; }[]; }
>bar : number
>a : number
function foo(bar:string):{a:number; b:string;}[];
>foo : { (bar: number): { a: number; }[]; (bar: string): { a: number; b: string; }[]; }
>bar : string
>a : number
>b : string
function foo(bar:any):{a:any;b?:any;}[] { return [{a:""}] }
>foo : { (bar: number): { a: number; }[]; (bar: string): { a: number; b: string; }[]; }
>bar : any
>a : any
>b : any
>[{a:""}] : { a: string; }[]
>{a:""} : { a: string; }
>a : string
>"" : string

View file

@ -0,0 +1,24 @@
//// [functionOverloads43.ts]
function foo(bar: { a:number }[]): number;
function foo(bar: { a:string }[]): string;
function foo([x]: { a:number | string }[]): string | number {
if (x) {
return x.a;
}
return undefined;
}
var x = foo([{a: "str"}]);
var y = foo([{a: 100}]);
//// [functionOverloads43.js]
function foo(_a) {
var x = _a[0];
if (x) {
return x.a;
}
return undefined;
}
var x = foo([{ a: "str" }]);
var y = foo([{ a: 100 }]);

View file

@ -0,0 +1,39 @@
=== tests/cases/compiler/functionOverloads43.ts ===
function foo(bar: { a:number }[]): number;
>foo : Symbol(foo, Decl(functionOverloads43.ts, 0, 0), Decl(functionOverloads43.ts, 0, 42), Decl(functionOverloads43.ts, 1, 42))
>bar : Symbol(bar, Decl(functionOverloads43.ts, 0, 13))
>a : Symbol(a, Decl(functionOverloads43.ts, 0, 19))
function foo(bar: { a:string }[]): string;
>foo : Symbol(foo, Decl(functionOverloads43.ts, 0, 0), Decl(functionOverloads43.ts, 0, 42), Decl(functionOverloads43.ts, 1, 42))
>bar : Symbol(bar, Decl(functionOverloads43.ts, 1, 13))
>a : Symbol(a, Decl(functionOverloads43.ts, 1, 19))
function foo([x]: { a:number | string }[]): string | number {
>foo : Symbol(foo, Decl(functionOverloads43.ts, 0, 0), Decl(functionOverloads43.ts, 0, 42), Decl(functionOverloads43.ts, 1, 42))
>x : Symbol(x, Decl(functionOverloads43.ts, 2, 14))
>a : Symbol(a, Decl(functionOverloads43.ts, 2, 19))
if (x) {
>x : Symbol(x, Decl(functionOverloads43.ts, 2, 14))
return x.a;
>x.a : Symbol(a, Decl(functionOverloads43.ts, 2, 19))
>x : Symbol(x, Decl(functionOverloads43.ts, 2, 14))
>a : Symbol(a, Decl(functionOverloads43.ts, 2, 19))
}
return undefined;
>undefined : Symbol(undefined)
}
var x = foo([{a: "str"}]);
>x : Symbol(x, Decl(functionOverloads43.ts, 10, 3))
>foo : Symbol(foo, Decl(functionOverloads43.ts, 0, 0), Decl(functionOverloads43.ts, 0, 42), Decl(functionOverloads43.ts, 1, 42))
>a : Symbol(a, Decl(functionOverloads43.ts, 10, 14))
var y = foo([{a: 100}]);
>y : Symbol(y, Decl(functionOverloads43.ts, 11, 3))
>foo : Symbol(foo, Decl(functionOverloads43.ts, 0, 0), Decl(functionOverloads43.ts, 0, 42), Decl(functionOverloads43.ts, 1, 42))
>a : Symbol(a, Decl(functionOverloads43.ts, 11, 14))

View file

@ -0,0 +1,47 @@
=== tests/cases/compiler/functionOverloads43.ts ===
function foo(bar: { a:number }[]): number;
>foo : { (bar: { a: number; }[]): number; (bar: { a: string; }[]): string; }
>bar : { a: number; }[]
>a : number
function foo(bar: { a:string }[]): string;
>foo : { (bar: { a: number; }[]): number; (bar: { a: string; }[]): string; }
>bar : { a: string; }[]
>a : string
function foo([x]: { a:number | string }[]): string | number {
>foo : { (bar: { a: number; }[]): number; (bar: { a: string; }[]): string; }
>x : { a: number | string; }
>a : number | string
if (x) {
>x : { a: number | string; }
return x.a;
>x.a : number | string
>x : { a: number | string; }
>a : number | string
}
return undefined;
>undefined : undefined
}
var x = foo([{a: "str"}]);
>x : string
>foo([{a: "str"}]) : string
>foo : { (bar: { a: number; }[]): number; (bar: { a: string; }[]): string; }
>[{a: "str"}] : { a: string; }[]
>{a: "str"} : { a: string; }
>a : string
>"str" : string
var y = foo([{a: 100}]);
>y : number
>foo([{a: 100}]) : number
>foo : { (bar: { a: number; }[]): number; (bar: { a: string; }[]): string; }
>[{a: 100}] : { a: number; }[]
>{a: 100} : { a: number; }
>a : number
>100 : number

View file

@ -0,0 +1,37 @@
//// [functionOverloads44.ts]
interface Animal { animal }
interface Dog extends Animal { dog }
interface Cat extends Animal { cat }
function foo1(bar: { a:number }[]): Dog;
function foo1(bar: { a:string }[]): Animal;
function foo1([x]: { a:number | string }[]): Dog {
return undefined;
}
function foo2(bar: { a:number }[]): Cat;
function foo2(bar: { a:string }[]): Cat | Dog;
function foo2([x]: { a:number | string }[]): Cat {
return undefined;
}
var x1 = foo1([{a: "str"}]);
var y1 = foo1([{a: 100}]);
var x2 = foo2([{a: "str"}]);
var y2 = foo2([{a: 100}]);
//// [functionOverloads44.js]
function foo1(_a) {
var x = _a[0];
return undefined;
}
function foo2(_a) {
var x = _a[0];
return undefined;
}
var x1 = foo1([{ a: "str" }]);
var y1 = foo1([{ a: 100 }]);
var x2 = foo2([{ a: "str" }]);
var y2 = foo2([{ a: 100 }]);

View file

@ -0,0 +1,81 @@
=== tests/cases/compiler/functionOverloads44.ts ===
interface Animal { animal }
>Animal : Symbol(Animal, Decl(functionOverloads44.ts, 0, 0))
>animal : Symbol(animal, Decl(functionOverloads44.ts, 0, 18))
interface Dog extends Animal { dog }
>Dog : Symbol(Dog, Decl(functionOverloads44.ts, 0, 27))
>Animal : Symbol(Animal, Decl(functionOverloads44.ts, 0, 0))
>dog : Symbol(dog, Decl(functionOverloads44.ts, 1, 30))
interface Cat extends Animal { cat }
>Cat : Symbol(Cat, Decl(functionOverloads44.ts, 1, 36))
>Animal : Symbol(Animal, Decl(functionOverloads44.ts, 0, 0))
>cat : Symbol(cat, Decl(functionOverloads44.ts, 2, 30))
function foo1(bar: { a:number }[]): Dog;
>foo1 : Symbol(foo1, Decl(functionOverloads44.ts, 2, 36), Decl(functionOverloads44.ts, 4, 40), Decl(functionOverloads44.ts, 5, 43))
>bar : Symbol(bar, Decl(functionOverloads44.ts, 4, 14))
>a : Symbol(a, Decl(functionOverloads44.ts, 4, 20))
>Dog : Symbol(Dog, Decl(functionOverloads44.ts, 0, 27))
function foo1(bar: { a:string }[]): Animal;
>foo1 : Symbol(foo1, Decl(functionOverloads44.ts, 2, 36), Decl(functionOverloads44.ts, 4, 40), Decl(functionOverloads44.ts, 5, 43))
>bar : Symbol(bar, Decl(functionOverloads44.ts, 5, 14))
>a : Symbol(a, Decl(functionOverloads44.ts, 5, 20))
>Animal : Symbol(Animal, Decl(functionOverloads44.ts, 0, 0))
function foo1([x]: { a:number | string }[]): Dog {
>foo1 : Symbol(foo1, Decl(functionOverloads44.ts, 2, 36), Decl(functionOverloads44.ts, 4, 40), Decl(functionOverloads44.ts, 5, 43))
>x : Symbol(x, Decl(functionOverloads44.ts, 6, 15))
>a : Symbol(a, Decl(functionOverloads44.ts, 6, 20))
>Dog : Symbol(Dog, Decl(functionOverloads44.ts, 0, 27))
return undefined;
>undefined : Symbol(undefined)
}
function foo2(bar: { a:number }[]): Cat;
>foo2 : Symbol(foo2, Decl(functionOverloads44.ts, 8, 1), Decl(functionOverloads44.ts, 10, 40), Decl(functionOverloads44.ts, 11, 46))
>bar : Symbol(bar, Decl(functionOverloads44.ts, 10, 14))
>a : Symbol(a, Decl(functionOverloads44.ts, 10, 20))
>Cat : Symbol(Cat, Decl(functionOverloads44.ts, 1, 36))
function foo2(bar: { a:string }[]): Cat | Dog;
>foo2 : Symbol(foo2, Decl(functionOverloads44.ts, 8, 1), Decl(functionOverloads44.ts, 10, 40), Decl(functionOverloads44.ts, 11, 46))
>bar : Symbol(bar, Decl(functionOverloads44.ts, 11, 14))
>a : Symbol(a, Decl(functionOverloads44.ts, 11, 20))
>Cat : Symbol(Cat, Decl(functionOverloads44.ts, 1, 36))
>Dog : Symbol(Dog, Decl(functionOverloads44.ts, 0, 27))
function foo2([x]: { a:number | string }[]): Cat {
>foo2 : Symbol(foo2, Decl(functionOverloads44.ts, 8, 1), Decl(functionOverloads44.ts, 10, 40), Decl(functionOverloads44.ts, 11, 46))
>x : Symbol(x, Decl(functionOverloads44.ts, 12, 15))
>a : Symbol(a, Decl(functionOverloads44.ts, 12, 20))
>Cat : Symbol(Cat, Decl(functionOverloads44.ts, 1, 36))
return undefined;
>undefined : Symbol(undefined)
}
var x1 = foo1([{a: "str"}]);
>x1 : Symbol(x1, Decl(functionOverloads44.ts, 17, 3))
>foo1 : Symbol(foo1, Decl(functionOverloads44.ts, 2, 36), Decl(functionOverloads44.ts, 4, 40), Decl(functionOverloads44.ts, 5, 43))
>a : Symbol(a, Decl(functionOverloads44.ts, 17, 16))
var y1 = foo1([{a: 100}]);
>y1 : Symbol(y1, Decl(functionOverloads44.ts, 18, 3))
>foo1 : Symbol(foo1, Decl(functionOverloads44.ts, 2, 36), Decl(functionOverloads44.ts, 4, 40), Decl(functionOverloads44.ts, 5, 43))
>a : Symbol(a, Decl(functionOverloads44.ts, 18, 16))
var x2 = foo2([{a: "str"}]);
>x2 : Symbol(x2, Decl(functionOverloads44.ts, 20, 3))
>foo2 : Symbol(foo2, Decl(functionOverloads44.ts, 8, 1), Decl(functionOverloads44.ts, 10, 40), Decl(functionOverloads44.ts, 11, 46))
>a : Symbol(a, Decl(functionOverloads44.ts, 20, 16))
var y2 = foo2([{a: 100}]);
>y2 : Symbol(y2, Decl(functionOverloads44.ts, 21, 3))
>foo2 : Symbol(foo2, Decl(functionOverloads44.ts, 8, 1), Decl(functionOverloads44.ts, 10, 40), Decl(functionOverloads44.ts, 11, 46))
>a : Symbol(a, Decl(functionOverloads44.ts, 21, 16))

View file

@ -0,0 +1,97 @@
=== tests/cases/compiler/functionOverloads44.ts ===
interface Animal { animal }
>Animal : Animal
>animal : any
interface Dog extends Animal { dog }
>Dog : Dog
>Animal : Animal
>dog : any
interface Cat extends Animal { cat }
>Cat : Cat
>Animal : Animal
>cat : any
function foo1(bar: { a:number }[]): Dog;
>foo1 : { (bar: { a: number; }[]): Dog; (bar: { a: string; }[]): Animal; }
>bar : { a: number; }[]
>a : number
>Dog : Dog
function foo1(bar: { a:string }[]): Animal;
>foo1 : { (bar: { a: number; }[]): Dog; (bar: { a: string; }[]): Animal; }
>bar : { a: string; }[]
>a : string
>Animal : Animal
function foo1([x]: { a:number | string }[]): Dog {
>foo1 : { (bar: { a: number; }[]): Dog; (bar: { a: string; }[]): Animal; }
>x : { a: number | string; }
>a : number | string
>Dog : Dog
return undefined;
>undefined : undefined
}
function foo2(bar: { a:number }[]): Cat;
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Cat | Dog; }
>bar : { a: number; }[]
>a : number
>Cat : Cat
function foo2(bar: { a:string }[]): Cat | Dog;
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Cat | Dog; }
>bar : { a: string; }[]
>a : string
>Cat : Cat
>Dog : Dog
function foo2([x]: { a:number | string }[]): Cat {
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Cat | Dog; }
>x : { a: number | string; }
>a : number | string
>Cat : Cat
return undefined;
>undefined : undefined
}
var x1 = foo1([{a: "str"}]);
>x1 : Animal
>foo1([{a: "str"}]) : Animal
>foo1 : { (bar: { a: number; }[]): Dog; (bar: { a: string; }[]): Animal; }
>[{a: "str"}] : { a: string; }[]
>{a: "str"} : { a: string; }
>a : string
>"str" : string
var y1 = foo1([{a: 100}]);
>y1 : Dog
>foo1([{a: 100}]) : Dog
>foo1 : { (bar: { a: number; }[]): Dog; (bar: { a: string; }[]): Animal; }
>[{a: 100}] : { a: number; }[]
>{a: 100} : { a: number; }
>a : number
>100 : number
var x2 = foo2([{a: "str"}]);
>x2 : Cat | Dog
>foo2([{a: "str"}]) : Cat | Dog
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Cat | Dog; }
>[{a: "str"}] : { a: string; }[]
>{a: "str"} : { a: string; }
>a : string
>"str" : string
var y2 = foo2([{a: 100}]);
>y2 : Cat
>foo2([{a: 100}]) : Cat
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Cat | Dog; }
>[{a: 100}] : { a: number; }[]
>{a: 100} : { a: number; }
>a : number
>100 : number

View file

@ -0,0 +1,37 @@
//// [functionOverloads45.ts]
interface Animal { animal }
interface Dog extends Animal { dog }
interface Cat extends Animal { cat }
function foo1(bar: { a:number }[]): Cat;
function foo1(bar: { a:string }[]): Dog;
function foo1([x]: { a:number | string }[]): Animal {
return undefined;
}
function foo2(bar: { a:number }[]): Cat;
function foo2(bar: { a:string }[]): Dog;
function foo2([x]: { a:number | string }[]): Cat | Dog {
return undefined;
}
var x1 = foo1([{a: "str"}]);
var y1 = foo1([{a: 100}]);
var x2 = foo2([{a: "str"}]);
var y2 = foo2([{a: 100}]);
//// [functionOverloads45.js]
function foo1(_a) {
var x = _a[0];
return undefined;
}
function foo2(_a) {
var x = _a[0];
return undefined;
}
var x1 = foo1([{ a: "str" }]);
var y1 = foo1([{ a: 100 }]);
var x2 = foo2([{ a: "str" }]);
var y2 = foo2([{ a: 100 }]);

View file

@ -0,0 +1,81 @@
=== tests/cases/compiler/functionOverloads45.ts ===
interface Animal { animal }
>Animal : Symbol(Animal, Decl(functionOverloads45.ts, 0, 0))
>animal : Symbol(animal, Decl(functionOverloads45.ts, 0, 18))
interface Dog extends Animal { dog }
>Dog : Symbol(Dog, Decl(functionOverloads45.ts, 0, 27))
>Animal : Symbol(Animal, Decl(functionOverloads45.ts, 0, 0))
>dog : Symbol(dog, Decl(functionOverloads45.ts, 1, 30))
interface Cat extends Animal { cat }
>Cat : Symbol(Cat, Decl(functionOverloads45.ts, 1, 36))
>Animal : Symbol(Animal, Decl(functionOverloads45.ts, 0, 0))
>cat : Symbol(cat, Decl(functionOverloads45.ts, 2, 30))
function foo1(bar: { a:number }[]): Cat;
>foo1 : Symbol(foo1, Decl(functionOverloads45.ts, 2, 36), Decl(functionOverloads45.ts, 4, 40), Decl(functionOverloads45.ts, 5, 40))
>bar : Symbol(bar, Decl(functionOverloads45.ts, 4, 14))
>a : Symbol(a, Decl(functionOverloads45.ts, 4, 20))
>Cat : Symbol(Cat, Decl(functionOverloads45.ts, 1, 36))
function foo1(bar: { a:string }[]): Dog;
>foo1 : Symbol(foo1, Decl(functionOverloads45.ts, 2, 36), Decl(functionOverloads45.ts, 4, 40), Decl(functionOverloads45.ts, 5, 40))
>bar : Symbol(bar, Decl(functionOverloads45.ts, 5, 14))
>a : Symbol(a, Decl(functionOverloads45.ts, 5, 20))
>Dog : Symbol(Dog, Decl(functionOverloads45.ts, 0, 27))
function foo1([x]: { a:number | string }[]): Animal {
>foo1 : Symbol(foo1, Decl(functionOverloads45.ts, 2, 36), Decl(functionOverloads45.ts, 4, 40), Decl(functionOverloads45.ts, 5, 40))
>x : Symbol(x, Decl(functionOverloads45.ts, 6, 15))
>a : Symbol(a, Decl(functionOverloads45.ts, 6, 20))
>Animal : Symbol(Animal, Decl(functionOverloads45.ts, 0, 0))
return undefined;
>undefined : Symbol(undefined)
}
function foo2(bar: { a:number }[]): Cat;
>foo2 : Symbol(foo2, Decl(functionOverloads45.ts, 8, 1), Decl(functionOverloads45.ts, 10, 40), Decl(functionOverloads45.ts, 11, 40))
>bar : Symbol(bar, Decl(functionOverloads45.ts, 10, 14))
>a : Symbol(a, Decl(functionOverloads45.ts, 10, 20))
>Cat : Symbol(Cat, Decl(functionOverloads45.ts, 1, 36))
function foo2(bar: { a:string }[]): Dog;
>foo2 : Symbol(foo2, Decl(functionOverloads45.ts, 8, 1), Decl(functionOverloads45.ts, 10, 40), Decl(functionOverloads45.ts, 11, 40))
>bar : Symbol(bar, Decl(functionOverloads45.ts, 11, 14))
>a : Symbol(a, Decl(functionOverloads45.ts, 11, 20))
>Dog : Symbol(Dog, Decl(functionOverloads45.ts, 0, 27))
function foo2([x]: { a:number | string }[]): Cat | Dog {
>foo2 : Symbol(foo2, Decl(functionOverloads45.ts, 8, 1), Decl(functionOverloads45.ts, 10, 40), Decl(functionOverloads45.ts, 11, 40))
>x : Symbol(x, Decl(functionOverloads45.ts, 12, 15))
>a : Symbol(a, Decl(functionOverloads45.ts, 12, 20))
>Cat : Symbol(Cat, Decl(functionOverloads45.ts, 1, 36))
>Dog : Symbol(Dog, Decl(functionOverloads45.ts, 0, 27))
return undefined;
>undefined : Symbol(undefined)
}
var x1 = foo1([{a: "str"}]);
>x1 : Symbol(x1, Decl(functionOverloads45.ts, 17, 3))
>foo1 : Symbol(foo1, Decl(functionOverloads45.ts, 2, 36), Decl(functionOverloads45.ts, 4, 40), Decl(functionOverloads45.ts, 5, 40))
>a : Symbol(a, Decl(functionOverloads45.ts, 17, 16))
var y1 = foo1([{a: 100}]);
>y1 : Symbol(y1, Decl(functionOverloads45.ts, 18, 3))
>foo1 : Symbol(foo1, Decl(functionOverloads45.ts, 2, 36), Decl(functionOverloads45.ts, 4, 40), Decl(functionOverloads45.ts, 5, 40))
>a : Symbol(a, Decl(functionOverloads45.ts, 18, 16))
var x2 = foo2([{a: "str"}]);
>x2 : Symbol(x2, Decl(functionOverloads45.ts, 20, 3))
>foo2 : Symbol(foo2, Decl(functionOverloads45.ts, 8, 1), Decl(functionOverloads45.ts, 10, 40), Decl(functionOverloads45.ts, 11, 40))
>a : Symbol(a, Decl(functionOverloads45.ts, 20, 16))
var y2 = foo2([{a: 100}]);
>y2 : Symbol(y2, Decl(functionOverloads45.ts, 21, 3))
>foo2 : Symbol(foo2, Decl(functionOverloads45.ts, 8, 1), Decl(functionOverloads45.ts, 10, 40), Decl(functionOverloads45.ts, 11, 40))
>a : Symbol(a, Decl(functionOverloads45.ts, 21, 16))

View file

@ -0,0 +1,97 @@
=== tests/cases/compiler/functionOverloads45.ts ===
interface Animal { animal }
>Animal : Animal
>animal : any
interface Dog extends Animal { dog }
>Dog : Dog
>Animal : Animal
>dog : any
interface Cat extends Animal { cat }
>Cat : Cat
>Animal : Animal
>cat : any
function foo1(bar: { a:number }[]): Cat;
>foo1 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>bar : { a: number; }[]
>a : number
>Cat : Cat
function foo1(bar: { a:string }[]): Dog;
>foo1 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>bar : { a: string; }[]
>a : string
>Dog : Dog
function foo1([x]: { a:number | string }[]): Animal {
>foo1 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>x : { a: number | string; }
>a : number | string
>Animal : Animal
return undefined;
>undefined : undefined
}
function foo2(bar: { a:number }[]): Cat;
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>bar : { a: number; }[]
>a : number
>Cat : Cat
function foo2(bar: { a:string }[]): Dog;
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>bar : { a: string; }[]
>a : string
>Dog : Dog
function foo2([x]: { a:number | string }[]): Cat | Dog {
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>x : { a: number | string; }
>a : number | string
>Cat : Cat
>Dog : Dog
return undefined;
>undefined : undefined
}
var x1 = foo1([{a: "str"}]);
>x1 : Dog
>foo1([{a: "str"}]) : Dog
>foo1 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>[{a: "str"}] : { a: string; }[]
>{a: "str"} : { a: string; }
>a : string
>"str" : string
var y1 = foo1([{a: 100}]);
>y1 : Cat
>foo1([{a: 100}]) : Cat
>foo1 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>[{a: 100}] : { a: number; }[]
>{a: 100} : { a: number; }
>a : number
>100 : number
var x2 = foo2([{a: "str"}]);
>x2 : Dog
>foo2([{a: "str"}]) : Dog
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>[{a: "str"}] : { a: string; }[]
>{a: "str"} : { a: string; }
>a : string
>"str" : string
var y2 = foo2([{a: 100}]);
>y2 : Cat
>foo2([{a: 100}]) : Cat
>foo2 : { (bar: { a: number; }[]): Cat; (bar: { a: string; }[]): Dog; }
>[{a: 100}] : { a: number; }[]
>{a: 100} : { a: number; }
>a : number
>100 : number

View file

@ -5,7 +5,7 @@ run(1);
//// [isolatedModulesPlainFile-System.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
return {
setters:[],

View file

@ -4,7 +4,7 @@
export class Foo {}
//// [modulePrologueSystem.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, __moduleName) {
"use strict";
var Foo;
return {

View file

@ -1,20 +1,11 @@
tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(1,1): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(1,18): error TS2304: Cannot find name 'role'.
tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(2,18): error TS2304: Cannot find name 'Role'.
tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts(4,26): error TS2503: Cannot find namespace 'ng'.
==== tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts (4 errors) ====
==== tests/cases/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.ts (1 errors) ====
return this.edit(role)
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.
~~~~
!!! error TS2304: Cannot find name 'role'.
.then((role: Role) =>
~~~~
!!! error TS2304: Cannot find name 'Role'.
this.roleService.add(role)
.then((data: ng.IHttpPromiseCallbackArg<Role>) => data.data));
~~
!!! error TS2503: Cannot find namespace 'ng'.

View file

@ -6,9 +6,8 @@ return this.edit(role)
//// [multiLinePropertyAccessAndArrowFunctionIndent1.js]
var _this = this;
return this.edit(role)
.then(function (role) {
return _this.roleService.add(role)
return this.roleService.add(role)
.then(function (data) { return data.data; });
});

Some files were not shown because too many files have changed in this diff Show more