Merge branch 'master' into duplicateIdentifierBindingElement

This commit is contained in:
Yui T 2015-05-05 15:05:55 -07:00
commit a5ec06c8bf
44 changed files with 1011 additions and 6118 deletions

1
bin/lib.d.ts vendored
View file

@ -15838,6 +15838,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
overrideMimeType(mime: string): void;
send(data?: Document): void;
send(data?: string): void;
send(data?: any): void;
setRequestHeader(header: string, value: string): void;
DONE: number;
HEADERS_RECEIVED: number;

1
bin/lib.dom.d.ts vendored
View file

@ -14668,6 +14668,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
overrideMimeType(mime: string): void;
send(data?: Document): void;
send(data?: string): void;
send(data?: any): void;
setRequestHeader(header: string, value: string): void;
DONE: number;
HEADERS_RECEIVED: number;

1
bin/lib.es6.d.ts vendored
View file

@ -17217,6 +17217,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
overrideMimeType(mime: string): void;
send(data?: Document): void;
send(data?: string): void;
send(data?: any): void;
setRequestHeader(header: string, value: string): void;
DONE: number;
HEADERS_RECEIVED: number;

View file

@ -444,7 +444,7 @@ var ts;
for (var _i = 0; _i < parts.length; _i++) {
var part = parts[_i];
if (part !== ".") {
if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") {
normalized.pop();
}
else {
@ -536,7 +536,7 @@ var ts;
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") {
directoryComponents.length--;
}
for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
@ -1416,6 +1416,9 @@ var ts;
Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -1844,7 +1847,7 @@ var ts;
}
collecting = true;
if (result && result.length) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
continue;
case 9:
@ -1890,7 +1893,7 @@ var ts;
default:
if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) {
if (result && result.length && isLineBreak(ch)) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
pos++;
continue;
@ -3908,7 +3911,7 @@ var ts;
}
ts.hasQuestionToken = hasQuestionToken;
function hasRestParameters(s) {
return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined;
return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined;
}
ts.hasRestParameters = hasRestParameters;
function isLiteralKind(kind) {
@ -4336,7 +4339,7 @@ var ts;
var lineStartsOfS = ts.computeLineStarts(s);
if (lineStartsOfS.length > 1) {
lineCount = lineCount + lineStartsOfS.length - 1;
linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS);
}
}
}
@ -4405,8 +4408,8 @@ var ts;
ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
function shouldEmitToOwnFile(sourceFile, compilerOptions) {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) {
return true;
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js");
}
return false;
}
@ -5981,7 +5984,7 @@ var ts;
templateSpans.pos = getNodePos();
do {
templateSpans.push(parseTemplateSpan());
} while (templateSpans[templateSpans.length - 1].literal.kind === 12);
} while (ts.lastOrUndefined(templateSpans).literal.kind === 12);
templateSpans.end = getNodeEnd();
template.templateSpans = templateSpans;
return finishNode(template);
@ -11125,7 +11128,7 @@ var ts;
}
function getRestTypeOfSignature(signature) {
if (signature.hasRestParameter) {
var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters));
if (type.flags & 4096 && type.target === globalArrayType) {
return type.typeArguments[0];
}
@ -13219,7 +13222,7 @@ var ts;
}
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]);
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
}
@ -14279,9 +14282,9 @@ var ts;
links.type = instantiateType(getTypeAtPosition(context, i), mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
var parameter = signature.parameters[signature.parameters.length - 1];
var parameter = ts.lastOrUndefined(signature.parameters);
var links = getSymbolLinks(parameter);
links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper);
links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper);
}
}
function getReturnTypeFromBody(func, contextualMapper) {
@ -18660,7 +18663,7 @@ var ts;
function checkGrammarBindingElement(node) {
if (node.dotDotDotToken) {
var elements = node.parent.elements;
if (node !== elements[elements.length - 1]) {
if (node !== ts.lastOrUndefined(elements)) {
return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
}
if (node.name.kind === 152 || node.name.kind === 151) {
@ -20446,7 +20449,7 @@ var ts;
var sourceMapNameIndexMap = {};
var sourceMapNameIndices = [];
function getSourceMapNameIndex() {
return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1;
return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1;
}
var lastRecordedSourceMapSpan;
var lastEncodedSourceMapSpan = {
@ -22922,11 +22925,11 @@ var ts;
emitNodeWithoutSourceMap(memberName);
}
}
function getInitializedProperties(node, static) {
function getInitializedProperties(node, isStatic) {
var properties = [];
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if (member.kind === 133 && static === ((member.flags & 128) !== 0) && member.initializer) {
if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) {
properties.push(member);
}
}
@ -24834,10 +24837,10 @@ var ts;
}
}
function hasDetachedComments(pos) {
return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos;
return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos;
}
function getLeadingCommentsWithoutDetachedComments() {
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos);
if (detachedCommentsInfo.length - 1) {
detachedCommentsInfo.pop();
}
@ -24918,12 +24921,12 @@ var ts;
lastComment = comment;
});
if (detachedComments.length) {
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end);
var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
if (nodeLine >= lastCommentLine + 2) {
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment);
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end };
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end };
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
}
@ -24964,6 +24967,8 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
ts.version = "1.5.0";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -25034,6 +25039,9 @@ var ts;
}
}
}
var newLine = options.newLine === 0 ? carriageReturnLineFeed :
options.newLine === 1 ? lineFeed :
ts.sys.newLine;
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -25041,7 +25049,7 @@ var ts;
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
getCanonicalFileName: getCanonicalFileName,
getNewLine: function () { return ts.sys.newLine; }
getNewLine: function () { return newLine; }
};
}
ts.createCompilerHost = createCompilerHost;
@ -25526,6 +25534,16 @@ var ts;
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
},
{
name: "newLine",
type: {
"crlf": 0,
"lf": 1
},
description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
paramType: ts.Diagnostics.NEWLINE,
error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
},
{
name: "noEmit",
type: "boolean",

View file

@ -444,7 +444,7 @@ var ts;
for (var _i = 0; _i < parts.length; _i++) {
var part = parts[_i];
if (part !== ".") {
if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") {
normalized.pop();
}
else {
@ -536,7 +536,7 @@ var ts;
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") {
directoryComponents.length--;
}
for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
@ -1416,6 +1416,9 @@ var ts;
Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -1844,7 +1847,7 @@ var ts;
}
collecting = true;
if (result && result.length) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
continue;
case 9:
@ -1890,7 +1893,7 @@ var ts;
default:
if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) {
if (result && result.length && isLineBreak(ch)) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
pos++;
continue;
@ -2770,6 +2773,16 @@ var ts;
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
},
{
name: "newLine",
type: {
"crlf": 0,
"lf": 1
},
description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
paramType: ts.Diagnostics.NEWLINE,
error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
},
{
name: "noEmit",
type: "boolean",
@ -3769,7 +3782,7 @@ var ts;
}
ts.hasQuestionToken = hasQuestionToken;
function hasRestParameters(s) {
return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined;
return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined;
}
ts.hasRestParameters = hasRestParameters;
function isLiteralKind(kind) {
@ -4197,7 +4210,7 @@ var ts;
var lineStartsOfS = ts.computeLineStarts(s);
if (lineStartsOfS.length > 1) {
lineCount = lineCount + lineStartsOfS.length - 1;
linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS);
}
}
}
@ -4266,8 +4279,8 @@ var ts;
ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
function shouldEmitToOwnFile(sourceFile, compilerOptions) {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) {
return true;
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js");
}
return false;
}
@ -5842,7 +5855,7 @@ var ts;
templateSpans.pos = getNodePos();
do {
templateSpans.push(parseTemplateSpan());
} while (templateSpans[templateSpans.length - 1].literal.kind === 12);
} while (ts.lastOrUndefined(templateSpans).literal.kind === 12);
templateSpans.end = getNodeEnd();
template.templateSpans = templateSpans;
return finishNode(template);
@ -11499,7 +11512,7 @@ var ts;
}
function getRestTypeOfSignature(signature) {
if (signature.hasRestParameter) {
var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters));
if (type.flags & 4096 && type.target === globalArrayType) {
return type.typeArguments[0];
}
@ -13593,7 +13606,7 @@ var ts;
}
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]);
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
}
@ -14653,9 +14666,9 @@ var ts;
links.type = instantiateType(getTypeAtPosition(context, i), mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
var parameter = signature.parameters[signature.parameters.length - 1];
var parameter = ts.lastOrUndefined(signature.parameters);
var links = getSymbolLinks(parameter);
links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper);
links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper);
}
}
function getReturnTypeFromBody(func, contextualMapper) {
@ -19034,7 +19047,7 @@ var ts;
function checkGrammarBindingElement(node) {
if (node.dotDotDotToken) {
var elements = node.parent.elements;
if (node !== elements[elements.length - 1]) {
if (node !== ts.lastOrUndefined(elements)) {
return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
}
if (node.name.kind === 152 || node.name.kind === 151) {
@ -20820,7 +20833,7 @@ var ts;
var sourceMapNameIndexMap = {};
var sourceMapNameIndices = [];
function getSourceMapNameIndex() {
return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1;
return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1;
}
var lastRecordedSourceMapSpan;
var lastEncodedSourceMapSpan = {
@ -23296,11 +23309,11 @@ var ts;
emitNodeWithoutSourceMap(memberName);
}
}
function getInitializedProperties(node, static) {
function getInitializedProperties(node, isStatic) {
var properties = [];
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if (member.kind === 133 && static === ((member.flags & 128) !== 0) && member.initializer) {
if (member.kind === 133 && isStatic === ((member.flags & 128) !== 0) && member.initializer) {
properties.push(member);
}
}
@ -25208,10 +25221,10 @@ var ts;
}
}
function hasDetachedComments(pos) {
return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos;
return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos;
}
function getLeadingCommentsWithoutDetachedComments() {
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos);
if (detachedCommentsInfo.length - 1) {
detachedCommentsInfo.pop();
}
@ -25292,12 +25305,12 @@ var ts;
lastComment = comment;
});
if (detachedComments.length) {
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end);
var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
if (nodeLine >= lastCommentLine + 2) {
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment);
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end };
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end };
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
}
@ -25338,6 +25351,8 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
ts.version = "1.5.0";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -25408,6 +25423,9 @@ var ts;
}
}
}
var newLine = options.newLine === 0 ? carriageReturnLineFeed :
options.newLine === 1 ? lineFeed :
ts.sys.newLine;
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -25415,7 +25433,7 @@ var ts;
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
getCanonicalFileName: getCanonicalFileName,
getNewLine: function () { return ts.sys.newLine; }
getNewLine: function () { return newLine; }
};
}
ts.createCompilerHost = createCompilerHost;
@ -26136,13 +26154,13 @@ var ts;
return textSpan(node);
}
case 224:
return spanInNode(node.parent.statements[node.parent.statements.length - 1]);
return spanInNode(ts.lastOrUndefined(node.parent.statements));
;
case 208:
var caseBlock = node.parent;
var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1];
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
if (lastClause) {
return spanInNode(lastClause.statements[lastClause.statements.length - 1]);
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
default:
@ -27786,7 +27804,7 @@ var ts;
function nodeEndsWith(n, expectedLastToken, sourceFile) {
var children = n.getChildren(sourceFile);
if (children.length) {
var last = children[children.length - 1];
var last = ts.lastOrUndefined(children);
if (last.kind === expectedLastToken) {
return true;
}
@ -28226,7 +28244,7 @@ var ts;
if (isStarted) {
if (trailingTrivia) {
ts.Debug.assert(trailingTrivia.length !== 0);
wasNewLine = trailingTrivia[trailingTrivia.length - 1].kind === 4;
wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4;
}
else {
wasNewLine = false;
@ -29468,6 +29486,8 @@ var ts;
var previousRange;
var previousParent;
var previousRangeStartLine;
var lastIndentedLine;
var indentationOnLastIndentedLine;
var edits = [];
formattingScanner.advance();
if (formattingScanner.isOnToken()) {
@ -29522,7 +29542,9 @@ var ts;
}
var delta = formatting.SmartIndenter.shouldIndentChildNode(node.kind, 0) ? options.IndentSize : 0;
if (effectiveParentStartLine === startLine) {
indentation = parentDynamicIndentation.getIndentation();
indentation = startLine === lastIndentedLine
? indentationOnLastIndentedLine
: parentDynamicIndentation.getIndentation();
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
}
return {
@ -29732,7 +29754,6 @@ var ts;
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
continue;
}
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
switch (triviaItem.kind) {
case 3:
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
@ -29755,6 +29776,8 @@ var ts;
if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
}
}
formattingScanner.advance();
@ -32554,22 +32577,6 @@ var ts;
}
return ScriptElementKind.unknown;
}
function getTypeKind(type) {
var flags = type.getFlags();
if (flags & 128)
return ScriptElementKind.enumElement;
if (flags & 1024)
return ScriptElementKind.classElement;
if (flags & 2048)
return ScriptElementKind.interfaceElement;
if (flags & 512)
return ScriptElementKind.typeParameterElement;
if (flags & 1048703)
return ScriptElementKind.primitiveType;
if (flags & 256)
return ScriptElementKind.primitiveType;
return ScriptElementKind.unknown;
}
function getSymbolModifiers(symbol) {
return symbol && symbol.declarations && symbol.declarations.length > 0
? ts.getNodeModifiers(symbol.declarations[0])
@ -32933,6 +32940,59 @@ var ts;
containerName: containerName
};
}
function getDefinitionFromSymbol(symbol, node) {
var typeChecker = program.getTypeChecker();
var result = [];
var declarations = symbol.getDeclarations();
var symbolName = typeChecker.symbolToString(symbol);
var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
ts.forEach(declarations, function (declaration) {
result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName));
});
}
return result;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isNewExpressionTarget(location) || location.kind === 114) {
if (symbol.flags & 32) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 202);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
}
}
return false;
}
function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) {
return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result);
}
return false;
}
function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) {
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
if ((selectConstructors && d.kind === 136) ||
(!selectConstructors && (d.kind === 201 || d.kind === 135 || d.kind === 134))) {
declarations.push(d);
if (d.body)
definition = d;
}
});
if (definition) {
result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName));
return true;
}
else if (declarations.length) {
result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName));
return true;
}
return false;
}
}
function getDefinitionAtPosition(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
@ -32982,56 +33042,37 @@ var ts;
var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); });
}
var result = [];
var declarations = symbol.getDeclarations();
var symbolName = typeChecker.symbolToString(symbol);
var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
ts.forEach(declarations, function (declaration) {
result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName));
});
return getDefinitionFromSymbol(symbol, node);
}
function getTypeDefinitionAtPosition(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
var node = ts.getTouchingPropertyName(sourceFile, position);
if (!node) {
return undefined;
}
return result;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isNewExpressionTarget(location) || location.kind === 114) {
if (symbol.flags & 32) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 202);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
}
}
return false;
var typeChecker = program.getTypeChecker();
var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
return undefined;
}
function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) {
return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result);
}
return false;
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
if (!type) {
return undefined;
}
function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) {
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
if ((selectConstructors && d.kind === 136) ||
(!selectConstructors && (d.kind === 201 || d.kind === 135 || d.kind === 134))) {
declarations.push(d);
if (d.body)
definition = d;
if (type.flags & 16384) {
var result = [];
ts.forEach(type.types, function (t) {
if (t.symbol) {
result.push.apply(result, getDefinitionFromSymbol(t.symbol, node));
}
});
if (definition) {
result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName));
return true;
}
else if (declarations.length) {
result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName));
return true;
}
return false;
return result;
}
if (!type.symbol) {
return undefined;
}
return getDefinitionFromSymbol(type.symbol, node);
}
function getOccurrencesAtPosition(fileName, position) {
var results = getOccurrencesAtPositionCore(fileName, position);
@ -34797,6 +34838,7 @@ var ts;
getSignatureHelpItems: getSignatureHelpItems,
getQuickInfoAtPosition: getQuickInfoAtPosition,
getDefinitionAtPosition: getDefinitionAtPosition,
getTypeDefinitionAtPosition: getTypeDefinitionAtPosition,
getReferencesAtPosition: getReferencesAtPosition,
findReferences: findReferences,
getOccurrencesAtPosition: getOccurrencesAtPosition,
@ -35300,6 +35342,7 @@ var ts;
CommandNames.Rename = "rename";
CommandNames.Saveto = "saveto";
CommandNames.SignatureHelp = "signatureHelp";
CommandNames.TypeDefinition = "typeDefinition";
CommandNames.Unknown = "unknown";
})(CommandNames = server.CommandNames || (server.CommandNames = {}));
var Errors;
@ -35471,6 +35514,24 @@ var ts;
end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan))
}); });
};
Session.prototype.getTypeDefinition = function (line, offset, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
var definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position);
if (!definitions) {
return undefined;
}
return definitions.map(function (def) { return ({
file: def.fileName,
start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start),
end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan))
}); });
};
Session.prototype.getOccurrences = function (line, offset, fileName) {
fileName = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(fileName);
@ -35665,7 +35726,7 @@ var ts;
IndentSize: formatOptions.IndentSize,
TabSize: formatOptions.TabSize,
NewLineCharacter: "\n",
ConvertTabsToSpaces: true
ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces
};
var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
for (var i = 0, len = lineText.length; i < len; i++) {
@ -35927,6 +35988,11 @@ var ts;
response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file);
break;
}
case CommandNames.TypeDefinition: {
var defArgs = request.arguments;
response = this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file);
break;
}
case CommandNames.References: {
var refArgs = request.arguments;
response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file);
@ -36654,6 +36720,7 @@ var ts;
if (content !== undefined) {
var indentSize;
info = new ScriptInfo(this.host, fileName, content, openedByClient);
info.setFormatOptions(this.getFormatCodeOptions());
this.filenameToScriptInfo[fileName] = info;
if (!info.isOpen) {
info.fileWatcher = this.host.watchFile(fileName, function (_) { _this.watchedFileChanged(fileName); });
@ -36670,7 +36737,7 @@ var ts;
ProjectService.prototype.findConfigFile = function (searchPath) {
while (true) {
var fileName = ts.combinePaths(searchPath, "tsconfig.json");
if (ts.sys.fileExists(fileName)) {
if (this.host.fileExists(fileName)) {
return fileName;
}
var parentPath = ts.getDirectoryPath(searchPath);
@ -36803,7 +36870,7 @@ var ts;
var proj = this.createProject(configFilename, projectOptions);
for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) {
var rootFilename = parsedCommandLine.fileNames[i];
if (ts.sys.fileExists(rootFilename)) {
if (this.host.fileExists(rootFilename)) {
var info = this.openFile(rootFilename, clientFileName == rootFilename);
proj.addRoot(info);
}

34
bin/typescript.d.ts vendored
View file

@ -1094,6 +1094,7 @@ declare module "typescript" {
locale?: string;
mapRoot?: string;
module?: ModuleKind;
newLine?: NewLineKind;
noEmit?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
@ -1124,6 +1125,10 @@ declare module "typescript" {
UMD = 3,
System = 4,
}
const enum NewLineKind {
CarriageReturnLineFeed = 0,
LineFeed = 1,
}
interface LineAndCharacter {
line: number;
character: number;
@ -1186,6 +1191,32 @@ declare module "typescript" {
var sys: System;
}
declare module "typescript" {
interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
}
interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
getTextPos(): number;
getTokenPos(): number;
getTokenText(): string;
getTokenValue(): string;
hasExtendedUnicodeEscape(): boolean;
hasPrecedingLineBreak(): boolean;
isIdentifier(): boolean;
isReservedWord(): boolean;
isUnterminated(): boolean;
reScanGreaterToken(): SyntaxKind;
reScanSlashToken(): SyntaxKind;
reScanTemplateToken(): SyntaxKind;
scan(): SyntaxKind;
setText(text: string, start?: number, length?: number): void;
setOnError(onError: ErrorCallback): void;
setScriptTarget(scriptTarget: ScriptTarget): void;
setTextPos(textPos: number): void;
lookAhead<T>(callback: () => T): T;
tryScan<T>(callback: () => T): T;
}
function tokenToString(t: SyntaxKind): string;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
@ -1195,6 +1226,8 @@ declare module "typescript" {
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
}
declare module "typescript" {
function getDefaultLibFileName(options: CompilerOptions): string;
@ -1381,6 +1414,7 @@ declare module "typescript" {
getRenameInfo(fileName: string, position: number): RenameInfo;
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];

View file

@ -547,6 +547,11 @@ var ts;
ModuleKind[ModuleKind["System"] = 4] = "System";
})(ts.ModuleKind || (ts.ModuleKind = {}));
var ModuleKind = ts.ModuleKind;
(function (NewLineKind) {
NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed";
NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed";
})(ts.NewLineKind || (ts.NewLineKind = {}));
var NewLineKind = ts.NewLineKind;
(function (ScriptTarget) {
ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3";
ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5";
@ -1137,7 +1142,7 @@ var ts;
for (var _i = 0; _i < parts.length; _i++) {
var part = parts[_i];
if (part !== ".") {
if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") {
normalized.pop();
}
else {
@ -1244,7 +1249,7 @@ var ts;
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") {
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
directoryComponents.length--;
@ -2154,6 +2159,9 @@ var ts;
Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -2652,7 +2660,7 @@ var ts;
}
collecting = true;
if (result && result.length) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
continue;
case 9 /* tab */:
@ -2698,7 +2706,7 @@ var ts;
default:
if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) {
if (result && result.length && isLineBreak(ch)) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
pos++;
continue;
@ -2728,8 +2736,7 @@ var ts;
ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
}
ts.isIdentifierPart = isIdentifierPart;
// Creates a scanner over a (possibly unspecified) range of a piece of text.
/* @internal */
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
function createScanner(languageVersion, skipTrivia, text, onError, start, length) {
var pos; // Current position (end position of text of current token)
var end; // end of text
@ -4924,7 +4931,7 @@ var ts;
}
ts.hasQuestionToken = hasQuestionToken;
function hasRestParameters(s) {
return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined;
return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined;
}
ts.hasRestParameters = hasRestParameters;
function isLiteralKind(kind) {
@ -5388,7 +5395,7 @@ var ts;
var lineStartsOfS = ts.computeLineStarts(s);
if (lineStartsOfS.length > 1) {
lineCount = lineCount + lineStartsOfS.length - 1;
linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS);
}
}
}
@ -5457,8 +5464,10 @@ var ts;
ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
function shouldEmitToOwnFile(sourceFile, compilerOptions) {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) {
return true;
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
// 1. in-browser single file compilation scenario
// 2. non .js file
return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js");
}
return false;
}
@ -7465,7 +7474,7 @@ var ts;
templateSpans.pos = getNodePos();
do {
templateSpans.push(parseTemplateSpan());
} while (templateSpans[templateSpans.length - 1].literal.kind === 12 /* TemplateMiddle */);
} while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */);
templateSpans.end = getNodeEnd();
template.templateSpans = templateSpans;
return finishNode(template);
@ -13656,7 +13665,7 @@ var ts;
}
function getRestTypeOfSignature(signature) {
if (signature.hasRestParameter) {
var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters));
if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) {
return type.typeArguments[0];
}
@ -15965,7 +15974,7 @@ var ts;
// If last parameter is contextually rest parameter get its type
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]);
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
}
@ -17366,9 +17375,9 @@ var ts;
links.type = instantiateType(getTypeAtPosition(context, i), mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
var parameter = signature.parameters[signature.parameters.length - 1];
var parameter = ts.lastOrUndefined(signature.parameters);
var links = getSymbolLinks(parameter);
links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper);
links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper);
}
}
function getReturnTypeFromBody(func, contextualMapper) {
@ -22381,7 +22390,7 @@ var ts;
function checkGrammarBindingElement(node) {
if (node.dotDotDotToken) {
var elements = node.parent.elements;
if (node !== elements[elements.length - 1]) {
if (node !== ts.lastOrUndefined(elements)) {
return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
}
if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) {
@ -24373,7 +24382,7 @@ var ts;
var sourceMapNameIndexMap = {};
var sourceMapNameIndices = [];
function getSourceMapNameIndex() {
return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1;
return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1;
}
// Last recorded and encoded spans
var lastRecordedSourceMapSpan;
@ -27145,11 +27154,11 @@ var ts;
emitNodeWithoutSourceMap(memberName);
}
}
function getInitializedProperties(node, static) {
function getInitializedProperties(node, isStatic) {
var properties = [];
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if (member.kind === 133 /* PropertyDeclaration */ && static === ((member.flags & 128 /* Static */) !== 0) && member.initializer) {
if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) {
properties.push(member);
}
}
@ -29368,11 +29377,11 @@ var ts;
}
}
function hasDetachedComments(pos) {
return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos;
return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos;
}
function getLeadingCommentsWithoutDetachedComments() {
// get the leading comments from detachedPos
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos);
if (detachedCommentsInfo.length - 1) {
detachedCommentsInfo.pop();
}
@ -29473,13 +29482,13 @@ var ts;
// All comments look like they could have been part of the copyright header. Make
// sure there is at least one blank line between it and the node. If not, it's not
// a copyright header.
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end);
var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
if (nodeLine >= lastCommentLine + 2) {
// Valid detachedComments
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment);
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end };
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end };
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
}
@ -29521,6 +29530,8 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
ts.version = "1.5.0";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -29594,6 +29605,9 @@ var ts;
}
}
}
var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed :
options.newLine === 1 /* LineFeed */ ? lineFeed :
ts.sys.newLine;
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -29601,7 +29615,7 @@ var ts;
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
getCanonicalFileName: getCanonicalFileName,
getNewLine: function () { return ts.sys.newLine; }
getNewLine: function () { return newLine; }
};
}
ts.createCompilerHost = createCompilerHost;
@ -30119,6 +30133,16 @@ var ts;
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
},
{
name: "newLine",
type: {
"crlf": 0 /* CarriageReturnLineFeed */,
"lf": 1 /* LineFeed */
},
description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
paramType: ts.Diagnostics.NEWLINE,
error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
},
{
name: "noEmit",
type: "boolean",
@ -32529,7 +32553,7 @@ var ts;
function nodeEndsWith(n, expectedLastToken, sourceFile) {
var children = n.getChildren(sourceFile);
if (children.length) {
var last = children[children.length - 1];
var last = ts.lastOrUndefined(children);
if (last.kind === expectedLastToken) {
return true;
}
@ -33023,7 +33047,7 @@ var ts;
if (isStarted) {
if (trailingTrivia) {
ts.Debug.assert(trailingTrivia.length !== 0);
wasNewLine = trailingTrivia[trailingTrivia.length - 1].kind === 4 /* NewLineTrivia */;
wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */;
}
else {
wasNewLine = false;
@ -34482,6 +34506,8 @@ var ts;
var previousRange;
var previousParent;
var previousRangeStartLine;
var lastIndentedLine;
var indentationOnLastIndentedLine;
var edits = [];
formattingScanner.advance();
if (formattingScanner.isOnToken()) {
@ -34551,7 +34577,9 @@ var ts;
// if node is located on the same line with the parent
// - inherit indentation from the parent
// - push children if either parent of node itself has non-zero delta
indentation = parentDynamicIndentation.getIndentation();
indentation = startLine === lastIndentedLine
? indentationOnLastIndentedLine
: parentDynamicIndentation.getIndentation();
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
}
return {
@ -34799,7 +34827,6 @@ var ts;
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
continue;
}
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
switch (triviaItem.kind) {
case 3 /* MultiLineCommentTrivia */:
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
@ -34823,6 +34850,8 @@ var ts;
if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
}
}
formattingScanner.advance();
@ -38055,22 +38084,6 @@ var ts;
}
return ScriptElementKind.unknown;
}
function getTypeKind(type) {
var flags = type.getFlags();
if (flags & 128 /* Enum */)
return ScriptElementKind.enumElement;
if (flags & 1024 /* Class */)
return ScriptElementKind.classElement;
if (flags & 2048 /* Interface */)
return ScriptElementKind.interfaceElement;
if (flags & 512 /* TypeParameter */)
return ScriptElementKind.typeParameterElement;
if (flags & 1048703 /* Intrinsic */)
return ScriptElementKind.primitiveType;
if (flags & 256 /* StringLiteral */)
return ScriptElementKind.primitiveType;
return ScriptElementKind.unknown;
}
function getSymbolModifiers(symbol) {
return symbol && symbol.declarations && symbol.declarations.length > 0
? ts.getNodeModifiers(symbol.declarations[0])
@ -38453,6 +38466,62 @@ var ts;
containerName: containerName
};
}
function getDefinitionFromSymbol(symbol, node) {
var typeChecker = program.getTypeChecker();
var result = [];
var declarations = symbol.getDeclarations();
var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
// Just add all the declarations.
ts.forEach(declarations, function (declaration) {
result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName));
});
}
return result;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
}
}
return false;
}
function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) {
return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result);
}
return false;
}
function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) {
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
if ((selectConstructors && d.kind === 136 /* Constructor */) ||
(!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) {
declarations.push(d);
if (d.body)
definition = d;
}
});
if (definition) {
result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName));
return true;
}
else if (declarations.length) {
result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName));
return true;
}
return false;
}
}
/// Goto definition
function getDefinitionAtPosition(fileName, position) {
synchronizeHostData();
@ -38516,59 +38585,38 @@ var ts;
var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); });
}
var result = [];
var declarations = symbol.getDeclarations();
var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
// Just add all the declarations.
ts.forEach(declarations, function (declaration) {
result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName));
});
return getDefinitionFromSymbol(symbol, node);
}
/// Goto type
function getTypeDefinitionAtPosition(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
var node = ts.getTouchingPropertyName(sourceFile, position);
if (!node) {
return undefined;
}
return result;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
}
}
return false;
var typeChecker = program.getTypeChecker();
var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
return undefined;
}
function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) {
return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result);
}
return false;
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
if (!type) {
return undefined;
}
function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) {
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
if ((selectConstructors && d.kind === 136 /* Constructor */) ||
(!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) {
declarations.push(d);
if (d.body)
definition = d;
if (type.flags & 16384 /* Union */) {
var result = [];
ts.forEach(type.types, function (t) {
if (t.symbol) {
result.push.apply(result, getDefinitionFromSymbol(t.symbol, node));
}
});
if (definition) {
result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName));
return true;
}
else if (declarations.length) {
result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName));
return true;
}
return false;
return result;
}
if (!type.symbol) {
return undefined;
}
return getDefinitionFromSymbol(type.symbol, node);
}
function getOccurrencesAtPosition(fileName, position) {
var results = getOccurrencesAtPositionCore(fileName, position);
@ -40613,6 +40661,7 @@ var ts;
getSignatureHelpItems: getSignatureHelpItems,
getQuickInfoAtPosition: getQuickInfoAtPosition,
getDefinitionAtPosition: getDefinitionAtPosition,
getTypeDefinitionAtPosition: getTypeDefinitionAtPosition,
getReferencesAtPosition: getReferencesAtPosition,
findReferences: findReferences,
getOccurrencesAtPosition: getOccurrencesAtPosition,
@ -41498,14 +41547,14 @@ var ts;
}
// fall through.
case 224 /* CatchClause */:
return spanInNode(node.parent.statements[node.parent.statements.length - 1]);
return spanInNode(ts.lastOrUndefined(node.parent.statements));
;
case 208 /* CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1];
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
if (lastClause) {
return spanInNode(lastClause.statements[lastClause.statements.length - 1]);
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
// Default to parent node
@ -41909,6 +41958,17 @@ var ts;
return _this.languageService.getDefinitionAtPosition(fileName, position);
});
};
/// GOTO Type
/**
* Computes the definition location of the type of the symbol
* at the requested position.
*/
LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) {
var _this = this;
return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () {
return _this.languageService.getTypeDefinitionAtPosition(fileName, position);
});
};
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) {
var _this = this;
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () {

View file

@ -1094,6 +1094,7 @@ declare module ts {
locale?: string;
mapRoot?: string;
module?: ModuleKind;
newLine?: NewLineKind;
noEmit?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
@ -1124,6 +1125,10 @@ declare module ts {
UMD = 3,
System = 4,
}
const enum NewLineKind {
CarriageReturnLineFeed = 0,
LineFeed = 1,
}
interface LineAndCharacter {
line: number;
character: number;
@ -1186,6 +1191,32 @@ declare module ts {
var sys: System;
}
declare module ts {
interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
}
interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
getTextPos(): number;
getTokenPos(): number;
getTokenText(): string;
getTokenValue(): string;
hasExtendedUnicodeEscape(): boolean;
hasPrecedingLineBreak(): boolean;
isIdentifier(): boolean;
isReservedWord(): boolean;
isUnterminated(): boolean;
reScanGreaterToken(): SyntaxKind;
reScanSlashToken(): SyntaxKind;
reScanTemplateToken(): SyntaxKind;
scan(): SyntaxKind;
setText(text: string, start?: number, length?: number): void;
setOnError(onError: ErrorCallback): void;
setScriptTarget(scriptTarget: ScriptTarget): void;
setTextPos(textPos: number): void;
lookAhead<T>(callback: () => T): T;
tryScan<T>(callback: () => T): T;
}
function tokenToString(t: SyntaxKind): string;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
@ -1195,6 +1226,8 @@ declare module ts {
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
}
declare module ts {
function getDefaultLibFileName(options: CompilerOptions): string;
@ -1381,6 +1414,7 @@ declare module ts {
getRenameInfo(fileName: string, position: number): RenameInfo;
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];

View file

@ -547,6 +547,11 @@ var ts;
ModuleKind[ModuleKind["System"] = 4] = "System";
})(ts.ModuleKind || (ts.ModuleKind = {}));
var ModuleKind = ts.ModuleKind;
(function (NewLineKind) {
NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed";
NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed";
})(ts.NewLineKind || (ts.NewLineKind = {}));
var NewLineKind = ts.NewLineKind;
(function (ScriptTarget) {
ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3";
ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5";
@ -1137,7 +1142,7 @@ var ts;
for (var _i = 0; _i < parts.length; _i++) {
var part = parts[_i];
if (part !== ".") {
if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") {
normalized.pop();
}
else {
@ -1244,7 +1249,7 @@ var ts;
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") {
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
directoryComponents.length--;
@ -2154,6 +2159,9 @@ var ts;
Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -2652,7 +2660,7 @@ var ts;
}
collecting = true;
if (result && result.length) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
continue;
case 9 /* tab */:
@ -2698,7 +2706,7 @@ var ts;
default:
if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) {
if (result && result.length && isLineBreak(ch)) {
result[result.length - 1].hasTrailingNewLine = true;
ts.lastOrUndefined(result).hasTrailingNewLine = true;
}
pos++;
continue;
@ -2728,8 +2736,7 @@ var ts;
ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
}
ts.isIdentifierPart = isIdentifierPart;
// Creates a scanner over a (possibly unspecified) range of a piece of text.
/* @internal */
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
function createScanner(languageVersion, skipTrivia, text, onError, start, length) {
var pos; // Current position (end position of text of current token)
var end; // end of text
@ -4924,7 +4931,7 @@ var ts;
}
ts.hasQuestionToken = hasQuestionToken;
function hasRestParameters(s) {
return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined;
return s.parameters.length > 0 && ts.lastOrUndefined(s.parameters).dotDotDotToken !== undefined;
}
ts.hasRestParameters = hasRestParameters;
function isLiteralKind(kind) {
@ -5388,7 +5395,7 @@ var ts;
var lineStartsOfS = ts.computeLineStarts(s);
if (lineStartsOfS.length > 1) {
lineCount = lineCount + lineStartsOfS.length - 1;
linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS);
}
}
}
@ -5457,8 +5464,10 @@ var ts;
ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
function shouldEmitToOwnFile(sourceFile, compilerOptions) {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.fileName, ".js")) {
return true;
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
// 1. in-browser single file compilation scenario
// 2. non .js file
return compilerOptions.separateCompilation || !ts.fileExtensionIs(sourceFile.fileName, ".js");
}
return false;
}
@ -7465,7 +7474,7 @@ var ts;
templateSpans.pos = getNodePos();
do {
templateSpans.push(parseTemplateSpan());
} while (templateSpans[templateSpans.length - 1].literal.kind === 12 /* TemplateMiddle */);
} while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */);
templateSpans.end = getNodeEnd();
template.templateSpans = templateSpans;
return finishNode(template);
@ -13656,7 +13665,7 @@ var ts;
}
function getRestTypeOfSignature(signature) {
if (signature.hasRestParameter) {
var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters));
if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) {
return type.typeArguments[0];
}
@ -15965,7 +15974,7 @@ var ts;
// If last parameter is contextually rest parameter get its type
if (indexOfParameter === (func.parameters.length - 1) &&
funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]);
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
}
@ -17366,9 +17375,9 @@ var ts;
links.type = instantiateType(getTypeAtPosition(context, i), mapper);
}
if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
var parameter = signature.parameters[signature.parameters.length - 1];
var parameter = ts.lastOrUndefined(signature.parameters);
var links = getSymbolLinks(parameter);
links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper);
links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper);
}
}
function getReturnTypeFromBody(func, contextualMapper) {
@ -22381,7 +22390,7 @@ var ts;
function checkGrammarBindingElement(node) {
if (node.dotDotDotToken) {
var elements = node.parent.elements;
if (node !== elements[elements.length - 1]) {
if (node !== ts.lastOrUndefined(elements)) {
return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
}
if (node.name.kind === 152 /* ArrayBindingPattern */ || node.name.kind === 151 /* ObjectBindingPattern */) {
@ -24373,7 +24382,7 @@ var ts;
var sourceMapNameIndexMap = {};
var sourceMapNameIndices = [];
function getSourceMapNameIndex() {
return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1;
return sourceMapNameIndices.length ? ts.lastOrUndefined(sourceMapNameIndices) : -1;
}
// Last recorded and encoded spans
var lastRecordedSourceMapSpan;
@ -27145,11 +27154,11 @@ var ts;
emitNodeWithoutSourceMap(memberName);
}
}
function getInitializedProperties(node, static) {
function getInitializedProperties(node, isStatic) {
var properties = [];
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if (member.kind === 133 /* PropertyDeclaration */ && static === ((member.flags & 128 /* Static */) !== 0) && member.initializer) {
if (member.kind === 133 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) {
properties.push(member);
}
}
@ -29368,11 +29377,11 @@ var ts;
}
}
function hasDetachedComments(pos) {
return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos;
return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos;
}
function getLeadingCommentsWithoutDetachedComments() {
// get the leading comments from detachedPos
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos);
if (detachedCommentsInfo.length - 1) {
detachedCommentsInfo.pop();
}
@ -29473,13 +29482,13 @@ var ts;
// All comments look like they could have been part of the copyright header. Make
// sure there is at least one blank line between it and the node. If not, it's not
// a copyright header.
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end);
var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
if (nodeLine >= lastCommentLine + 2) {
// Valid detachedComments
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment);
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end };
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end };
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
}
@ -29521,6 +29530,8 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
ts.version = "1.5.0";
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@ -29594,6 +29605,9 @@ var ts;
}
}
}
var newLine = options.newLine === 0 /* CarriageReturnLineFeed */ ? carriageReturnLineFeed :
options.newLine === 1 /* LineFeed */ ? lineFeed :
ts.sys.newLine;
return {
getSourceFile: getSourceFile,
getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
@ -29601,7 +29615,7 @@ var ts;
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
getCanonicalFileName: getCanonicalFileName,
getNewLine: function () { return ts.sys.newLine; }
getNewLine: function () { return newLine; }
};
}
ts.createCompilerHost = createCompilerHost;
@ -30119,6 +30133,16 @@ var ts;
paramType: ts.Diagnostics.KIND,
error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
},
{
name: "newLine",
type: {
"crlf": 0 /* CarriageReturnLineFeed */,
"lf": 1 /* LineFeed */
},
description: ts.Diagnostics.Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
paramType: ts.Diagnostics.NEWLINE,
error: ts.Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
},
{
name: "noEmit",
type: "boolean",
@ -32529,7 +32553,7 @@ var ts;
function nodeEndsWith(n, expectedLastToken, sourceFile) {
var children = n.getChildren(sourceFile);
if (children.length) {
var last = children[children.length - 1];
var last = ts.lastOrUndefined(children);
if (last.kind === expectedLastToken) {
return true;
}
@ -33023,7 +33047,7 @@ var ts;
if (isStarted) {
if (trailingTrivia) {
ts.Debug.assert(trailingTrivia.length !== 0);
wasNewLine = trailingTrivia[trailingTrivia.length - 1].kind === 4 /* NewLineTrivia */;
wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */;
}
else {
wasNewLine = false;
@ -34482,6 +34506,8 @@ var ts;
var previousRange;
var previousParent;
var previousRangeStartLine;
var lastIndentedLine;
var indentationOnLastIndentedLine;
var edits = [];
formattingScanner.advance();
if (formattingScanner.isOnToken()) {
@ -34551,7 +34577,9 @@ var ts;
// if node is located on the same line with the parent
// - inherit indentation from the parent
// - push children if either parent of node itself has non-zero delta
indentation = parentDynamicIndentation.getIndentation();
indentation = startLine === lastIndentedLine
? indentationOnLastIndentedLine
: parentDynamicIndentation.getIndentation();
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
}
return {
@ -34799,7 +34827,6 @@ var ts;
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
continue;
}
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
switch (triviaItem.kind) {
case 3 /* MultiLineCommentTrivia */:
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
@ -34823,6 +34850,8 @@ var ts;
if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
}
}
formattingScanner.advance();
@ -38055,22 +38084,6 @@ var ts;
}
return ScriptElementKind.unknown;
}
function getTypeKind(type) {
var flags = type.getFlags();
if (flags & 128 /* Enum */)
return ScriptElementKind.enumElement;
if (flags & 1024 /* Class */)
return ScriptElementKind.classElement;
if (flags & 2048 /* Interface */)
return ScriptElementKind.interfaceElement;
if (flags & 512 /* TypeParameter */)
return ScriptElementKind.typeParameterElement;
if (flags & 1048703 /* Intrinsic */)
return ScriptElementKind.primitiveType;
if (flags & 256 /* StringLiteral */)
return ScriptElementKind.primitiveType;
return ScriptElementKind.unknown;
}
function getSymbolModifiers(symbol) {
return symbol && symbol.declarations && symbol.declarations.length > 0
? ts.getNodeModifiers(symbol.declarations[0])
@ -38453,6 +38466,62 @@ var ts;
containerName: containerName
};
}
function getDefinitionFromSymbol(symbol, node) {
var typeChecker = program.getTypeChecker();
var result = [];
var declarations = symbol.getDeclarations();
var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
// Just add all the declarations.
ts.forEach(declarations, function (declaration) {
result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName));
});
}
return result;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
}
}
return false;
}
function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) {
return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result);
}
return false;
}
function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) {
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
if ((selectConstructors && d.kind === 136 /* Constructor */) ||
(!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) {
declarations.push(d);
if (d.body)
definition = d;
}
});
if (definition) {
result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName));
return true;
}
else if (declarations.length) {
result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName));
return true;
}
return false;
}
}
/// Goto definition
function getDefinitionAtPosition(fileName, position) {
synchronizeHostData();
@ -38516,59 +38585,38 @@ var ts;
var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); });
}
var result = [];
var declarations = symbol.getDeclarations();
var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
// Just add all the declarations.
ts.forEach(declarations, function (declaration) {
result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName));
});
return getDefinitionFromSymbol(symbol, node);
}
/// Goto type
function getTypeDefinitionAtPosition(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
var node = ts.getTouchingPropertyName(sourceFile, position);
if (!node) {
return undefined;
}
return result;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
var classDeclaration = symbol.getDeclarations()[0];
ts.Debug.assert(classDeclaration && classDeclaration.kind === 202 /* ClassDeclaration */);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
}
}
return false;
var typeChecker = program.getTypeChecker();
var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
return undefined;
}
function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) {
if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) {
return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result);
}
return false;
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
if (!type) {
return undefined;
}
function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) {
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
if ((selectConstructors && d.kind === 136 /* Constructor */) ||
(!selectConstructors && (d.kind === 201 /* FunctionDeclaration */ || d.kind === 135 /* MethodDeclaration */ || d.kind === 134 /* MethodSignature */))) {
declarations.push(d);
if (d.body)
definition = d;
if (type.flags & 16384 /* Union */) {
var result = [];
ts.forEach(type.types, function (t) {
if (t.symbol) {
result.push.apply(result, getDefinitionFromSymbol(t.symbol, node));
}
});
if (definition) {
result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName));
return true;
}
else if (declarations.length) {
result.push(createDefinitionInfo(declarations[declarations.length - 1], symbolKind, symbolName, containerName));
return true;
}
return false;
return result;
}
if (!type.symbol) {
return undefined;
}
return getDefinitionFromSymbol(type.symbol, node);
}
function getOccurrencesAtPosition(fileName, position) {
var results = getOccurrencesAtPositionCore(fileName, position);
@ -40613,6 +40661,7 @@ var ts;
getSignatureHelpItems: getSignatureHelpItems,
getQuickInfoAtPosition: getQuickInfoAtPosition,
getDefinitionAtPosition: getDefinitionAtPosition,
getTypeDefinitionAtPosition: getTypeDefinitionAtPosition,
getReferencesAtPosition: getReferencesAtPosition,
findReferences: findReferences,
getOccurrencesAtPosition: getOccurrencesAtPosition,
@ -41498,14 +41547,14 @@ var ts;
}
// fall through.
case 224 /* CatchClause */:
return spanInNode(node.parent.statements[node.parent.statements.length - 1]);
return spanInNode(ts.lastOrUndefined(node.parent.statements));
;
case 208 /* CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = caseBlock.clauses[caseBlock.clauses.length - 1];
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
if (lastClause) {
return spanInNode(lastClause.statements[lastClause.statements.length - 1]);
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
// Default to parent node
@ -41909,6 +41958,17 @@ var ts;
return _this.languageService.getDefinitionAtPosition(fileName, position);
});
};
/// GOTO Type
/**
* Computes the definition location of the type of the symbol
* at the requested position.
*/
LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) {
var _this = this;
return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () {
return _this.languageService.getTypeDefinitionAtPosition(fileName, position);
});
};
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) {
var _this = this;
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () {

View file

@ -88,12 +88,11 @@ module ts {
let undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined");
let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null");
let unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
let resolvingType = createIntrinsicType(TypeFlags.Any, "__resolving__");
let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false);
let unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false);
@ -118,7 +117,7 @@ module ts {
let getGlobalParameterDecoratorType: () => ObjectType;
let getGlobalPropertyDecoratorType: () => ObjectType;
let getGlobalMethodDecoratorType: () => ObjectType;
let tupleTypes: Map<TupleType> = {};
let unionTypes: Map<UnionType> = {};
let stringLiteralTypes: Map<StringLiteralType> = {};
@ -126,6 +125,9 @@ module ts {
let emitDecorate = false;
let emitParam = false;
let resolutionTargets: Object[] = [];
let resolutionResults: boolean[] = [];
let mergedSymbols: Symbol[] = [];
let symbolLinks: SymbolLinks[] = [];
let nodeLinks: NodeLinks[] = [];
@ -350,9 +352,9 @@ module ts {
}
else if (location.kind === SyntaxKind.SourceFile ||
(location.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>location).name.kind === SyntaxKind.StringLiteral)) {
result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & SymbolFlags.ModuleMember);
result = getSymbolOfNode(location).exports["default"];
let localSymbol = getLocalSymbolForExportDefault(result);
if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) {
if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) {
break loop;
}
result = undefined;
@ -1980,7 +1982,7 @@ module ts {
}
}
function collectLinkedAliases(node: Identifier): Node[]{
function collectLinkedAliases(node: Identifier): Node[] {
var exportSymbol: Symbol;
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node);
@ -2014,6 +2016,38 @@ module ts {
}
}
// Push an entry on the type resolution stack. If an entry with the given target is not already on the stack,
// a new entry with that target and an associated result value of true is pushed on the stack, and the value
// true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and
// all entries pushed after it are changed to false, and the value false is returned. The target object provides
// a unique identity for a particular type resolution result: Symbol instances are used to track resolution of
// SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and
// Signature instances are used to track resolution of Signature.resolvedReturnType.
function pushTypeResolution(target: Object): boolean {
let i = 0;
let count = resolutionTargets.length;
while (i < count && resolutionTargets[i] !== target) {
i++;
}
if (i < count) {
do {
resolutionResults[i++] = false;
}
while (i < count);
return false;
}
resolutionTargets.push(target);
resolutionResults.push(true);
return true;
}
// Pop an entry from the type resolution stack and return its associated result value. The result value will
// be true if no circularities were detected, or false if a circularity was found.
function popTypeResolution(): boolean {
resolutionTargets.pop();
return resolutionResults.pop();
}
function getRootDeclaration(node: Node): Node {
while (node.kind === SyntaxKind.BindingElement) {
node = node.parent.parent;
@ -2271,20 +2305,27 @@ module ts {
return links.type = checkExpression((<ExportAssignment>declaration).expression);
}
// Handle variable, parameter or property
links.type = resolvingType;
if (!pushTypeResolution(symbol)) {
return unknownType;
}
let type = getWidenedTypeForVariableLikeDeclaration(<VariableLikeDeclaration>declaration, /*reportErrors*/ true);
if (links.type === resolvingType) {
links.type = type;
}
}
else if (links.type === resolvingType) {
links.type = anyType;
if (compilerOptions.noImplicitAny) {
let diagnostic = (<VariableLikeDeclaration>symbol.valueDeclaration).type ?
Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation :
Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer;
error(symbol.valueDeclaration, diagnostic, symbolToString(symbol));
if (!popTypeResolution()) {
if ((<VariableLikeDeclaration>symbol.valueDeclaration).type) {
// Variable has type annotation that circularly references the variable itself
type = unknownType;
error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation,
symbolToString(symbol));
}
else {
// Variable has initializer that circularly references the variable itself
type = anyType;
if (compilerOptions.noImplicitAny) {
error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer,
symbolToString(symbol));
}
}
}
links.type = type;
}
return links.type;
}
@ -2308,19 +2349,13 @@ module ts {
function getTypeOfAccessors(symbol: Symbol): Type {
let links = getSymbolLinks(symbol);
checkAndStoreTypeOfAccessors(symbol, links);
return links.type;
}
function checkAndStoreTypeOfAccessors(symbol: Symbol, links?: SymbolLinks) {
links = links || getSymbolLinks(symbol);
if (!links.type) {
links.type = resolvingType;
if (!pushTypeResolution(symbol)) {
return unknownType;
}
let getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
let setter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.SetAccessor);
let type: Type;
// First try to see if the user specified a return type on the get-accessor.
let getterReturnType = getAnnotatedAccessorType(getter);
if (getterReturnType) {
@ -2342,23 +2377,20 @@ module ts {
if (compilerOptions.noImplicitAny) {
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol));
}
type = anyType;
}
}
}
if (links.type === resolvingType) {
links.type = type;
}
}
else if (links.type === resolvingType) {
links.type = anyType;
if (compilerOptions.noImplicitAny) {
let getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
if (!popTypeResolution()) {
type = anyType;
if (compilerOptions.noImplicitAny) {
let getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
}
}
links.type = type;
}
return links.type;
}
function getTypeOfFuncClassEnumModule(symbol: Symbol): Type {
@ -2451,7 +2483,7 @@ module ts {
return result;
}
function getBaseTypes(type: InterfaceType): ObjectType[]{
function getBaseTypes(type: InterfaceType): ObjectType[] {
let typeWithBaseTypes = <InterfaceTypeWithBaseTypes>type;
if (!typeWithBaseTypes.baseTypes) {
if (type.symbol.flags & SymbolFlags.Class) {
@ -2536,17 +2568,18 @@ module ts {
function getDeclaredTypeOfTypeAlias(symbol: Symbol): Type {
let links = getSymbolLinks(symbol);
if (!links.declaredType) {
links.declaredType = resolvingType;
// Note that we use the links object as the target here because the symbol object is used as the unique
// identity for resolution of the 'type' property in SymbolLinks.
if (!pushTypeResolution(links)) {
return unknownType;
}
let declaration = <TypeAliasDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration);
let type = getTypeFromTypeNode(declaration.type);
if (links.declaredType === resolvingType) {
links.declaredType = type;
if (!popTypeResolution()) {
type = unknownType;
error(declaration.name, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
}
}
else if (links.declaredType === resolvingType) {
links.declaredType = unknownType;
let declaration = <TypeAliasDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration);
error(declaration.name, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
links.declaredType = type;
}
return links.declaredType;
}
@ -3150,7 +3183,9 @@ module ts {
function getReturnTypeOfSignature(signature: Signature): Type {
if (!signature.resolvedReturnType) {
signature.resolvedReturnType = resolvingType;
if (!pushTypeResolution(signature)) {
return unknownType;
}
let type: Type;
if (signature.target) {
type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper);
@ -3161,21 +3196,19 @@ module ts {
else {
type = getReturnTypeFromBody(<FunctionLikeDeclaration>signature.declaration);
}
if (signature.resolvedReturnType === resolvingType) {
signature.resolvedReturnType = type;
}
}
else if (signature.resolvedReturnType === resolvingType) {
signature.resolvedReturnType = anyType;
if (compilerOptions.noImplicitAny) {
let declaration = <Declaration>signature.declaration;
if (declaration.name) {
error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(declaration.name));
}
else {
error(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
if (!popTypeResolution()) {
type = anyType;
if (compilerOptions.noImplicitAny) {
let declaration = <Declaration>signature.declaration;
if (declaration.name) {
error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(declaration.name));
}
else {
error(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
}
}
}
signature.resolvedReturnType = type;
}
return signature.resolvedReturnType;
}
@ -7342,10 +7375,9 @@ module ts {
if (isContextSensitive(node)) {
assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper);
}
if (!node.type) {
signature.resolvedReturnType = resolvingType;
if (!node.type && !signature.resolvedReturnType) {
let returnType = getReturnTypeFromBody(node, contextualMapper);
if (signature.resolvedReturnType === resolvingType) {
if (!signature.resolvedReturnType) {
signature.resolvedReturnType = returnType;
}
}
@ -8359,8 +8391,7 @@ module ts {
}
}
}
checkAndStoreTypeOfAccessors(getSymbolOfNode(node));
getTypeOfAccessors(getSymbolOfNode(node));
}
checkFunctionLikeDeclaration(node);

View file

@ -363,6 +363,7 @@ module ts {
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." },
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." },
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." },
_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@ -517,7 +518,6 @@ module ts {
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." },
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." },
_0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." },
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },

View file

@ -1440,6 +1440,10 @@
"category": "Error",
"code": 2501
},
"'{0}' is referenced directly or indirectly in its own type annotation.": {
"category": "Error",
"code": 2502
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@ -2060,10 +2064,6 @@
"category": "Error",
"code": 7020
},
"'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.": {
"category": "Error",
"code": 7021
},
"'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
"category": "Error",
"code": 7022

File diff suppressed because it is too large Load diff

View file

@ -1442,8 +1442,10 @@ module ts {
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.fileName, ".js")) {
return true;
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
// 1. in-browser single file compilation scenario
// 2. non .js file
return compilerOptions.separateCompilation || !fileExtensionIs(sourceFile.fileName, ".js");
}
return false;
}
@ -1700,7 +1702,7 @@ module ts {
}
export function getLocalSymbolForExportDefault(symbol: Symbol) {
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
}
/**

View file

@ -1610,7 +1610,6 @@ module Harness {
export module Baseline {
export interface BaselineOptions {
LineEndingSensitive?: boolean;
Subfolder?: string;
Baselinefolder?: string;
}
@ -1702,13 +1701,6 @@ module Harness {
expected = IO.readFile(refFileName);
}
var lineEndingSensitive = opts && opts.LineEndingSensitive;
if (!lineEndingSensitive) {
expected = expected.replace(/\r\n?/g, '\n');
actual = actual.replace(/\r\n?/g, '\n');
}
return { expected, actual };
}

View file

@ -12180,6 +12180,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
overrideMimeType(mime: string): void;
send(data?: Document): void;
send(data?: string): void;
send(data?: any): void;
setRequestHeader(header: string, value: string): void;
DONE: number;
HEADERS_RECEIVED: number;

View file

@ -0,0 +1,28 @@
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(1,6): error TS2456: Type alias 'typeAlias1' circularly references itself.
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(2,5): error TS2502: 'varOfAliasedType1' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(4,5): error TS2502: 'varOfAliasedType2' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(5,6): error TS2456: Type alias 'typeAlias2' circularly references itself.
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(9,6): error TS2456: Type alias 'typeAlias3' circularly references itself.
==== tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts (5 errors) ====
type typeAlias1 = typeof varOfAliasedType1;
~~~~~~~~~~
!!! error TS2456: Type alias 'typeAlias1' circularly references itself.
var varOfAliasedType1: typeAlias1;
~~~~~~~~~~~~~~~~~
!!! error TS2502: 'varOfAliasedType1' is referenced directly or indirectly in its own type annotation.
var varOfAliasedType2: typeAlias2;
~~~~~~~~~~~~~~~~~
!!! error TS2502: 'varOfAliasedType2' is referenced directly or indirectly in its own type annotation.
type typeAlias2 = typeof varOfAliasedType2;
~~~~~~~~~~
!!! error TS2456: Type alias 'typeAlias2' circularly references itself.
function func(): typeAlias3 { return null; }
var varOfAliasedType3 = func();
type typeAlias3 = typeof varOfAliasedType3;
~~~~~~~~~~
!!! error TS2456: Type alias 'typeAlias3' circularly references itself.

View file

@ -0,0 +1,17 @@
//// [circularTypeofWithVarOrFunc.ts]
type typeAlias1 = typeof varOfAliasedType1;
var varOfAliasedType1: typeAlias1;
var varOfAliasedType2: typeAlias2;
type typeAlias2 = typeof varOfAliasedType2;
function func(): typeAlias3 { return null; }
var varOfAliasedType3 = func();
type typeAlias3 = typeof varOfAliasedType3;
//// [circularTypeofWithVarOrFunc.js]
var varOfAliasedType1;
var varOfAliasedType2;
function func() { return null; }
var varOfAliasedType3 = func();

View file

@ -1,15 +1,21 @@
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(4,6): error TS2456: Type alias 'T0' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(5,6): error TS2456: Type alias 'T0_1' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(6,6): error TS2456: Type alias 'T0_2' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(7,6): error TS2456: Type alias 'T0_3' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(11,6): error TS2456: Type alias 'T1' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(14,6): error TS2456: Type alias 'T2' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(16,6): error TS2456: Type alias 'T2_1' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(19,6): error TS2456: Type alias 'T3' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(22,6): error TS2456: Type alias 'T4' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(25,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(26,6): error TS2456: Type alias 'T5' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(29,6): error TS2456: Type alias 'T6' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(30,6): error TS2456: Type alias 'T7' circularly references itself.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(31,5): error TS2502: 'yy' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(32,6): error TS2456: Type alias 'T8' circularly references itself.
==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (9 errors) ====
==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (15 errors) ====
// It is an error for the type specified in a type alias to depend on that type alias
// A type alias directly depends on the type it aliases.
@ -17,10 +23,14 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(
~~
!!! error TS2456: Type alias 'T0' circularly references itself.
type T0_1 = T0_2
~~~~
!!! error TS2456: Type alias 'T0_1' circularly references itself.
type T0_2 = T0_3
~~~~
!!! error TS2456: Type alias 'T0_2' circularly references itself.
type T0_3 = T0_1
~~~~
!!! error TS2456: Type alias 'T0_3' circularly references itself.
// A type reference directly depends on the referenced type and each of the type arguments, if any.
interface I<T> {}
@ -49,17 +59,25 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(
// A type query directly depends on the type of the referenced entity.
var x: T5[] = []
~
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
type T5 = typeof x
~~
!!! error TS2456: Type alias 'T5' circularly references itself.
class C1<T> {}
type T6 = T7 | number
~~
!!! error TS2456: Type alias 'T6' circularly references itself.
type T7 = typeof yy
~~
!!! error TS2456: Type alias 'T7' circularly references itself.
var yy: [string, T8[]];
~~
!!! error TS2502: 'yy' is referenced directly or indirectly in its own type annotation.
type T8 = C<T6>
~~
!!! error TS2456: Type alias 'T8' circularly references itself.
// legal cases
type T9 = () => T9

View file

@ -0,0 +1,12 @@
//// [exportDefaultVariable.ts]
// Regression test for #3018
declare var io: any;
declare module 'module' {
export default io;
}
//// [exportDefaultVariable.js]
// Regression test for #3018

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/exportDefaultVariable.ts ===
// Regression test for #3018
declare var io: any;
>io : Symbol(io, Decl(exportDefaultVariable.ts, 2, 11))
declare module 'module' {
export default io;
>io : Symbol(default, Decl(exportDefaultVariable.ts, 2, 11))
}

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/exportDefaultVariable.ts ===
// Regression test for #3018
declare var io: any;
>io : any
declare module 'module' {
export default io;
>io : any
}

View file

@ -1,13 +1,16 @@
tests/cases/conformance/es6/for-ofStatements/for-of33.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
tests/cases/conformance/es6/for-ofStatements/for-of33.ts(4,5): error TS7023: '[Symbol.iterator]' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (1 errors) ====
==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (2 errors) ====
for (var v of new StringIterator) { }
~
!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
class StringIterator {
[Symbol.iterator]() {
~~~~~~~~~~~~~~~~~
!!! error TS7023: '[Symbol.iterator]' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
return v;
}
}

View file

@ -1,13 +1,16 @@
tests/cases/conformance/es6/for-ofStatements/for-of34.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
tests/cases/conformance/es6/for-ofStatements/for-of34.ts(4,5): error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (1 errors) ====
==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (2 errors) ====
for (var v of new StringIterator) { }
~
!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
class StringIterator {
next() {
~~~~
!!! error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
return v;
}

View file

@ -1,13 +1,16 @@
tests/cases/conformance/es6/for-ofStatements/for-of35.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
tests/cases/conformance/es6/for-ofStatements/for-of35.ts(4,5): error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (1 errors) ====
==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (2 errors) ====
for (var v of new StringIterator) { }
~
!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
class StringIterator {
next() {
~~~~
!!! error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
return {
done: true,
value: v

View file

@ -1,31 +1,35 @@
tests/cases/compiler/implicitAnyFromCircularInference.ts(3,5): error TS7021: 'a' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/implicitAnyFromCircularInference.ts(7,5): error TS7021: 'c' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/implicitAnyFromCircularInference.ts(10,5): error TS7021: 'd' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/implicitAnyFromCircularInference.ts(3,5): error TS2502: 'a' is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/implicitAnyFromCircularInference.ts(6,5): error TS2502: 'b' is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/implicitAnyFromCircularInference.ts(7,5): error TS2502: 'c' is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/implicitAnyFromCircularInference.ts(10,5): error TS2502: 'd' is referenced directly or indirectly in its own type annotation.
tests/cases/compiler/implicitAnyFromCircularInference.ts(15,10): error TS7023: 'g' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(18,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(23,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(26,10): error TS7023: 'h' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(28,14): error TS7023: 'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
tests/cases/compiler/implicitAnyFromCircularInference.ts(41,5): error TS7022: 's' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
==== tests/cases/compiler/implicitAnyFromCircularInference.ts (9 errors) ====
==== tests/cases/compiler/implicitAnyFromCircularInference.ts (11 errors) ====
// Error expected
var a: typeof a;
~
!!! error TS7021: 'a' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.
!!! error TS2502: 'a' is referenced directly or indirectly in its own type annotation.
// Error expected on b or c
var b: typeof c;
~
!!! error TS2502: 'b' is referenced directly or indirectly in its own type annotation.
var c: typeof b;
~
!!! error TS7021: 'c' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.
!!! error TS2502: 'c' is referenced directly or indirectly in its own type annotation.
// Error expected
var d: Array<typeof d>;
~
!!! error TS7021: 'd' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation.
!!! error TS2502: 'd' is referenced directly or indirectly in its own type annotation.
function f() { return f; }
@ -52,6 +56,8 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x
!!! error TS7023: 'h' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
return foo();
function foo() {
~~~
!!! error TS7023: 'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
return h() || "hello";
}
}

View file

@ -1,9 +1,9 @@
//// [newLineFlagWithCRLF.ts]
//// [newLineFlagWithCRLF.ts]
var x=1;
x=2;
//// [newLineFlagWithCRLF.js]
var x = 1;
x = 2;
//// [newLineFlagWithCRLF.js]
var x = 1;
x = 2;

View file

@ -1,8 +1,8 @@
=== tests/cases/compiler/newLineFlagWithCRLF.ts ===
var x=1;
>x : Symbol(x, Decl(newLineFlagWithCRLF.ts, 0, 3))
x=2;
>x : Symbol(x, Decl(newLineFlagWithCRLF.ts, 0, 3))
=== tests/cases/compiler/newLineFlagWithCRLF.ts ===
var x=1;
>x : Symbol(x, Decl(newLineFlagWithCRLF.ts, 0, 3))
x=2;
>x : Symbol(x, Decl(newLineFlagWithCRLF.ts, 0, 3))

View file

@ -1,11 +1,11 @@
=== tests/cases/compiler/newLineFlagWithCRLF.ts ===
var x=1;
>x : number
>1 : number
x=2;
>x=2 : number
>x : number
>2 : number
=== tests/cases/compiler/newLineFlagWithCRLF.ts ===
var x=1;
>x : number
>1 : number
x=2;
>x=2 : number
>x : number
>2 : number

View file

@ -1,9 +1,9 @@
//// [newLineFlagWithLF.ts]
//// [newLineFlagWithLF.ts]
var x=1;
x=2;
//// [newLineFlagWithLF.js]
//// [newLineFlagWithLF.js]
var x = 1;
x = 2;

View file

@ -1,8 +1,8 @@
=== tests/cases/compiler/newLineFlagWithLF.ts ===
var x=1;
>x : Symbol(x, Decl(newLineFlagWithLF.ts, 0, 3))
x=2;
>x : Symbol(x, Decl(newLineFlagWithLF.ts, 0, 3))
=== tests/cases/compiler/newLineFlagWithLF.ts ===
var x=1;
>x : Symbol(x, Decl(newLineFlagWithLF.ts, 0, 3))
x=2;
>x : Symbol(x, Decl(newLineFlagWithLF.ts, 0, 3))

View file

@ -1,11 +1,11 @@
=== tests/cases/compiler/newLineFlagWithLF.ts ===
var x=1;
>x : number
>1 : number
x=2;
>x=2 : number
>x : number
>2 : number
=== tests/cases/compiler/newLineFlagWithLF.ts ===
var x=1;
>x : number
>1 : number
x=2;
>x=2 : number
>x : number
>2 : number

View file

@ -1,19 +1,19 @@
//// [noEmitHelpers.ts]
//// [noEmitHelpers.ts]
class A { }
class B extends A { }
//// [noEmitHelpers.js]
var A = (function () {
function A() {
}
return A;
})();
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
})(A);
//// [noEmitHelpers.js]
var A = (function () {
function A() {
}
return A;
})();
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
})(A);

View file

@ -1,9 +1,9 @@
=== tests/cases/compiler/noEmitHelpers.ts ===
class A { }
>A : Symbol(A, Decl(noEmitHelpers.ts, 0, 0))
class B extends A { }
>B : Symbol(B, Decl(noEmitHelpers.ts, 1, 11))
>A : Symbol(A, Decl(noEmitHelpers.ts, 0, 0))
=== tests/cases/compiler/noEmitHelpers.ts ===
class A { }
>A : Symbol(A, Decl(noEmitHelpers.ts, 0, 0))
class B extends A { }
>B : Symbol(B, Decl(noEmitHelpers.ts, 1, 11))
>A : Symbol(A, Decl(noEmitHelpers.ts, 0, 0))

View file

@ -1,9 +1,9 @@
=== tests/cases/compiler/noEmitHelpers.ts ===
class A { }
>A : A
class B extends A { }
>B : B
>A : A
=== tests/cases/compiler/noEmitHelpers.ts ===
class A { }
>A : A
class B extends A { }
>B : B
>A : A

View file

@ -0,0 +1,76 @@
tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(2,5): error TS2502: 'c' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(4,5): error TS2502: 'd' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(6,5): error TS2502: 'e' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(10,5): error TS2502: 'f' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(12,5): error TS2502: 'f2' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(14,5): error TS2502: 'f3' is referenced directly or indirectly in its own type annotation.
tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(51,5): error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation.
==== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts (7 errors) ====
// The following are errors because of circular references
var c: typeof c;
~
!!! error TS2502: 'c' is referenced directly or indirectly in its own type annotation.
var c: any;
var d: typeof e;
~
!!! error TS2502: 'd' is referenced directly or indirectly in its own type annotation.
var d: any;
var e: typeof d;
~
!!! error TS2502: 'e' is referenced directly or indirectly in its own type annotation.
var e: any;
interface Foo<T> { }
var f: Array<typeof f>;
~
!!! error TS2502: 'f' is referenced directly or indirectly in its own type annotation.
var f: any;
var f2: Foo<typeof f2>;
~~
!!! error TS2502: 'f2' is referenced directly or indirectly in its own type annotation.
var f2: any;
var f3: Foo<typeof f3>[];
~~
!!! error TS2502: 'f3' is referenced directly or indirectly in its own type annotation.
var f3: any;
// None of these declarations should have any errors!
// Truly recursive types
var g: { x: typeof g; };
var g: typeof g.x;
var h: () => typeof h;
var h = h();
var i: (x: typeof i) => typeof x;
var i = i(i);
var j: <T extends typeof j>(x: T) => T;
var j = j(j);
// Same as h, i, j with construct signatures
var h2: new () => typeof h2;
var h2 = new h2();
var i2: new (x: typeof i2) => typeof x;
var i2 = new i2(i2);
var j2: new <T extends typeof j2>(x: T) => T;
var j2 = new j2(j2);
// Indexers
var k: { [n: number]: typeof k;[s: string]: typeof k };
var k = k[0];
var k = k[''];
// Hybrid - contains type literals as well as type arguments
// These two are recursive
var hy1: { x: typeof hy1 }[];
var hy1 = hy1[0].x;
var hy2: { x: Array<typeof hy2> };
var hy2 = hy2.x[0];
interface Foo2<T, U> { }
// This one should be an error because the first type argument is not contained inside a type literal
var hy3: Foo2<typeof hy3, { x: typeof hy3 }>;
~~~
!!! error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation.
var hy3: any;

View file

@ -1,6 +1,5 @@
//// [recursiveTypesWithTypeof.ts]
// None of these declarations should have any errors!
// Using typeof directly, these should be any
// The following are errors because of circular references
var c: typeof c;
var c: any;
var d: typeof e;
@ -8,7 +7,6 @@ var d: any;
var e: typeof d;
var e: any;
// In type arguments, these should be any
interface Foo<T> { }
var f: Array<typeof f>;
var f: any;
@ -17,6 +15,7 @@ var f2: any;
var f3: Foo<typeof f3>[];
var f3: any;
// None of these declarations should have any errors!
// Truly recursive types
var g: { x: typeof g; };
var g: typeof g.x;
@ -49,25 +48,25 @@ var hy2 = hy2.x[0];
interface Foo2<T, U> { }
// This one should be any because the first type argument is not contained inside a type literal
// This one should be an error because the first type argument is not contained inside a type literal
var hy3: Foo2<typeof hy3, { x: typeof hy3 }>;
var hy3: any;
//// [recursiveTypesWithTypeof.js]
// The following are errors because of circular references
var c;
var c;
var d;
var d;
var e;
var e;
var f;
var f;
var f2;
var f2;
var f3;
var f3;
// None of these declarations should have any errors!
// Using typeof directly, these should be any
var c;
var c;
var d;
var d;
var e;
var e;
var f;
var f;
var f2;
var f2;
var f3;
var f3;
// Truly recursive types
var g;
var g;
@ -94,6 +93,6 @@ var hy1;
var hy1 = hy1[0].x;
var hy2;
var hy2 = hy2.x[0];
// This one should be any because the first type argument is not contained inside a type literal
// This one should be an error because the first type argument is not contained inside a type literal
var hy3;
var hy3;

View file

@ -1,187 +0,0 @@
=== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts ===
// None of these declarations should have any errors!
// Using typeof directly, these should be any
var c: typeof c;
>c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3))
>c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3))
var c: any;
>c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3))
var d: typeof e;
>d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3))
>e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3))
var d: any;
>d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3))
var e: typeof d;
>e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3))
>d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3))
var e: any;
>e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3))
// In type arguments, these should be any
interface Foo<T> { }
>Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 10, 14))
var f: Array<typeof f>;
>f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3))
var f: any;
>f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3))
var f2: Foo<typeof f2>;
>f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3))
>Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11))
>f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3))
var f2: any;
>f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3))
var f3: Foo<typeof f3>[];
>f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3))
>Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11))
>f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3))
var f3: any;
>f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3))
// Truly recursive types
var g: { x: typeof g; };
>g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8))
>g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3))
var g: typeof g.x;
>g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3))
>g.x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8))
>g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8))
var h: () => typeof h;
>h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3))
>h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3))
var h = h();
>h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3))
>h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3))
var i: (x: typeof i) => typeof x;
>i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 23, 8))
>i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 23, 8))
var i = i(i);
>i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3))
>i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3))
>i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3))
var j: <T extends typeof j>(x: T) => T;
>j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8))
>j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 25, 28))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8))
var j = j(j);
>j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3))
>j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3))
>j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3))
// Same as h, i, j with construct signatures
var h2: new () => typeof h2;
>h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3))
>h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3))
var h2 = new h2();
>h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3))
>h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3))
var i2: new (x: typeof i2) => typeof x;
>i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 31, 13))
>i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 31, 13))
var i2 = new i2(i2);
>i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3))
>i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3))
>i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3))
var j2: new <T extends typeof j2>(x: T) => T;
>j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13))
>j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 33, 34))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13))
var j2 = new j2(j2);
>j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3))
>j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3))
>j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3))
// Indexers
var k: { [n: number]: typeof k;[s: string]: typeof k };
>k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3))
>n : Symbol(n, Decl(recursiveTypesWithTypeof.ts, 37, 10))
>k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3))
>s : Symbol(s, Decl(recursiveTypesWithTypeof.ts, 37, 32))
>k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3))
var k = k[0];
>k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3))
>k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3))
var k = k[''];
>k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3))
>k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3))
// Hybrid - contains type literals as well as type arguments
// These two are recursive
var hy1: { x: typeof hy1 }[];
>hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10))
>hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3))
var hy1 = hy1[0].x;
>hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3))
>hy1[0].x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10))
>hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10))
var hy2: { x: Array<typeof hy2> };
>hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3))
var hy2 = hy2.x[0];
>hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3))
>hy2.x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10))
>hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10))
interface Foo2<T, U> { }
>Foo2 : Symbol(Foo2, Decl(recursiveTypesWithTypeof.ts, 46, 19))
>T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 48, 15))
>U : Symbol(U, Decl(recursiveTypesWithTypeof.ts, 48, 17))
// This one should be any because the first type argument is not contained inside a type literal
var hy3: Foo2<typeof hy3, { x: typeof hy3 }>;
>hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3))
>Foo2 : Symbol(Foo2, Decl(recursiveTypesWithTypeof.ts, 46, 19))
>hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3))
>x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 51, 27))
>hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3))
var hy3: any;
>hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3))

View file

@ -1,201 +0,0 @@
=== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts ===
// None of these declarations should have any errors!
// Using typeof directly, these should be any
var c: typeof c;
>c : any
>c : any
var c: any;
>c : any
var d: typeof e;
>d : any
>e : any
var d: any;
>d : any
var e: typeof d;
>e : any
>d : any
var e: any;
>e : any
// In type arguments, these should be any
interface Foo<T> { }
>Foo : Foo<T>
>T : T
var f: Array<typeof f>;
>f : any
>Array : T[]
>f : any
var f: any;
>f : any
var f2: Foo<typeof f2>;
>f2 : any
>Foo : Foo<T>
>f2 : any
var f2: any;
>f2 : any
var f3: Foo<typeof f3>[];
>f3 : any
>Foo : Foo<T>
>f3 : any
var f3: any;
>f3 : any
// Truly recursive types
var g: { x: typeof g; };
>g : { x: any; }
>x : { x: any; }
>g : { x: any; }
var g: typeof g.x;
>g : { x: any; }
>g.x : { x: any; }
>g : { x: any; }
>x : { x: any; }
var h: () => typeof h;
>h : () => any
>h : () => any
var h = h();
>h : () => any
>h() : () => any
>h : () => any
var i: (x: typeof i) => typeof x;
>i : (x: any) => any
>x : (x: any) => any
>i : (x: any) => any
>x : (x: any) => any
var i = i(i);
>i : (x: any) => any
>i(i) : (x: any) => any
>i : (x: any) => any
>i : (x: any) => any
var j: <T extends typeof j>(x: T) => T;
>j : <T extends any>(x: T) => T
>T : T
>j : <T extends any>(x: T) => T
>x : T
>T : T
>T : T
var j = j(j);
>j : <T extends any>(x: T) => T
>j(j) : <T extends any>(x: T) => T
>j : <T extends any>(x: T) => T
>j : <T extends any>(x: T) => T
// Same as h, i, j with construct signatures
var h2: new () => typeof h2;
>h2 : new () => any
>h2 : new () => any
var h2 = new h2();
>h2 : new () => any
>new h2() : new () => any
>h2 : new () => any
var i2: new (x: typeof i2) => typeof x;
>i2 : new (x: any) => any
>x : new (x: any) => any
>i2 : new (x: any) => any
>x : new (x: any) => any
var i2 = new i2(i2);
>i2 : new (x: any) => any
>new i2(i2) : new (x: any) => any
>i2 : new (x: any) => any
>i2 : new (x: any) => any
var j2: new <T extends typeof j2>(x: T) => T;
>j2 : new <T extends any>(x: T) => T
>T : T
>j2 : new <T extends any>(x: T) => T
>x : T
>T : T
>T : T
var j2 = new j2(j2);
>j2 : new <T extends any>(x: T) => T
>new j2(j2) : new <T extends any>(x: T) => T
>j2 : new <T extends any>(x: T) => T
>j2 : new <T extends any>(x: T) => T
// Indexers
var k: { [n: number]: typeof k;[s: string]: typeof k };
>k : { [s: string]: any; [n: number]: any; }
>n : number
>k : { [s: string]: any; [n: number]: any; }
>s : string
>k : { [s: string]: any; [n: number]: any; }
var k = k[0];
>k : { [s: string]: any; [n: number]: any; }
>k[0] : { [s: string]: any; [n: number]: any; }
>k : { [s: string]: any; [n: number]: any; }
>0 : number
var k = k[''];
>k : { [s: string]: any; [n: number]: any; }
>k[''] : { [s: string]: any; [n: number]: any; }
>k : { [s: string]: any; [n: number]: any; }
>'' : string
// Hybrid - contains type literals as well as type arguments
// These two are recursive
var hy1: { x: typeof hy1 }[];
>hy1 : { x: any[]; }[]
>x : { x: any[]; }[]
>hy1 : { x: any[]; }[]
var hy1 = hy1[0].x;
>hy1 : { x: any[]; }[]
>hy1[0].x : { x: any[]; }[]
>hy1[0] : { x: any[]; }
>hy1 : { x: any[]; }[]
>0 : number
>x : { x: any[]; }[]
var hy2: { x: Array<typeof hy2> };
>hy2 : { x: any[]; }
>x : { x: any[]; }[]
>Array : T[]
>hy2 : { x: any[]; }
var hy2 = hy2.x[0];
>hy2 : { x: any[]; }
>hy2.x[0] : { x: any[]; }
>hy2.x : { x: any[]; }[]
>hy2 : { x: any[]; }
>x : { x: any[]; }[]
>0 : number
interface Foo2<T, U> { }
>Foo2 : Foo2<T, U>
>T : T
>U : U
// This one should be any because the first type argument is not contained inside a type literal
var hy3: Foo2<typeof hy3, { x: typeof hy3 }>;
>hy3 : any
>Foo2 : Foo2<T, U>
>hy3 : any
>x : any
>hy3 : any
var hy3: any;
>hy3 : any

View file

@ -1,7 +1,8 @@
tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation.
==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (1 errors) ====
==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (2 errors) ====
var x = 1;
export var r1: typeof x;
~~~~~~~~~~~~~~~~~~~~~~~~
@ -46,6 +47,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType
export var r11: typeof E.A;
export var r12: typeof r12;
~~~
!!! error TS2502: 'r12' is referenced directly or indirectly in its own type annotation.
function foo() { }
module foo {

View file

@ -1,7 +1,8 @@
tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation.
==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (1 errors) ====
==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (2 errors) ====
export var x = 1;
~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
@ -46,6 +47,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.t
export var r11: typeof E.A;
export var r12: typeof r12;
~~~
!!! error TS2502: 'r12' is referenced directly or indirectly in its own type annotation.
export function foo() { }
export module foo {

View file

@ -0,0 +1,7 @@
// Regression test for #3018
declare var io: any;
declare module 'module' {
export default io;
}

View file

@ -0,0 +1,9 @@
type typeAlias1 = typeof varOfAliasedType1;
var varOfAliasedType1: typeAlias1;
var varOfAliasedType2: typeAlias2;
type typeAlias2 = typeof varOfAliasedType2;
function func(): typeAlias3 { return null; }
var varOfAliasedType3 = func();
type typeAlias3 = typeof varOfAliasedType3;

View file

@ -1,5 +1,4 @@
// None of these declarations should have any errors!
// Using typeof directly, these should be any
// The following are errors because of circular references
var c: typeof c;
var c: any;
var d: typeof e;
@ -7,7 +6,6 @@ var d: any;
var e: typeof d;
var e: any;
// In type arguments, these should be any
interface Foo<T> { }
var f: Array<typeof f>;
var f: any;
@ -16,6 +14,7 @@ var f2: any;
var f3: Foo<typeof f3>[];
var f3: any;
// None of these declarations should have any errors!
// Truly recursive types
var g: { x: typeof g; };
var g: typeof g.x;
@ -48,6 +47,6 @@ var hy2 = hy2.x[0];
interface Foo2<T, U> { }
// This one should be any because the first type argument is not contained inside a type literal
// This one should be an error because the first type argument is not contained inside a type literal
var hy3: Foo2<typeof hy3, { x: typeof hy3 }>;
var hy3: any;