mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
Merge branch 'master' into refactorSignatureRelatability
This commit is contained in:
commit
bae09d5d96
@ -924,7 +924,8 @@ function lintFileAsync(options, path, cb) {
|
||||
var lintTargets = compilerSources
|
||||
.concat(harnessCoreSources)
|
||||
.concat(serverCoreSources)
|
||||
.concat(scriptSources);
|
||||
.concat(scriptSources)
|
||||
.concat([path.join(servicesDirectory, "services.ts")]);
|
||||
|
||||
desc("Runs tslint on the compiler sources");
|
||||
task("lint", ["build-rules"], function() {
|
||||
|
||||
Binary file not shown.
BIN
doc/images/image1.png
Normal file
BIN
doc/images/image1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
doc/images/image2.png
Normal file
BIN
doc/images/image2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
doc/images/image3.png
Normal file
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
BIN
doc/images/image4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@ -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.
|
||||
|
||||
/
|
||||
  
|
||||
|
||||
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.
|
||||
|
||||
/
|
||||
  
|
||||
|
||||
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.
|
||||
|
||||
/
|
||||
  
|
||||
|
||||
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.
|
||||
|
||||
/
|
||||
  
|
||||
|
||||
Section [3.9.2.4](#3.9.2.4) provides details on how to use string literals in function signatures.
|
||||
|
||||
|
||||
@ -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("  " + text.replace(/\s\s\s/g, " ").replace(/\x0B/g, " \n   ") + "\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("<", {}, "<", {});
|
||||
findReplace("<", { style: "Code" }, "<", {});
|
||||
findReplace("<", { style: "Code Fragment" }, "<", {});
|
||||
findReplace("<", { 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
|
||||
@ -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 = "  " + 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) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -67,6 +67,7 @@ namespace ts {
|
||||
// The language service will always care about the narrowed type of a symbol, because that is
|
||||
// the type the language says the symbol should have.
|
||||
getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol,
|
||||
getSymbolsOfParameterPropertyDeclaration,
|
||||
getDeclaredTypeOfSymbol,
|
||||
getPropertiesOfType,
|
||||
getPropertyOfType,
|
||||
@ -430,6 +431,26 @@ namespace ts {
|
||||
// return undefined if we can't find a symbol.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get symbols that represent parameter-property-declaration as parameter and as property declaration
|
||||
* @param parameter a parameterDeclaration node
|
||||
* @param parameterName a name of the parameter to get the symbols for.
|
||||
* @return a tuple of two symbols
|
||||
*/
|
||||
function getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): [Symbol, Symbol] {
|
||||
const constructoDeclaration = parameter.parent;
|
||||
const classDeclaration = parameter.parent.parent;
|
||||
|
||||
const parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, SymbolFlags.Value);
|
||||
const propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, SymbolFlags.Value);
|
||||
|
||||
if (parameterSymbol && propertySymbol) {
|
||||
return [parameterSymbol, propertySymbol];
|
||||
}
|
||||
|
||||
Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration");
|
||||
}
|
||||
|
||||
function isBlockScopedNameDeclaredBeforeUse(declaration: Declaration, usage: Node): boolean {
|
||||
const declarationFile = getSourceFileOfNode(declaration);
|
||||
const useFile = getSourceFileOfNode(usage);
|
||||
@ -819,15 +840,6 @@ namespace ts {
|
||||
return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier);
|
||||
}
|
||||
|
||||
function getMemberOfModuleVariable(moduleSymbol: Symbol, name: string): Symbol {
|
||||
if (moduleSymbol.flags & SymbolFlags.Variable) {
|
||||
const typeAnnotation = (<VariableDeclaration>moduleSymbol.valueDeclaration).type;
|
||||
if (typeAnnotation) {
|
||||
return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This function creates a synthetic symbol that combines the value side of one symbol with the
|
||||
// type/namespace side of another symbol. Consider this example:
|
||||
//
|
||||
@ -1063,7 +1075,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
const moduleReferenceLiteral = <LiteralExpression>moduleReferenceExpression;
|
||||
const searchPath = getDirectoryPath(getSourceFile(location).fileName);
|
||||
|
||||
// Module names are escaped in our symbol table. However, string literal values aren't.
|
||||
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
|
||||
@ -2183,65 +2194,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isDeclarationVisible(node: Declaration): boolean {
|
||||
function getContainingExternalModule(node: Node) {
|
||||
for (; node; node = node.parent) {
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration) {
|
||||
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.SourceFile) {
|
||||
return isExternalOrCommonJsModule(<SourceFile>node) ? node : undefined;
|
||||
}
|
||||
if (node) {
|
||||
const links = getNodeLinks(node);
|
||||
if (links.isVisible === undefined) {
|
||||
links.isVisible = !!determineIfDeclarationIsVisible();
|
||||
}
|
||||
Debug.fail("getContainingModule cant reach here");
|
||||
return links.isVisible;
|
||||
}
|
||||
|
||||
function isUsedInExportAssignment(node: Node) {
|
||||
// Get source File and see if it is external module and has export assigned symbol
|
||||
const externalModule = getContainingExternalModule(node);
|
||||
let exportAssignmentSymbol: Symbol;
|
||||
let resolvedExportSymbol: Symbol;
|
||||
if (externalModule) {
|
||||
// This is export assigned symbol node
|
||||
const externalModuleSymbol = getSymbolOfNode(externalModule);
|
||||
exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol);
|
||||
const symbolOfNode = getSymbolOfNode(node);
|
||||
if (isSymbolUsedInExportAssignment(symbolOfNode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if symbolOfNode is alias declaration, resolve the symbol declaration and check
|
||||
if (symbolOfNode.flags & SymbolFlags.Alias) {
|
||||
return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode));
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the symbol is used in export assignment
|
||||
function isSymbolUsedInExportAssignment(symbol: Symbol) {
|
||||
if (exportAssignmentSymbol === symbol) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & SymbolFlags.Alias)) {
|
||||
// if export assigned symbol is alias declaration, resolve the alias
|
||||
resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol);
|
||||
if (resolvedExportSymbol === symbol) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Container of resolvedExportSymbol is visible
|
||||
return forEach(resolvedExportSymbol.declarations, (current: Node) => {
|
||||
while (current) {
|
||||
if (current === node) {
|
||||
return true;
|
||||
}
|
||||
current = current.parent;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
function determineIfDeclarationIsVisible() {
|
||||
switch (node.kind) {
|
||||
@ -2320,14 +2281,6 @@ namespace ts {
|
||||
Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
|
||||
}
|
||||
}
|
||||
|
||||
if (node) {
|
||||
const links = getNodeLinks(node);
|
||||
if (links.isVisible === undefined) {
|
||||
links.isVisible = !!determineIfDeclarationIsVisible();
|
||||
}
|
||||
return links.isVisible;
|
||||
}
|
||||
}
|
||||
|
||||
function collectLinkedAliases(node: Identifier): Node[] {
|
||||
@ -3373,14 +3326,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function addInheritedSignatures(signatures: Signature[], baseSignatures: Signature[]) {
|
||||
if (baseSignatures) {
|
||||
for (const signature of baseSignatures) {
|
||||
signatures.push(signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers {
|
||||
if (!(<InterfaceTypeWithDeclaredMembers>type).declaredProperties) {
|
||||
const symbol = type.symbol;
|
||||
@ -3768,11 +3713,14 @@ namespace ts {
|
||||
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol {
|
||||
const types = containingType.types;
|
||||
let props: Symbol[];
|
||||
// Flags we want to propagate to the result if they exist in all source symbols
|
||||
let commonFlags = (containingType.flags & TypeFlags.Intersection) ? SymbolFlags.Optional : SymbolFlags.None;
|
||||
for (const current of types) {
|
||||
const type = getApparentType(current);
|
||||
if (type !== unknownType) {
|
||||
const prop = getPropertyOfType(type, name);
|
||||
if (prop && !(getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected))) {
|
||||
commonFlags &= prop.flags;
|
||||
if (!props) {
|
||||
props = [prop];
|
||||
}
|
||||
@ -3800,7 +3748,12 @@ namespace ts {
|
||||
}
|
||||
propTypes.push(getTypeOfSymbol(prop));
|
||||
}
|
||||
const result = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.SyntheticProperty, name);
|
||||
const result = <TransientSymbol>createSymbol(
|
||||
SymbolFlags.Property |
|
||||
SymbolFlags.Transient |
|
||||
SymbolFlags.SyntheticProperty |
|
||||
commonFlags,
|
||||
name);
|
||||
result.containingType = containingType;
|
||||
result.declarations = declarations;
|
||||
result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
||||
@ -3861,25 +3814,6 @@ namespace ts {
|
||||
function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] {
|
||||
return getSignaturesOfStructuredType(getApparentType(type), kind);
|
||||
}
|
||||
|
||||
function typeHasConstructSignatures(type: Type): boolean {
|
||||
const apparentType = getApparentType(type);
|
||||
if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) {
|
||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
||||
return resolved.constructSignatures.length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function typeHasCallOrConstructSignatures(type: Type): boolean {
|
||||
const apparentType = getApparentType(type);
|
||||
if (apparentType.flags & TypeFlags.StructuredType) {
|
||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
||||
return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type {
|
||||
if (type.flags & TypeFlags.StructuredType) {
|
||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
||||
@ -4381,10 +4315,6 @@ namespace ts {
|
||||
return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity);
|
||||
}
|
||||
|
||||
function tryGetGlobalType(name: string, arity = 0): ObjectType {
|
||||
return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a type that is inside a namespace at the global scope, e.g.
|
||||
* getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type
|
||||
@ -5646,32 +5576,24 @@ namespace ts {
|
||||
if (target === anyFunctionType || source === anyFunctionType) {
|
||||
return Ternary.True;
|
||||
}
|
||||
|
||||
const sourceSignatures = getSignaturesOfType(source, kind);
|
||||
const targetSignatures = getSignaturesOfType(target, kind);
|
||||
if (kind === SignatureKind.Construct && sourceSignatures.length && targetSignatures.length &&
|
||||
isAbstractConstructorType(source) && !isAbstractConstructorType(target)) {
|
||||
// An abstract constructor type is not assignable to a non-abstract constructor type
|
||||
// as it would otherwise be possible to new an abstract class. Note that the assignablity
|
||||
// check we perform for an extends clause excludes construct signatures from the target,
|
||||
// so this check never proceeds.
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
|
||||
let result = Ternary.True;
|
||||
const saveErrorInfo = errorInfo;
|
||||
|
||||
|
||||
|
||||
if (kind === SignatureKind.Construct) {
|
||||
// Only want to compare the construct signatures for abstractness guarantees.
|
||||
|
||||
// Because the "abstractness" of a class is the same across all construct signatures
|
||||
// (internally we are checking the corresponding declaration), it is enough to perform
|
||||
// the check and report an error once over all pairs of source and target construct signatures.
|
||||
//
|
||||
// sourceSig and targetSig are (possibly) undefined.
|
||||
//
|
||||
// Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds.
|
||||
const sourceSig = sourceSignatures[0];
|
||||
const targetSig = targetSignatures[0];
|
||||
|
||||
result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig);
|
||||
if (result !== Ternary.True) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
outer: for (const t of targetSignatures) {
|
||||
if (!t.hasStringLiterals || target.flags & TypeFlags.FromSignature) {
|
||||
// Only elaborate errors from the first failure
|
||||
@ -5698,40 +5620,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
function abstractSignatureRelatedTo(source: Type, sourceSig: Signature, target: Type, targetSig: Signature) {
|
||||
if (sourceSig && targetSig) {
|
||||
|
||||
const sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
|
||||
const targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
|
||||
|
||||
if (!sourceDecl) {
|
||||
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
|
||||
// of whether the constructed object is abstract or not.
|
||||
return Ternary.True;
|
||||
}
|
||||
|
||||
const sourceErasedSignature = getErasedSignature(sourceSig);
|
||||
const targetErasedSignature = getErasedSignature(targetSig);
|
||||
|
||||
const sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
|
||||
const targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
|
||||
|
||||
const sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
|
||||
const targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
|
||||
const sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract;
|
||||
const targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract;
|
||||
|
||||
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
|
||||
// if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment.
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
}
|
||||
return Ternary.True;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5860,6 +5748,20 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if the given type is the constructor type for an abstract class
|
||||
function isAbstractConstructorType(type: Type) {
|
||||
if (type.flags & TypeFlags.Anonymous) {
|
||||
const symbol = type.symbol;
|
||||
if (symbol && symbol.flags & SymbolFlags.Class) {
|
||||
const declaration = getClassLikeDeclarationOfSymbol(symbol);
|
||||
if (declaration && declaration.flags & NodeFlags.Abstract) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case
|
||||
// when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible,
|
||||
// though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding.
|
||||
@ -6230,12 +6132,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext {
|
||||
const inferences: TypeInferences[] = [];
|
||||
for (const unused of typeParameters) {
|
||||
inferences.push({
|
||||
primary: undefined, secondary: undefined, isFixed: false
|
||||
});
|
||||
}
|
||||
const inferences = map(typeParameters, createTypeInferencesObject);
|
||||
|
||||
return {
|
||||
typeParameters,
|
||||
inferUnionTypes,
|
||||
@ -6244,6 +6142,14 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function createTypeInferencesObject(): TypeInferences {
|
||||
return {
|
||||
primary: undefined,
|
||||
secondary: undefined,
|
||||
isFixed: false,
|
||||
};
|
||||
}
|
||||
|
||||
function inferTypes(context: InferenceContext, source: Type, target: Type) {
|
||||
let sourceStack: Type[];
|
||||
let targetStack: Type[];
|
||||
@ -6514,10 +6420,6 @@ namespace ts {
|
||||
return context.inferredTypes;
|
||||
}
|
||||
|
||||
function hasAncestor(node: Node, kind: SyntaxKind): boolean {
|
||||
return getAncestor(node, kind) !== undefined;
|
||||
}
|
||||
|
||||
// EXPRESSION TYPE CHECKING
|
||||
|
||||
function getResolvedSymbol(node: Identifier): Symbol {
|
||||
@ -7140,17 +7042,14 @@ namespace ts {
|
||||
|
||||
function checkSuperExpression(node: Node): Type {
|
||||
const isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (<CallExpression>node.parent).expression === node;
|
||||
const classDeclaration = getContainingClass(node);
|
||||
const classType = classDeclaration && <InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration));
|
||||
const baseClassType = classType && getBaseTypes(classType)[0];
|
||||
|
||||
let container = getSuperContainer(node, /*includeFunctions*/ true);
|
||||
let container = getSuperContainer(node, /*stopOnFunctions*/ true);
|
||||
let needToCaptureLexicalThis = false;
|
||||
|
||||
if (!isCallExpression) {
|
||||
// adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
|
||||
while (container && container.kind === SyntaxKind.ArrowFunction) {
|
||||
container = getSuperContainer(container, /*includeFunctions*/ true);
|
||||
container = getSuperContainer(container, /*stopOnFunctions*/ true);
|
||||
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
|
||||
}
|
||||
}
|
||||
@ -7158,43 +7057,66 @@ namespace ts {
|
||||
const canUseSuperExpression = isLegalUsageOfSuperExpression(container);
|
||||
let nodeCheckFlag: NodeCheckFlags = 0;
|
||||
|
||||
// always set NodeCheckFlags for 'super' expression node
|
||||
if (canUseSuperExpression) {
|
||||
if ((container.flags & NodeFlags.Static) || isCallExpression) {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperStatic;
|
||||
}
|
||||
else {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperInstance;
|
||||
}
|
||||
|
||||
getNodeLinks(node).flags |= nodeCheckFlag;
|
||||
|
||||
if (needToCaptureLexicalThis) {
|
||||
// call expressions are allowed only in constructors so they should always capture correct 'this'
|
||||
// super property access expressions can also appear in arrow functions -
|
||||
// in this case they should also use correct lexical this
|
||||
captureLexicalThis(node.parent, container);
|
||||
}
|
||||
}
|
||||
|
||||
if (!baseClassType) {
|
||||
if (!classDeclaration || !getClassExtendsHeritageClauseElement(classDeclaration)) {
|
||||
error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (!canUseSuperExpression) {
|
||||
if (container && container.kind === SyntaxKind.ComputedPropertyName) {
|
||||
// issue more specific error if super is used in computed property name
|
||||
// class A { foo() { return "1" }}
|
||||
// class B {
|
||||
// [super.foo()]() {}
|
||||
// }
|
||||
let current = node;
|
||||
while (current && current !== container && current.kind !== SyntaxKind.ComputedPropertyName) {
|
||||
current = current.parent;
|
||||
}
|
||||
if (current && current.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
||||
}
|
||||
else if (isCallExpression) {
|
||||
error(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
|
||||
}
|
||||
else if (!container || !container.parent || !(isClassLike(container.parent) || container.parent.kind === SyntaxKind.ObjectLiteralExpression)) {
|
||||
error(node, Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if ((container.flags & NodeFlags.Static) || isCallExpression) {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperStatic;
|
||||
}
|
||||
else {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperInstance;
|
||||
}
|
||||
|
||||
getNodeLinks(node).flags |= nodeCheckFlag;
|
||||
|
||||
if (needToCaptureLexicalThis) {
|
||||
// call expressions are allowed only in constructors so they should always capture correct 'this'
|
||||
// super property access expressions can also appear in arrow functions -
|
||||
// in this case they should also use correct lexical this
|
||||
captureLexicalThis(node.parent, container);
|
||||
}
|
||||
|
||||
if (container.parent.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
error(node, Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
|
||||
return unknownType;
|
||||
}
|
||||
else {
|
||||
// for object literal assume that type of 'super' is 'any'
|
||||
return anyType;
|
||||
}
|
||||
}
|
||||
|
||||
// at this point the only legal case for parent is ClassLikeDeclaration
|
||||
const classLikeDeclaration = <ClassLikeDeclaration>container.parent;
|
||||
const classType = <InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
|
||||
const baseClassType = classType && getBaseTypes(classType)[0];
|
||||
if (!baseClassType) {
|
||||
if (!getClassExtendsHeritageClauseElement(classLikeDeclaration)) {
|
||||
error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@ -7224,8 +7146,8 @@ namespace ts {
|
||||
// - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance
|
||||
// - In a static member function or static member accessor
|
||||
|
||||
// topmost container must be something that is directly nested in the class declaration
|
||||
if (container && isClassLike(container.parent)) {
|
||||
// topmost container must be something that is directly nested in the class declaration\object literal expression
|
||||
if (isClassLike(container.parent) || container.parent.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
if (container.flags & NodeFlags.Static) {
|
||||
return container.kind === SyntaxKind.MethodDeclaration ||
|
||||
container.kind === SyntaxKind.MethodSignature ||
|
||||
@ -8117,7 +8039,6 @@ namespace ts {
|
||||
/// type or factory function.
|
||||
/// Otherwise, returns unknownSymbol.
|
||||
function getJsxElementTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
|
||||
const flags: JsxFlags = JsxFlags.UnknownElement;
|
||||
const links = getNodeLinks(node);
|
||||
if (!links.resolvedSymbol) {
|
||||
if (isJsxIntrinsicIdentifier(node.tagName)) {
|
||||
@ -8316,9 +8237,9 @@ namespace ts {
|
||||
// Props is of type 'any' or unknown
|
||||
return links.resolvedJsxType = attributesType;
|
||||
}
|
||||
else if (!(attributesType.flags & TypeFlags.ObjectType)) {
|
||||
// Props is not an object type
|
||||
error(node.tagName, Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType));
|
||||
else if (attributesType.flags & TypeFlags.Union) {
|
||||
// Props cannot be a union type
|
||||
error(node.tagName, Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType));
|
||||
return links.resolvedJsxType = anyType;
|
||||
}
|
||||
else {
|
||||
@ -14390,16 +14311,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getModuleStatements(node: Declaration): Statement[] {
|
||||
if (node.kind === SyntaxKind.SourceFile) {
|
||||
return (<SourceFile>node).statements;
|
||||
}
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).body.kind === SyntaxKind.ModuleBlock) {
|
||||
return (<ModuleBlock>(<ModuleDeclaration>node).body).statements;
|
||||
}
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
function hasExportedMembers(moduleSymbol: Symbol) {
|
||||
for (var id in moduleSymbol.exports) {
|
||||
if (id !== "export=") {
|
||||
@ -15478,20 +15389,6 @@ namespace ts {
|
||||
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
|
||||
}
|
||||
|
||||
function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type {
|
||||
if (functionType === unknownType) {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
const signature = getSingleCallSignature(functionType);
|
||||
if (!signature) {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
const instantiatedSignature = getSignatureInstantiation(signature, typeArguments);
|
||||
return getOrCreateTypeFromSignature(instantiatedSignature);
|
||||
}
|
||||
|
||||
function createResolver(): EmitResolver {
|
||||
return {
|
||||
getReferencedExportContainer,
|
||||
@ -15626,7 +15523,12 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
if (!nodeCanBeDecorated(node)) {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
|
||||
if (node.kind === SyntaxKind.MethodDeclaration && !ts.nodeIsPresent((<MethodDeclaration>node).body)) {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
|
||||
}
|
||||
else {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) {
|
||||
const accessors = getAllAccessorDeclarations((<ClassDeclaration>node.parent).members, <AccessorDeclaration>node);
|
||||
@ -16540,25 +16442,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isIntegerLiteral(expression: Expression): boolean {
|
||||
if (expression.kind === SyntaxKind.PrefixUnaryExpression) {
|
||||
const unaryExpression = <PrefixUnaryExpression>expression;
|
||||
if (unaryExpression.operator === SyntaxKind.PlusToken || unaryExpression.operator === SyntaxKind.MinusToken) {
|
||||
expression = unaryExpression.operand;
|
||||
}
|
||||
}
|
||||
if (expression.kind === SyntaxKind.NumericLiteral) {
|
||||
// Allows for scientific notation since literalExpression.text was formed by
|
||||
// coercing a number to a string. Sometimes this coercion can yield a string
|
||||
// in scientific notation.
|
||||
// We also don't need special logic for hex because a hex integer is converted
|
||||
// to decimal when it is coerced.
|
||||
return /^[0-9]+([eE]\+?[0-9]+)?$/.test((<LiteralExpression>expression).text);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
|
||||
return sourceFile.parseDiagnostics.length > 0;
|
||||
}
|
||||
@ -16587,11 +16470,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier &&
|
||||
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
|
||||
}
|
||||
|
||||
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
|
||||
if (node.typeParameters) {
|
||||
return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
|
||||
|
||||
@ -794,23 +794,6 @@ namespace ts {
|
||||
return path;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -1534,14 +1534,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),
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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
|
||||
|
||||
@ -14,7 +14,6 @@ namespace ts {
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
const nop = <(...args: any[]) => any>Function.prototype;
|
||||
let nullSourceMapWriter: SourceMapWriter;
|
||||
|
||||
export function getNullSourceMapWriter(): SourceMapWriter {
|
||||
|
||||
@ -218,7 +218,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
|
||||
@ -313,10 +312,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";
|
||||
|
||||
@ -1195,7 +1195,7 @@ namespace ts {
|
||||
|
||||
// @kind(SyntaxKind.CaseClause)
|
||||
export interface CaseClause extends Node {
|
||||
expression?: Expression;
|
||||
expression: Expression;
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
|
||||
@ -1723,6 +1723,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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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[]> = {};
|
||||
|
||||
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -31,7 +31,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 */
|
||||
@ -513,7 +512,6 @@ namespace Harness {
|
||||
}
|
||||
|
||||
const folder: any = fso.GetFolder(path);
|
||||
const paths: string[] = [];
|
||||
|
||||
return filesInFolder(folder, path);
|
||||
};
|
||||
@ -617,7 +615,6 @@ namespace Harness {
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => {};
|
||||
|
||||
const supportsCodePage = () => false;
|
||||
export let log = (s: string) => console.log(s);
|
||||
|
||||
namespace Http {
|
||||
@ -627,18 +624,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;
|
||||
|
||||
@ -315,13 +315,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();
|
||||
}
|
||||
|
||||
@ -305,25 +305,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);
|
||||
}
|
||||
|
||||
@ -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[];
|
||||
@ -514,7 +486,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;
|
||||
@ -569,21 +541,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)));
|
||||
|
||||
@ -611,7 +584,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));
|
||||
|
||||
@ -1109,7 +1083,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) {
|
||||
@ -1765,9 +1738,9 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getLineMapper() {
|
||||
return ((line: number) => {
|
||||
return (line: number) => {
|
||||
return this.index.lineNumberToInfo(line).offset;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
getTextChangeRangeSinceVersion(scriptVersion: number) {
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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();
|
||||
}
|
||||
@ -901,7 +893,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);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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'.
|
||||
}
|
||||
31
tests/baselines/reference/arrayLiteralComments.js
Normal file
31
tests/baselines/reference/arrayLiteralComments.js
Normal 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]
|
||||
];
|
||||
21
tests/baselines/reference/arrayLiteralComments.symbols
Normal file
21
tests/baselines/reference/arrayLiteralComments.symbols
Normal 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]
|
||||
]
|
||||
36
tests/baselines/reference/arrayLiteralComments.types
Normal file
36
tests/baselines/reference/arrayLiteralComments.types
Normal 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
|
||||
|
||||
]
|
||||
@ -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.
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -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() { }
|
||||
}
|
||||
}
|
||||
@ -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() { }
|
||||
}
|
||||
16
tests/baselines/reference/decoratorOnClassMethodOverload1.js
Normal file
16
tests/baselines/reference/decoratorOnClassMethodOverload1.js
Normal 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;
|
||||
}());
|
||||
25
tests/baselines/reference/decoratorOnClassMethodOverload2.js
Normal file
25
tests/baselines/reference/decoratorOnClassMethodOverload2.js
Normal 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;
|
||||
}());
|
||||
@ -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))
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
@ -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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
//// [prefixUnaryOperatorsOnExportedVariables.ts]
|
||||
|
||||
export var x = false;
|
||||
export var y = 1;
|
||||
if (!x) {
|
||||
|
||||
}
|
||||
|
||||
if (+x) {
|
||||
|
||||
}
|
||||
|
||||
if (-x) {
|
||||
|
||||
}
|
||||
|
||||
if (~x) {
|
||||
|
||||
}
|
||||
|
||||
if (void x) {
|
||||
|
||||
}
|
||||
|
||||
if (typeof x) {
|
||||
|
||||
}
|
||||
|
||||
if (++y) {
|
||||
|
||||
}
|
||||
|
||||
//// [prefixUnaryOperatorsOnExportedVariables.js]
|
||||
System.register([], function(exports_1) {
|
||||
"use strict";
|
||||
var x, y;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
exports_1("x", x = false);
|
||||
exports_1("y", y = 1);
|
||||
if (!x) {
|
||||
}
|
||||
if (+x) {
|
||||
}
|
||||
if (-x) {
|
||||
}
|
||||
if (~x) {
|
||||
}
|
||||
if (void x) {
|
||||
}
|
||||
if (typeof x) {
|
||||
}
|
||||
if (exports_1("y", ++y)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,42 @@
|
||||
=== tests/cases/compiler/prefixUnaryOperatorsOnExportedVariables.ts ===
|
||||
|
||||
export var x = false;
|
||||
>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10))
|
||||
|
||||
export var y = 1;
|
||||
>y : Symbol(y, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 2, 10))
|
||||
|
||||
if (!x) {
|
||||
>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10))
|
||||
|
||||
}
|
||||
|
||||
if (+x) {
|
||||
>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10))
|
||||
|
||||
}
|
||||
|
||||
if (-x) {
|
||||
>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10))
|
||||
|
||||
}
|
||||
|
||||
if (~x) {
|
||||
>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10))
|
||||
|
||||
}
|
||||
|
||||
if (void x) {
|
||||
>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10))
|
||||
|
||||
}
|
||||
|
||||
if (typeof x) {
|
||||
>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10))
|
||||
|
||||
}
|
||||
|
||||
if (++y) {
|
||||
>y : Symbol(y, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 2, 10))
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
=== tests/cases/compiler/prefixUnaryOperatorsOnExportedVariables.ts ===
|
||||
|
||||
export var x = false;
|
||||
>x : boolean
|
||||
>false : boolean
|
||||
|
||||
export var y = 1;
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
if (!x) {
|
||||
>!x : boolean
|
||||
>x : boolean
|
||||
|
||||
}
|
||||
|
||||
if (+x) {
|
||||
>+x : number
|
||||
>x : boolean
|
||||
|
||||
}
|
||||
|
||||
if (-x) {
|
||||
>-x : number
|
||||
>x : boolean
|
||||
|
||||
}
|
||||
|
||||
if (~x) {
|
||||
>~x : number
|
||||
>x : boolean
|
||||
|
||||
}
|
||||
|
||||
if (void x) {
|
||||
>void x : undefined
|
||||
>x : boolean
|
||||
|
||||
}
|
||||
|
||||
if (typeof x) {
|
||||
>typeof x : string
|
||||
>x : boolean
|
||||
|
||||
}
|
||||
|
||||
if (++y) {
|
||||
>++y : number
|
||||
>y : number
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/superCallFromFunction1.ts(3,5): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/superCallFromFunction1.ts(3,5): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superCallFromFunction1.ts (1 errors) ====
|
||||
@ -6,5 +6,5 @@ tests/cases/compiler/superCallFromFunction1.ts(3,5): error TS2335: 'super' can o
|
||||
function foo() {
|
||||
super(value => String(value));
|
||||
~~~~~
|
||||
!!! 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.
|
||||
}
|
||||
@ -1,15 +1,15 @@
|
||||
tests/cases/compiler/superErrors.ts(3,13): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/superErrors.ts(3,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(3,18): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superErrors.ts(4,19): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/superErrors.ts(4,19): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(4,24): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superErrors.ts(5,31): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/superErrors.ts(5,31): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(5,36): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/superErrors.ts(22,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(27,27): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(31,36): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(31,41): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/superErrors.ts(39,27): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(43,36): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superErrors.ts(43,41): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superErrors.ts(47,22): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superErrors.ts(48,28): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
@ -21,17 +21,17 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow
|
||||
// super in a non class context
|
||||
var x = super;
|
||||
~~~~~
|
||||
!!! 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 TS1034: 'super' must be followed by an argument list or member access.
|
||||
var y = () => super;
|
||||
~~~~~
|
||||
!!! 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 TS1034: 'super' must be followed by an argument list or member access.
|
||||
var z = () => () => () => super;
|
||||
~~~~~
|
||||
!!! 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 TS1034: 'super' must be followed by an argument list or member access.
|
||||
}
|
||||
@ -52,20 +52,20 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow
|
||||
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.
|
||||
}
|
||||
|
||||
// super call in a lambda in an inner function in a constructor
|
||||
function inner2() {
|
||||
var x = () => 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.
|
||||
}
|
||||
|
||||
// super call in a lambda in a function expression in a constructor
|
||||
(function() { return () => super; })();
|
||||
~~~~~
|
||||
!!! 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.
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
}
|
||||
@ -77,13 +77,13 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow
|
||||
function inner() {
|
||||
var x = () => 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.
|
||||
}
|
||||
|
||||
// super call in a lambda in a function expression in a constructor
|
||||
(function() { return () => super; })();
|
||||
~~~~~
|
||||
!!! 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.
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
}
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(7,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(10,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(14,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(17,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(20,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(23,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(39,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(42,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(46,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(49,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES5.ts(52,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superInObjectLiterals_ES5.ts (11 errors) ====
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
method() { }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
f() {
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
133
tests/baselines/reference/superInObjectLiterals_ES5.js
Normal file
133
tests/baselines/reference/superInObjectLiterals_ES5.js
Normal file
@ -0,0 +1,133 @@
|
||||
//// [superInObjectLiterals_ES5.ts]
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
method() { }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
f() {
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//// [superInObjectLiterals_ES5.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method: function () {
|
||||
}
|
||||
},
|
||||
method: function () {
|
||||
_super.prototype.method.call(this);
|
||||
},
|
||||
get prop() {
|
||||
_super.prototype.method.call(this);
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
_super.prototype.method.call(this);
|
||||
},
|
||||
p1: function () {
|
||||
_super.method.call(this);
|
||||
},
|
||||
p2: function f() {
|
||||
_super.method.call(this);
|
||||
},
|
||||
p3: function () {
|
||||
_super.method.call(this);
|
||||
}
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.method = function () { };
|
||||
return A;
|
||||
}());
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
B.prototype.f = function () {
|
||||
var _this = this;
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method: function () {
|
||||
}
|
||||
},
|
||||
method: function () {
|
||||
_super.prototype.method.call(this);
|
||||
},
|
||||
get prop() {
|
||||
_super.prototype.method.call(this);
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
_super.prototype.method.call(this);
|
||||
},
|
||||
p1: function () {
|
||||
_super.method.call(this);
|
||||
},
|
||||
p2: function f() {
|
||||
_super.method.call(this);
|
||||
},
|
||||
p3: function () {
|
||||
_super.prototype.method.call(_this);
|
||||
}
|
||||
};
|
||||
};
|
||||
return B;
|
||||
}(A));
|
||||
@ -0,0 +1,77 @@
|
||||
tests/cases/compiler/superInObjectLiterals_ES6.ts(17,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES6.ts(20,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES6.ts(23,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES6.ts(49,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/superInObjectLiterals_ES6.ts(52,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superInObjectLiterals_ES6.ts (5 errors) ====
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
method() { }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
f() {
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
119
tests/baselines/reference/superInObjectLiterals_ES6.js
Normal file
119
tests/baselines/reference/superInObjectLiterals_ES6.js
Normal file
@ -0,0 +1,119 @@
|
||||
//// [superInObjectLiterals_ES6.ts]
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
method() { }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
f() {
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//// [superInObjectLiterals_ES6.js]
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
class A {
|
||||
method() { }
|
||||
}
|
||||
class B extends A {
|
||||
f() {
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts]
|
||||
class A {
|
||||
foo() { return 1; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
foo() { return 2; }
|
||||
bar() {
|
||||
return class {
|
||||
[super.foo()]() {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES5.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.foo = function () { return 1; };
|
||||
return A;
|
||||
}());
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
B.prototype.foo = function () { return 2; };
|
||||
B.prototype.bar = function () {
|
||||
return (function () {
|
||||
function class_1() {
|
||||
}
|
||||
class_1.prototype[_super.prototype.foo.call(this)] = function () {
|
||||
return 100;
|
||||
};
|
||||
return class_1;
|
||||
}());
|
||||
};
|
||||
return B;
|
||||
}(A));
|
||||
@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 0))
|
||||
|
||||
foo() { return 1; }
|
||||
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 9))
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : Symbol(B, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 2, 1))
|
||||
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 0))
|
||||
|
||||
foo() { return 2; }
|
||||
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 4, 19))
|
||||
|
||||
bar() {
|
||||
>bar : Symbol(bar, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 5, 23))
|
||||
|
||||
return class {
|
||||
[super.foo()]() {
|
||||
>super.foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 0))
|
||||
>foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 9))
|
||||
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
foo() { return 1; }
|
||||
>foo : () => number
|
||||
>1 : number
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : B
|
||||
>A : A
|
||||
|
||||
foo() { return 2; }
|
||||
>foo : () => number
|
||||
>2 : number
|
||||
|
||||
bar() {
|
||||
>bar : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { [super.foo()]() { return 100; } } : typeof (Anonymous class)
|
||||
|
||||
[super.foo()]() {
|
||||
>super.foo() : number
|
||||
>super.foo : () => number
|
||||
>super : A
|
||||
>foo : () => number
|
||||
|
||||
return 100;
|
||||
>100 : number
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts]
|
||||
class A {
|
||||
foo() { return 1; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
foo() { return 2; }
|
||||
bar() {
|
||||
return class {
|
||||
[super.foo()]() {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES6.js]
|
||||
class A {
|
||||
foo() { return 1; }
|
||||
}
|
||||
class B extends A {
|
||||
foo() { return 2; }
|
||||
bar() {
|
||||
return class {
|
||||
[super.foo()]() {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 0))
|
||||
|
||||
foo() { return 1; }
|
||||
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 9))
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : Symbol(B, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 2, 1))
|
||||
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 0))
|
||||
|
||||
foo() { return 2; }
|
||||
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 4, 19))
|
||||
|
||||
bar() {
|
||||
>bar : Symbol(bar, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 5, 23))
|
||||
|
||||
return class {
|
||||
[super.foo()]() {
|
||||
>super.foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 9))
|
||||
>super : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 0))
|
||||
>foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 9))
|
||||
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
foo() { return 1; }
|
||||
>foo : () => number
|
||||
>1 : number
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : B
|
||||
>A : A
|
||||
|
||||
foo() { return 2; }
|
||||
>foo : () => number
|
||||
>2 : number
|
||||
|
||||
bar() {
|
||||
>bar : () => typeof (Anonymous class)
|
||||
|
||||
return class {
|
||||
>class { [super.foo()]() { return 100; } } : typeof (Anonymous class)
|
||||
|
||||
[super.foo()]() {
|
||||
>super.foo() : number
|
||||
>super.foo : () => number
|
||||
>super : A
|
||||
>foo : () => number
|
||||
|
||||
return 100;
|
||||
>100 : number
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(5,20): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(5,20): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2335: 'super' can only be referenced in a derived class.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts (7 errors) ====
|
||||
@ -16,19 +16,19 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24):
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return super._foo;
|
||||
~~~~~
|
||||
!!! error TS2335: 'super' can only be referenced in a derived class.
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
},
|
||||
set foo(value: string) {
|
||||
~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
super._foo = value;
|
||||
~~~~~
|
||||
!!! error TS2335: 'super' can only be referenced in a derived class.
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
},
|
||||
test: function () {
|
||||
return 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.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24):
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return super.test();
|
||||
~~~~~
|
||||
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -38,10 +38,10 @@ var ObjectLiteral;
|
||||
var ThisInObjectLiteral = {
|
||||
_foo: '1',
|
||||
get foo() {
|
||||
return _super._foo;
|
||||
return _super.prototype._foo;
|
||||
},
|
||||
set foo(value) {
|
||||
_super._foo = value;
|
||||
_super.prototype._foo = value;
|
||||
},
|
||||
test: function () {
|
||||
return _super._foo;
|
||||
@ -62,7 +62,7 @@ var SuperObjectTest = (function (_super) {
|
||||
SuperObjectTest.prototype.testing = function () {
|
||||
var test = {
|
||||
get F() {
|
||||
return _super.test.call(this);
|
||||
return _super.prototype.test.call(this);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
tests/cases/conformance/jsx/file.tsx(11,22): error TS2339: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/react.d.ts (0 errors) ====
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
props;
|
||||
}
|
||||
interface IntrinsicAttributes {
|
||||
ref?: string;
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
class MyComponent {
|
||||
render() {
|
||||
}
|
||||
|
||||
props: {
|
||||
ref?: string;
|
||||
}
|
||||
}
|
||||
|
||||
// Should be an OK
|
||||
var x = <MyComponent bar='world' />;
|
||||
~~~
|
||||
!!! error TS2339: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
|
||||
|
||||
41
tests/baselines/reference/tsxAttributeResolution11.js
Normal file
41
tests/baselines/reference/tsxAttributeResolution11.js
Normal file
@ -0,0 +1,41 @@
|
||||
//// [tests/cases/conformance/jsx/tsxAttributeResolution11.tsx] ////
|
||||
|
||||
//// [react.d.ts]
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
props;
|
||||
}
|
||||
interface IntrinsicAttributes {
|
||||
ref?: string;
|
||||
}
|
||||
}
|
||||
|
||||
//// [file.tsx]
|
||||
class MyComponent {
|
||||
render() {
|
||||
}
|
||||
|
||||
props: {
|
||||
ref?: string;
|
||||
}
|
||||
}
|
||||
|
||||
// Should be an OK
|
||||
var x = <MyComponent bar='world' />;
|
||||
|
||||
|
||||
|
||||
//// [file.jsx]
|
||||
var MyComponent = (function () {
|
||||
function MyComponent() {
|
||||
}
|
||||
MyComponent.prototype.render = function () {
|
||||
};
|
||||
return MyComponent;
|
||||
}());
|
||||
// Should be an OK
|
||||
var x = <MyComponent bar='world'/>;
|
||||
8
tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts
Normal file
8
tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts
Normal file
@ -0,0 +1,8 @@
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
// @noEmitOnError: true
|
||||
|
||||
type T = { x : number }
|
||||
export interface I {
|
||||
f: T;
|
||||
}
|
||||
14
tests/cases/compiler/arrayLiteralComments.ts
Normal file
14
tests/cases/compiler/arrayLiteralComments.ts
Normal file
@ -0,0 +1,14 @@
|
||||
var testArrayWithFunc = [
|
||||
// Function comment
|
||||
function() {
|
||||
let x = 1;
|
||||
},
|
||||
// String comment
|
||||
'1',
|
||||
// Numeric comment
|
||||
2,
|
||||
// Object comment
|
||||
{ a: 1 },
|
||||
// Array comment
|
||||
[1, 2, 3]
|
||||
]
|
||||
@ -0,0 +1,32 @@
|
||||
// @target: ES5
|
||||
// @module: system
|
||||
|
||||
export var x = false;
|
||||
export var y = 1;
|
||||
if (!x) {
|
||||
|
||||
}
|
||||
|
||||
if (+x) {
|
||||
|
||||
}
|
||||
|
||||
if (-x) {
|
||||
|
||||
}
|
||||
|
||||
if (~x) {
|
||||
|
||||
}
|
||||
|
||||
if (void x) {
|
||||
|
||||
}
|
||||
|
||||
if (typeof x) {
|
||||
|
||||
}
|
||||
|
||||
if (++y) {
|
||||
|
||||
}
|
||||
60
tests/cases/compiler/superInObjectLiterals_ES5.ts
Normal file
60
tests/cases/compiler/superInObjectLiterals_ES5.ts
Normal file
@ -0,0 +1,60 @@
|
||||
// @target: ES5
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
method() { }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
f() {
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
60
tests/cases/compiler/superInObjectLiterals_ES6.ts
Normal file
60
tests/cases/compiler/superInObjectLiterals_ES6.ts
Normal file
@ -0,0 +1,60 @@
|
||||
// @target: ES6
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
|
||||
class A {
|
||||
method() { }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
f() {
|
||||
var obj = {
|
||||
__proto__: {
|
||||
method() {
|
||||
}
|
||||
},
|
||||
method() {
|
||||
super.method();
|
||||
},
|
||||
get prop() {
|
||||
super.method();
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
super.method();
|
||||
},
|
||||
p1: function () {
|
||||
super.method();
|
||||
},
|
||||
p2: function f() {
|
||||
super.method();
|
||||
},
|
||||
p3: () => {
|
||||
super.method();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
// @target: ES5
|
||||
class A {
|
||||
foo() { return 1; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
foo() { return 2; }
|
||||
bar() {
|
||||
return class {
|
||||
[super.foo()]() {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
// @target: ES6
|
||||
class A {
|
||||
foo() { return 1; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
foo() { return 2; }
|
||||
bar() {
|
||||
return class {
|
||||
[super.foo()]() {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
// @target: ES5
|
||||
// @experimentaldecorators: true
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
@dec
|
||||
method()
|
||||
method() { }
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
// @target: ES5
|
||||
// @experimentaldecorators: true
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
method()
|
||||
@dec
|
||||
method() { }
|
||||
}
|
||||
29
tests/cases/conformance/jsx/tsxAttributeResolution11.tsx
Normal file
29
tests/cases/conformance/jsx/tsxAttributeResolution11.tsx
Normal file
@ -0,0 +1,29 @@
|
||||
//@jsx: preserve
|
||||
//@module: amd
|
||||
|
||||
//@filename: react.d.ts
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
props;
|
||||
}
|
||||
interface IntrinsicAttributes {
|
||||
ref?: string;
|
||||
}
|
||||
}
|
||||
|
||||
//@filename: file.tsx
|
||||
class MyComponent {
|
||||
render() {
|
||||
}
|
||||
|
||||
props: {
|
||||
ref?: string;
|
||||
}
|
||||
}
|
||||
|
||||
// Should be an OK
|
||||
var x = <MyComponent bar='world' />;
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// class Foo {
|
||||
//// constructor(private /*0*/privateParam: number,
|
||||
//// public /*1*/publicParam: string,
|
||||
//// protected /*2*/protectedParam: boolean) {
|
||||
////
|
||||
//// let localPrivate = /*3*/privateParam;
|
||||
//// this./*4*/privateParam += 10;
|
||||
////
|
||||
//// let localPublic = /*5*/publicParam;
|
||||
//// this./*6*/publicParam += " Hello!";
|
||||
////
|
||||
//// let localProtected = /*7*/protectedParam;
|
||||
//// this./*8*/protectedParam = false;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let markers = test.markers()
|
||||
for (let marker of markers) {
|
||||
goTo.position(marker.position);
|
||||
verify.documentHighlightsAtPositionCount(3, ["file1.ts"]);
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// class Foo {
|
||||
//// constructor(private {/*0*/privateParam}: number,
|
||||
//// public {/*1*/publicParam}: string,
|
||||
//// protected {/*2*/protectedParam}: boolean) {
|
||||
////
|
||||
//// let localPrivate = /*3*/privateParam;
|
||||
//// this.privateParam += 10; // this is not valid syntax
|
||||
////
|
||||
//// let localPublic = /*4*/publicParam;
|
||||
//// this.publicParam += " Hello!"; // this is not valid syntax
|
||||
////
|
||||
//// let localProtected = /*5*/protectedParam;
|
||||
//// this.protectedParam = false; // this is not valid syntax
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let markers = test.markers()
|
||||
for (let marker of markers) {
|
||||
goTo.position(marker.position);
|
||||
verify.documentHighlightsAtPositionCount(2, ["file1.ts"]);
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// class Foo {
|
||||
//// constructor(private [/*0*/privateParam]: number,
|
||||
//// public [/*1*/publicParam]: string,
|
||||
//// protected [/*2*/protectedParam]: boolean) {
|
||||
////
|
||||
//// let localPrivate = /*3*/privateParam;
|
||||
//// this.privateParam += 10; // this is not valid syntax
|
||||
////
|
||||
//// let localPublic = /*4*/publicParam;
|
||||
//// this.publicParam += " Hello!"; // this is not valid syntax
|
||||
////
|
||||
//// let localProtected = /*5*/protectedParam;
|
||||
//// this.protectedParam = false; // this is not valid syntax
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let markers = test.markers()
|
||||
for (let marker of markers) {
|
||||
goTo.position(marker.position);
|
||||
verify.documentHighlightsAtPositionCount(2, ["file1.ts"]);
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(private [|privateParam|]: number) {
|
||||
//// let localPrivate = [|privateParam|];
|
||||
//// this.[|privateParam|] += 10;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
if (ranges.length) {
|
||||
verify.referencesCountIs(ranges.length);
|
||||
for (const expectedRange of ranges) {
|
||||
verify.referencesAtPositionContains(expectedRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(public [|publicParam|]: number) {
|
||||
//// let localPublic = [|publicParam|];
|
||||
//// this.[|publicParam|] += 10;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.referencesCountIs(ranges.length);
|
||||
for (let expectedRange of ranges) {
|
||||
verify.referencesAtPositionContains(expectedRange);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(protected [|protectedParam|]: number) {
|
||||
//// let localProtected = [|protectedParam|];
|
||||
//// this.[|protectedParam|] += 10;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
const ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.referencesCountIs(ranges.length);
|
||||
for (const expectedRange of ranges) {
|
||||
verify.referencesAtPositionContains(expectedRange);
|
||||
}
|
||||
}
|
||||
@ -137,6 +137,7 @@ declare namespace FourSlashInterface {
|
||||
verifyDefinitionsName(name: string, containerName: string): void;
|
||||
}
|
||||
class verify extends verifyNegatable {
|
||||
assertHasRanges(ranges: FourSlash.Range[]): void;
|
||||
caretAtMarker(markerName?: string): void;
|
||||
indentationIs(numberOfSpaces: number): void;
|
||||
indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle): void;
|
||||
|
||||
34
tests/cases/fourslash/getOccurrencesSuper3.ts
Normal file
34
tests/cases/fourslash/getOccurrencesSuper3.ts
Normal file
@ -0,0 +1,34 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////let x = {
|
||||
//// a() {
|
||||
//// return [|s/**/uper|].b();
|
||||
//// },
|
||||
//// b() {
|
||||
//// return [|super|].a();
|
||||
//// },
|
||||
//// c: function () {
|
||||
//// return [|super|].a();
|
||||
//// }
|
||||
//// d: () => [|super|].b();
|
||||
////}
|
||||
|
||||
function checkRange(r: FourSlashInterface.Range, expectedOccurences: FourSlashInterface.Range[]): void {
|
||||
goTo.position(r.start);
|
||||
if (expectedOccurences.length) {
|
||||
for (const expected of expectedOccurences) {
|
||||
verify.occurrencesAtPositionContains(expected);
|
||||
}
|
||||
}
|
||||
else {
|
||||
verify.occurrencesAtPositionCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
let [r0, r1, r2, r3] = test.ranges();
|
||||
|
||||
checkRange(r0, [r0, r1]);
|
||||
checkRange(r1, [r0, r1]);
|
||||
checkRange(r0, [r0, r1]);
|
||||
checkRange(r2, []);
|
||||
checkRange(r3, []);
|
||||
@ -0,0 +1,24 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// class Foo {
|
||||
//// constructor(private /*0*/privateParam: number,
|
||||
//// public /*1*/publicParam: string,
|
||||
//// protected /*2*/protectedParam: boolean) {
|
||||
////
|
||||
//// let localPrivate = /*3*/privateParam;
|
||||
//// this./*4*/privateParam += 10;
|
||||
////
|
||||
//// let localPublic = /*5*/publicParam;
|
||||
//// this./*6*/publicParam += " Hello!";
|
||||
////
|
||||
//// let localProtected = /*7*/protectedParam;
|
||||
//// this./*8*/protectedParam = false;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let markers = test.markers()
|
||||
for (let marker of markers) {
|
||||
goTo.position(marker.position);
|
||||
verify.referencesCountIs(3);
|
||||
}
|
||||
15
tests/cases/fourslash/renameParameterPropertyDeclaration1.ts
Normal file
15
tests/cases/fourslash/renameParameterPropertyDeclaration1.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(private [|privateParam|]: number) {
|
||||
//// let localPrivate = [|privateParam|];
|
||||
//// this.[|privateParam|] += 10;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
15
tests/cases/fourslash/renameParameterPropertyDeclaration2.ts
Normal file
15
tests/cases/fourslash/renameParameterPropertyDeclaration2.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(public [|publicParam|]: number) {
|
||||
//// let publicParam = [|publicParam|];
|
||||
//// this.[|publicParam|] += 10;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
15
tests/cases/fourslash/renameParameterPropertyDeclaration3.ts
Normal file
15
tests/cases/fourslash/renameParameterPropertyDeclaration3.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(protected [|protectedParam|]: number) {
|
||||
//// let protectedParam = [|protectedParam|];
|
||||
//// this.[|protectedParam|] += 10;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
14
tests/cases/fourslash/renameParameterPropertyDeclaration4.ts
Normal file
14
tests/cases/fourslash/renameParameterPropertyDeclaration4.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(protected { [|protectedParam|] }) {
|
||||
//// let myProtectedParam = [|protectedParam|];
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
14
tests/cases/fourslash/renameParameterPropertyDeclaration5.ts
Normal file
14
tests/cases/fourslash/renameParameterPropertyDeclaration5.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Foo {
|
||||
//// constructor(protected [ [|protectedParam|] ]) {
|
||||
//// let myProtectedParam = [|protectedParam|];
|
||||
//// }
|
||||
//// }
|
||||
|
||||
let ranges = test.ranges();
|
||||
verify.assertHasRanges(ranges);
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
/// <reference path="..\..\..\src\harness\harness.ts" />
|
||||
|
||||
const expect: typeof _chai.expect = _chai.expect;
|
||||
|
||||
namespace ts.server {
|
||||
let lastWrittenToHost: string;
|
||||
const mockHost: ServerHost = {
|
||||
@ -28,7 +30,7 @@ namespace ts.server {
|
||||
endGroup(): void {},
|
||||
msg(s: string, type?: string): void {},
|
||||
};
|
||||
|
||||
|
||||
describe("the Session class", () => {
|
||||
let session: Session;
|
||||
let lastSent: protocol.Message;
|
||||
@ -204,7 +206,7 @@ namespace ts.server {
|
||||
.to.throw(`Protocol handler already exists for command "${command}"`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("event", () => {
|
||||
it("can format event responses and send them", () => {
|
||||
const evt = "notify-test";
|
||||
@ -315,7 +317,7 @@ namespace ts.server {
|
||||
responseRequired: true
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
send(msg: protocol.Message) {
|
||||
this.client.handle(msg);
|
||||
}
|
||||
@ -323,7 +325,7 @@ namespace ts.server {
|
||||
enqueue(msg: protocol.Request) {
|
||||
this.queue.unshift(msg);
|
||||
}
|
||||
|
||||
|
||||
handleRequest(msg: protocol.Request) {
|
||||
let response: protocol.Response;
|
||||
try {
|
||||
@ -345,7 +347,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class InProcClient {
|
||||
private server: InProcSession;
|
||||
private seq = 0;
|
||||
@ -379,7 +381,7 @@ namespace ts.server {
|
||||
connect(session: InProcSession): void {
|
||||
this.server = session;
|
||||
}
|
||||
|
||||
|
||||
execute(command: string, args: any, callback: (resp: protocol.Response) => void): void {
|
||||
if (!this.server) {
|
||||
return;
|
||||
@ -394,7 +396,7 @@ namespace ts.server {
|
||||
this.callbacks[this.seq] = callback;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
it("can be constructed and respond to commands", (done) => {
|
||||
const cli = new InProcClient();
|
||||
const session = new InProcSession(cli);
|
||||
@ -402,23 +404,23 @@ namespace ts.server {
|
||||
data: true
|
||||
};
|
||||
const toEvent = {
|
||||
data: false
|
||||
data: false
|
||||
};
|
||||
let responses = 0;
|
||||
|
||||
// Connect the client
|
||||
cli.connect(session);
|
||||
|
||||
|
||||
// Add an event handler
|
||||
cli.on("testevent", (eventinfo) => {
|
||||
expect(eventinfo).to.equal(toEvent);
|
||||
responses++;
|
||||
expect(responses).to.equal(1);
|
||||
});
|
||||
|
||||
|
||||
// Trigger said event from the server
|
||||
session.event(toEvent, "testevent");
|
||||
|
||||
|
||||
// Queue an echo command
|
||||
cli.execute("echo", toEcho, (resp) => {
|
||||
assert(resp.success, resp.message);
|
||||
@ -426,7 +428,7 @@ namespace ts.server {
|
||||
expect(responses).to.equal(2);
|
||||
expect(resp.body).to.deep.equal(toEcho);
|
||||
});
|
||||
|
||||
|
||||
// Queue a configure command
|
||||
cli.execute("configure", {
|
||||
hostInfo: "unit test",
|
||||
@ -436,10 +438,10 @@ namespace ts.server {
|
||||
}, (resp) => {
|
||||
assert(resp.success, resp.message);
|
||||
responses++;
|
||||
expect(responses).to.equal(3);
|
||||
expect(responses).to.equal(3);
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
// Consume the queue and trigger the callbacks
|
||||
session.consumeQueue();
|
||||
});
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
"no-trailing-whitespace": true,
|
||||
"no-inferrable-types": true,
|
||||
"no-null": true,
|
||||
"no-unused-variable": true,
|
||||
"boolean-trivia": true,
|
||||
"type-operator-spacing": true,
|
||||
"prefer-const": true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user