mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into allow-type-predicates-as-return-types-only
This commit is contained in:
+4
-2
@@ -544,7 +544,8 @@ compileFile(word2mdJs,
|
||||
// The generated spec.md; built for the 'generate-spec' task
|
||||
file(specMd, [word2mdJs, specWord], function () {
|
||||
var specWordFullPath = path.resolve(specWord);
|
||||
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd;
|
||||
var specMDFullPath = path.resolve(specMd);
|
||||
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + '"' + specMDFullPath + '"';
|
||||
console.log(cmd);
|
||||
child_process.exec(cmd, function () {
|
||||
complete();
|
||||
@@ -923,7 +924,8 @@ function lintFileAsync(options, path, cb) {
|
||||
var lintTargets = compilerSources
|
||||
.concat(harnessCoreSources)
|
||||
.concat(serverCoreSources)
|
||||
.concat(scriptSources);
|
||||
.concat(scriptSources)
|
||||
.concat([path.join(servicesDirectory, "services.ts")]);
|
||||
|
||||
desc("Runs tslint on the compiler sources");
|
||||
task("lint", ["build-rules"], function() {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
This directory contains miscellaneous documentation such as the TypeScript language specification and logo.
|
||||
If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook).
|
||||
|
||||
# Spec Contributions
|
||||
|
||||
The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats.
|
||||
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests.
|
||||
+76
-12
@@ -222,8 +222,21 @@ namespace ts {
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return (<ExportAssignment>node).isExportEquals ? "export=" : "default";
|
||||
case SyntaxKind.BinaryExpression:
|
||||
// Binary expression case is for JS module 'module.exports = expr'
|
||||
return "export=";
|
||||
switch (getSpecialPropertyAssignmentKind(node)) {
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
// module.exports = ...
|
||||
return "export=";
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
// exports.x = ... or this.y = ...
|
||||
return ((node as BinaryExpression).left as PropertyAccessExpression).name.text;
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
// className.prototype.methodName = ...
|
||||
return (((node as BinaryExpression).left as PropertyAccessExpression).expression as PropertyAccessExpression).name.text;
|
||||
}
|
||||
Debug.fail("Unknown binary declaration kind");
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return node.flags & NodeFlags.Default ? "default" : undefined;
|
||||
@@ -1166,11 +1179,25 @@ namespace ts {
|
||||
return checkStrictModeIdentifier(<Identifier>node);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
if (isInJavaScriptFile(node)) {
|
||||
if (isExportsPropertyAssignment(node)) {
|
||||
bindExportsPropertyAssignment(<BinaryExpression>node);
|
||||
}
|
||||
else if (isModuleExportsAssignment(node)) {
|
||||
bindModuleExportsAssignment(<BinaryExpression>node);
|
||||
const specialKind = getSpecialPropertyAssignmentKind(node);
|
||||
switch (specialKind) {
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
bindExportsPropertyAssignment(<BinaryExpression>node);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
bindModuleExportsAssignment(<BinaryExpression>node);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
bindPrototypePropertyAssignment(<BinaryExpression>node);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
bindThisPropertyAssignment(<BinaryExpression>node);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.None:
|
||||
// Nothing to do
|
||||
break;
|
||||
default:
|
||||
Debug.fail("Unknown special property assignment kind");
|
||||
}
|
||||
}
|
||||
return checkStrictModeBinaryExpression(<BinaryExpression>node);
|
||||
@@ -1189,7 +1216,8 @@ namespace ts {
|
||||
case SyntaxKind.ThisType:
|
||||
seenThisKeyword = true;
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
return checkTypePredicate(node as TypePredicateNode);
|
||||
case SyntaxKind.TypeParameter:
|
||||
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);
|
||||
case SyntaxKind.Parameter:
|
||||
@@ -1275,6 +1303,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkTypePredicate(node: TypePredicateNode) {
|
||||
const { parameterName, type } = node;
|
||||
if (parameterName && parameterName.kind === SyntaxKind.Identifier) {
|
||||
checkStrictModeIdentifier(parameterName as Identifier);
|
||||
}
|
||||
if (parameterName && parameterName.kind === SyntaxKind.ThisType) {
|
||||
seenThisKeyword = true;
|
||||
}
|
||||
bind(type);
|
||||
}
|
||||
|
||||
function bindSourceFileIfExternalModule() {
|
||||
setExportContextFlag(file);
|
||||
if (isExternalModule(file)) {
|
||||
@@ -1339,6 +1378,34 @@ namespace ts {
|
||||
bindExportAssignment(node);
|
||||
}
|
||||
|
||||
function bindThisPropertyAssignment(node: BinaryExpression) {
|
||||
// Declare a 'member' in case it turns out the container was an ES5 class
|
||||
if (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) {
|
||||
container.symbol.members = container.symbol.members || {};
|
||||
declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
function bindPrototypePropertyAssignment(node: BinaryExpression) {
|
||||
// We saw a node of the form 'x.prototype.y = z'. Declare a 'member' y on x if x was a function.
|
||||
|
||||
// Look up the function in the local scope, since prototype assignments should
|
||||
// follow the function declaration
|
||||
const classId = <Identifier>(<PropertyAccessExpression>(<PropertyAccessExpression>node.left).expression).expression;
|
||||
const funcSymbol = container.locals[classId.text];
|
||||
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the members collection if it doesn't exist already
|
||||
if (!funcSymbol.members) {
|
||||
funcSymbol.members = {};
|
||||
}
|
||||
|
||||
// Declare the method/property
|
||||
declareSymbol(funcSymbol.members, funcSymbol, <PropertyAccessExpression>node.left, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
|
||||
function bindCallExpression(node: CallExpression) {
|
||||
// We're only inspecting call expressions to detect CommonJS modules, so we can skip
|
||||
// this check if we've already seen the module indicator
|
||||
@@ -1432,10 +1499,7 @@ namespace ts {
|
||||
|
||||
// If this is a property-parameter, then also declare the property symbol into the
|
||||
// containing class.
|
||||
if (node.flags & NodeFlags.AccessibilityModifier &&
|
||||
node.parent.kind === SyntaxKind.Constructor &&
|
||||
isClassLike(node.parent.parent)) {
|
||||
|
||||
if (isParameterPropertyDeclaration(node)) {
|
||||
const classDeclaration = <ClassLikeDeclaration>node.parent.parent;
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
|
||||
+788
-657
File diff suppressed because it is too large
Load Diff
@@ -794,23 +794,6 @@ namespace ts {
|
||||
return path;
|
||||
}
|
||||
|
||||
const backslashOrDoubleQuote = /[\"\\]/g;
|
||||
const escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
const escapedCharsMap: Map<string> = {
|
||||
"\0": "\\0",
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
"\f": "\\f",
|
||||
"\b": "\\b",
|
||||
"\r": "\\r",
|
||||
"\n": "\\n",
|
||||
"\\": "\\\\",
|
||||
"\"": "\\\"",
|
||||
"\u2028": "\\u2028", // lineSeparator
|
||||
"\u2029": "\\u2029", // paragraphSeparator
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
};
|
||||
|
||||
export interface ObjectAllocator {
|
||||
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
|
||||
|
||||
@@ -1309,6 +1309,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitSignatureDeclaration(node: SignatureDeclaration) {
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
|
||||
// Construct signature or constructor type write new Signature
|
||||
if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) {
|
||||
write("new ");
|
||||
@@ -1321,9 +1324,6 @@ namespace ts {
|
||||
write("(");
|
||||
}
|
||||
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
|
||||
// Parameters
|
||||
emitCommaList(node.parameters, emitParameterDeclaration);
|
||||
|
||||
@@ -1534,14 +1534,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitBindingElement(bindingElement: BindingElement) {
|
||||
function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
|
||||
const diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
return diagnosticMessage !== undefined ? {
|
||||
diagnosticMessage,
|
||||
errorNode: bindingElement,
|
||||
typeName: bindingElement.name
|
||||
} : undefined;
|
||||
}
|
||||
|
||||
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
|
||||
// If bindingElement is an omittedExpression (i.e. containing elision),
|
||||
|
||||
@@ -791,6 +791,10 @@
|
||||
"category": "Error",
|
||||
"code": 1248
|
||||
},
|
||||
"A decorator can only decorate a method implementation, not an overload.": {
|
||||
"category": "Error",
|
||||
"code": 1249
|
||||
},
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
"code": 1300
|
||||
@@ -863,7 +867,7 @@
|
||||
"category": "Error",
|
||||
"code": 2312
|
||||
},
|
||||
"Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": {
|
||||
"Type parameter '{0}' has a circular constraint.": {
|
||||
"category": "Error",
|
||||
"code": 2313
|
||||
},
|
||||
@@ -1643,6 +1647,14 @@
|
||||
"category": "Error",
|
||||
"code": 2517
|
||||
},
|
||||
"A 'this'-based type guard is not compatible with a parameter-based type guard.": {
|
||||
"category": "Error",
|
||||
"code": 2518
|
||||
},
|
||||
"A 'this'-based type predicate is only allowed within a class or interface's members, get accessors, or return type positions for functions and methods.": {
|
||||
"category": "Error",
|
||||
"code": 2519
|
||||
},
|
||||
"Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": {
|
||||
"category": "Error",
|
||||
"code": 2520
|
||||
@@ -1679,7 +1691,7 @@
|
||||
"category": "Error",
|
||||
"code": 2528
|
||||
},
|
||||
"JSX element attributes type '{0}' must be an object type.": {
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
},
|
||||
@@ -1747,6 +1759,14 @@
|
||||
"category": "Error",
|
||||
"code": 2658
|
||||
},
|
||||
"'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 2659
|
||||
},
|
||||
"'super' can only be referenced in members of derived classes or object literal expressions.": {
|
||||
"category": "Error",
|
||||
"code": 2660
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
|
||||
+46
-42
@@ -499,7 +499,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
|
||||
let exportSpecifiers: Map<ExportSpecifier[]>;
|
||||
let exportEquals: ExportAssignment;
|
||||
let hasExportStars: boolean;
|
||||
let hasExportStarsToExportValues: boolean;
|
||||
|
||||
let detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[];
|
||||
|
||||
@@ -574,7 +574,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
externalImports = undefined;
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = undefined;
|
||||
hasExportStarsToExportValues = undefined;
|
||||
detachedCommentsInfo = undefined;
|
||||
sourceMapData = undefined;
|
||||
isEs6Module = false;
|
||||
@@ -779,12 +779,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function emitTrailingCommaIfPresent(nodeList: NodeArray<Node>): void {
|
||||
if (nodeList.hasTrailingComma) {
|
||||
write(",");
|
||||
}
|
||||
}
|
||||
|
||||
function emitLinePreservingList(parent: Node, nodes: NodeArray<Node>, allowTrailingComma: boolean, spacesBetweenBraces: boolean) {
|
||||
Debug.assert(nodes.length > 0);
|
||||
|
||||
@@ -2451,7 +2445,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitPrefixUnaryExpression(node: PrefixUnaryExpression) {
|
||||
const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand);
|
||||
const exportChanged = (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) &&
|
||||
isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand);
|
||||
|
||||
if (exportChanged) {
|
||||
// emit
|
||||
@@ -3248,10 +3243,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function emitDownLevelForOfStatement(node: ForOfStatement) {
|
||||
emitLoop(node, emitDownLevelForOfStatementWorker);
|
||||
}
|
||||
|
||||
function emitDownLevelForOfStatementWorker(node: ForOfStatement, loop: ConvertedLoop) {
|
||||
// The following ES6 code:
|
||||
//
|
||||
@@ -4289,22 +4280,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
// TODO (yuisu) : we should not have special cases to condition emitting comments
|
||||
// but have one place to fix check for these conditions.
|
||||
if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature &&
|
||||
node.parent && node.parent.kind !== SyntaxKind.PropertyAssignment &&
|
||||
node.parent.kind !== SyntaxKind.CallExpression) {
|
||||
// 1. Methods will emit the comments as part of emitting method declaration
|
||||
|
||||
const { kind, parent } = node;
|
||||
if (kind !== SyntaxKind.MethodDeclaration &&
|
||||
kind !== SyntaxKind.MethodSignature &&
|
||||
parent &&
|
||||
parent.kind !== SyntaxKind.PropertyAssignment &&
|
||||
parent.kind !== SyntaxKind.CallExpression &&
|
||||
parent.kind !== SyntaxKind.ArrayLiteralExpression) {
|
||||
// 1. Methods will emit comments at their assignment declaration sites.
|
||||
//
|
||||
// 2. If the function is a property of object literal, emitting leading-comments
|
||||
// is done by emitNodeWithoutSourceMap which then call this function.
|
||||
// In particular, we would like to avoid emit comments twice in following case:
|
||||
// For example:
|
||||
// is done by emitNodeWithoutSourceMap which then call this function.
|
||||
// In particular, we would like to avoid emit comments twice in following case:
|
||||
//
|
||||
// var obj = {
|
||||
// id:
|
||||
// /*comment*/ () => void
|
||||
// }
|
||||
|
||||
//
|
||||
// 3. If the function is an argument in call expression, emitting of comments will be
|
||||
// taken care of in emit list of arguments inside of emitCallexpression
|
||||
// taken care of in emit list of arguments inside of 'emitCallExpression'.
|
||||
//
|
||||
// 4. If the function is in an array literal, 'emitLinePreservingList' will take care
|
||||
// of leading comments.
|
||||
emitLeadingComments(node);
|
||||
}
|
||||
|
||||
@@ -4331,12 +4329,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
emitSignatureAndBody(node);
|
||||
if (modulekind !== ModuleKind.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
|
||||
if (modulekind !== ModuleKind.ES6 && kind === SyntaxKind.FunctionDeclaration && parent === currentSourceFile && node.name) {
|
||||
emitExportMemberAssignments((<FunctionDeclaration>node).name);
|
||||
}
|
||||
|
||||
emitEnd(node);
|
||||
if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) {
|
||||
if (kind !== SyntaxKind.MethodDeclaration && kind !== SyntaxKind.MethodSignature) {
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
}
|
||||
@@ -5260,11 +5258,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
writeLine();
|
||||
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
|
||||
emitStart(node);
|
||||
write(")(");
|
||||
write("(");
|
||||
if (baseTypeNode) {
|
||||
emit(baseTypeNode.expression);
|
||||
}
|
||||
write(")");
|
||||
write("))");
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
write(";");
|
||||
}
|
||||
@@ -6231,15 +6229,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
else {
|
||||
// export * from "foo"
|
||||
writeLine();
|
||||
write("__export(");
|
||||
if (modulekind !== ModuleKind.AMD) {
|
||||
emitRequire(getExternalModuleName(node));
|
||||
if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) {
|
||||
writeLine();
|
||||
write("__export(");
|
||||
if (modulekind !== ModuleKind.AMD) {
|
||||
emitRequire(getExternalModuleName(node));
|
||||
}
|
||||
else {
|
||||
write(generatedName);
|
||||
}
|
||||
write(");");
|
||||
}
|
||||
else {
|
||||
write(generatedName);
|
||||
}
|
||||
write(");");
|
||||
}
|
||||
emitEnd(node);
|
||||
}
|
||||
@@ -6327,7 +6327,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
externalImports = [];
|
||||
exportSpecifiers = {};
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
hasExportStarsToExportValues = false;
|
||||
for (const node of sourceFile.statements) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
@@ -6350,8 +6350,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
if ((<ExportDeclaration>node).moduleSpecifier) {
|
||||
if (!(<ExportDeclaration>node).exportClause) {
|
||||
// export * from "mod"
|
||||
externalImports.push(<ExportDeclaration>node);
|
||||
hasExportStars = true;
|
||||
if (resolver.moduleExportsSomeValue((<ExportDeclaration>node).moduleSpecifier)) {
|
||||
externalImports.push(<ExportDeclaration>node);
|
||||
hasExportStarsToExportValues = true;
|
||||
}
|
||||
}
|
||||
else if (resolver.isValueAliasDeclaration(node)) {
|
||||
// export { x, y } from "mod" where at least one export is a value symbol
|
||||
@@ -6377,7 +6379,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitExportStarHelper() {
|
||||
if (hasExportStars) {
|
||||
if (hasExportStarsToExportValues) {
|
||||
writeLine();
|
||||
write("function __export(m) {");
|
||||
increaseIndent();
|
||||
@@ -6455,7 +6457,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// should always win over entries with similar names that were added via star exports
|
||||
// to support this we store names of local/indirect exported entries in a set.
|
||||
// this set is used to filter names brought by star expors.
|
||||
if (!hasExportStars) {
|
||||
if (!hasExportStarsToExportValues) {
|
||||
// local names set is needed only in presence of star exports
|
||||
return undefined;
|
||||
}
|
||||
@@ -6880,6 +6882,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write("});");
|
||||
}
|
||||
else {
|
||||
// collectExternalModuleInfo prefilters star exports to keep only ones that export values
|
||||
// this means that check 'resolver.moduleExportsSomeValue' is redundant and can be omitted here
|
||||
writeLine();
|
||||
// export * from 'foo'
|
||||
// emit as:
|
||||
@@ -7148,7 +7152,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
externalImports = undefined;
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
hasExportStarsToExportValues = false;
|
||||
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
@@ -7372,7 +7376,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
externalImports = undefined;
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
hasExportStarsToExportValues = false;
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
|
||||
+21
-39
@@ -771,10 +771,6 @@ namespace ts {
|
||||
return doInsideOfContext(ParserContextFlags.Yield, func);
|
||||
}
|
||||
|
||||
function doOutsideOfYieldContext<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.Yield, func);
|
||||
}
|
||||
|
||||
function doInDecoratorContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Decorator, func);
|
||||
}
|
||||
@@ -791,10 +787,6 @@ namespace ts {
|
||||
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
function doOutsideOfYieldAndAwaitContext<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
function inContext(flags: ParserContextFlags) {
|
||||
return (contextFlags & flags) !== 0;
|
||||
}
|
||||
@@ -851,10 +843,6 @@ namespace ts {
|
||||
return token = scanner.scan();
|
||||
}
|
||||
|
||||
function getTokenPos(pos: number): number {
|
||||
return skipTrivia(sourceText, pos);
|
||||
}
|
||||
|
||||
function reScanGreaterToken(): SyntaxKind {
|
||||
return token = scanner.reScanGreaterToken();
|
||||
}
|
||||
@@ -1972,8 +1960,16 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseThisTypeNode(): TypeNode {
|
||||
const node = <TypeNode>createNode(SyntaxKind.ThisType);
|
||||
function parseTypePredicate(lhs: Identifier | ThisTypeNode): TypePredicateNode {
|
||||
nextToken();
|
||||
const node = createNode(SyntaxKind.TypePredicate, lhs.pos) as TypePredicateNode;
|
||||
node.parameterName = lhs;
|
||||
node.type = parseType();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseThisTypeNode(): ThisTypeNode {
|
||||
const node = createNode(SyntaxKind.ThisType) as ThisTypeNode;
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -2419,8 +2415,15 @@ namespace ts {
|
||||
return parseStringLiteralTypeNode();
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return parseTokenNode<TypeNode>();
|
||||
case SyntaxKind.ThisKeyword:
|
||||
return parseThisTypeNode();
|
||||
case SyntaxKind.ThisKeyword: {
|
||||
const thisKeyword = parseThisTypeNode();
|
||||
if (token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
|
||||
return parseTypePredicate(thisKeyword);
|
||||
}
|
||||
else {
|
||||
return thisKeyword;
|
||||
}
|
||||
}
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
return parseTypeQuery();
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
@@ -2654,10 +2657,6 @@ namespace ts {
|
||||
isStartOfExpression();
|
||||
}
|
||||
|
||||
function allowInAndParseExpression(): Expression {
|
||||
return allowInAnd(parseExpression);
|
||||
}
|
||||
|
||||
function parseExpression(): Expression {
|
||||
// Expression[in]:
|
||||
// AssignmentExpression[in]
|
||||
@@ -3660,7 +3659,7 @@ namespace ts {
|
||||
|
||||
parseExpected(SyntaxKind.OpenBraceToken);
|
||||
if (token !== SyntaxKind.CloseBraceToken) {
|
||||
node.expression = parseExpression();
|
||||
node.expression = parseAssignmentExpressionOrHigher();
|
||||
}
|
||||
if (inExpressionContext) {
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
@@ -3972,7 +3971,6 @@ namespace ts {
|
||||
|
||||
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
const tokenIsIdentifier = isIdentifier();
|
||||
const nameToken = token;
|
||||
const propertyName = parsePropertyName();
|
||||
|
||||
// Disallowing of optional property assignments happens in the grammar checker.
|
||||
@@ -4002,6 +4000,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
const propertyAssignment = <PropertyAssignment>createNode(SyntaxKind.PropertyAssignment, fullStart);
|
||||
propertyAssignment.modifiers = modifiers;
|
||||
propertyAssignment.name = propertyName;
|
||||
propertyAssignment.questionToken = questionToken;
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
@@ -5113,10 +5112,6 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseHeritageClausesWorker() {
|
||||
return parseList(ParsingContext.HeritageClauses, parseHeritageClause);
|
||||
}
|
||||
|
||||
function parseHeritageClause() {
|
||||
if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) {
|
||||
const node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
|
||||
@@ -5262,12 +5257,6 @@ namespace ts {
|
||||
return nextToken() === SyntaxKind.SlashToken;
|
||||
}
|
||||
|
||||
function nextTokenIsCommaOrFromKeyword() {
|
||||
nextToken();
|
||||
return token === SyntaxKind.CommaToken ||
|
||||
token === SyntaxKind.FromKeyword;
|
||||
}
|
||||
|
||||
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
|
||||
parseExpected(SyntaxKind.ImportKeyword);
|
||||
const afterImportPos = scanner.getStartPos();
|
||||
@@ -5760,13 +5749,6 @@ namespace ts {
|
||||
return finishNode(parameter);
|
||||
}
|
||||
|
||||
function parseJSDocOptionalType(type: JSDocType): JSDocOptionalType {
|
||||
const result = <JSDocOptionalType>createNode(SyntaxKind.JSDocOptionalType, type.pos);
|
||||
nextToken();
|
||||
result.type = type;
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseJSDocTypeReference(): JSDocTypeReference {
|
||||
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
|
||||
result.name = parseSimplePropertyName();
|
||||
|
||||
@@ -573,8 +573,11 @@ namespace ts {
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
|
||||
// get any preEmit diagnostics, not just the ones
|
||||
if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) {
|
||||
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
|
||||
if (options.noEmitOnError) {
|
||||
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
|
||||
if (preEmitDiagnostics.length > 0) {
|
||||
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
|
||||
}
|
||||
}
|
||||
|
||||
// Create the emit resolver outside of the "emitTime" tracking code below. That way
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace ts {
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
const nop = <(...args: any[]) => any>Function.prototype;
|
||||
let nullSourceMapWriter: SourceMapWriter;
|
||||
|
||||
export function getNullSourceMapWriter(): SourceMapWriter {
|
||||
|
||||
+6
-12
@@ -51,6 +51,8 @@ namespace ts {
|
||||
args: string[];
|
||||
currentDirectory: string;
|
||||
executingFile: string;
|
||||
newLine?: string;
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
echo(s: string): void;
|
||||
quit(exitCode?: number): void;
|
||||
fileExists(path: string): boolean;
|
||||
@@ -60,6 +62,8 @@ namespace ts {
|
||||
readFile(path: string): string;
|
||||
writeFile(path: string, contents: string): void;
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher;
|
||||
watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher;
|
||||
};
|
||||
|
||||
export var sys: System = (function () {
|
||||
@@ -214,7 +218,6 @@ namespace ts {
|
||||
const _fs = require("fs");
|
||||
const _path = require("path");
|
||||
const _os = require("os");
|
||||
const _tty = require("tty");
|
||||
|
||||
// average async stat takes about 30 microseconds
|
||||
// set chunk size to do 30 files in < 1 millisecond
|
||||
@@ -309,10 +312,6 @@ namespace ts {
|
||||
// time dynamically to match the large reference set?
|
||||
const watchedFileSet = createWatchedFileSet();
|
||||
|
||||
function isNode4OrLater(): Boolean {
|
||||
return parseInt(process.version.charAt(1)) >= 4;
|
||||
}
|
||||
|
||||
const platform: string = _os.platform();
|
||||
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
||||
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||
@@ -411,11 +410,6 @@ namespace ts {
|
||||
// and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649
|
||||
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
|
||||
// if the current node.js version is newer than 4, use `fs.watch` instead.
|
||||
if (isNode4OrLater()) {
|
||||
// Note: in node the callback of fs.watch is given only the relative file name as a parameter
|
||||
return _fs.watch(fileName, (eventName: string, relativeFileName: string) => callback(fileName));
|
||||
}
|
||||
|
||||
const watchedFile = watchedFileSet.addFile(fileName, callback);
|
||||
return {
|
||||
close: () => watchedFileSet.removeFile(watchedFile)
|
||||
@@ -474,9 +468,9 @@ namespace ts {
|
||||
function getChakraSystem(): System {
|
||||
|
||||
return {
|
||||
newLine: "\r\n",
|
||||
newLine: ChakraHost.newLine || "\r\n",
|
||||
args: ChakraHost.args,
|
||||
useCaseSensitiveFileNames: false,
|
||||
useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames,
|
||||
write: ChakraHost.echo,
|
||||
readFile(path: string, encoding?: string) {
|
||||
// encoding is automatically handled by the implementation in ChakraHost
|
||||
|
||||
+48
-7
@@ -733,11 +733,15 @@ namespace ts {
|
||||
// @kind(SyntaxKind.StringKeyword)
|
||||
// @kind(SyntaxKind.SymbolKeyword)
|
||||
// @kind(SyntaxKind.VoidKeyword)
|
||||
// @kind(SyntaxKind.ThisType)
|
||||
export interface TypeNode extends Node {
|
||||
_typeNodeBrand: any;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.ThisType)
|
||||
export interface ThisTypeNode extends TypeNode {
|
||||
_thisTypeNodeBrand: any;
|
||||
}
|
||||
|
||||
export interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration {
|
||||
_functionOrConstructorTypeNodeBrand: any;
|
||||
}
|
||||
@@ -756,7 +760,7 @@ namespace ts {
|
||||
|
||||
// @kind(SyntaxKind.TypePredicate)
|
||||
export interface TypePredicateNode extends TypeNode {
|
||||
parameterName: Identifier;
|
||||
parameterName: Identifier | ThisTypeNode;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
@@ -1191,7 +1195,7 @@ namespace ts {
|
||||
|
||||
// @kind(SyntaxKind.CaseClause)
|
||||
export interface CaseClause extends Node {
|
||||
expression?: Expression;
|
||||
expression: Expression;
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
|
||||
@@ -1719,6 +1723,7 @@ namespace ts {
|
||||
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
||||
@@ -1820,10 +1825,25 @@ namespace ts {
|
||||
CannotBeNamed
|
||||
}
|
||||
|
||||
export const enum TypePredicateKind {
|
||||
This,
|
||||
Identifier
|
||||
}
|
||||
|
||||
export interface TypePredicate {
|
||||
kind: TypePredicateKind;
|
||||
type: Type;
|
||||
}
|
||||
|
||||
// @kind (TypePredicateKind.This)
|
||||
export interface ThisTypePredicate extends TypePredicate {
|
||||
_thisTypePredicateBrand: any;
|
||||
}
|
||||
|
||||
// @kind (TypePredicateKind.Identifier)
|
||||
export interface IdentifierTypePredicate extends TypePredicate {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1887,6 +1907,7 @@ namespace ts {
|
||||
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
||||
getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind;
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean;
|
||||
isArgumentsLocalBinding(node: Identifier): boolean;
|
||||
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile;
|
||||
}
|
||||
@@ -1997,6 +2018,7 @@ namespace ts {
|
||||
type?: Type; // Type of value symbol
|
||||
declaredType?: Type; // Type of class, interface, enum, type alias, or type parameter
|
||||
typeParameters?: TypeParameter[]; // Type parameters of type alias (undefined if non-generic)
|
||||
inferredClassType?: Type; // Type of an inferred ES5 class
|
||||
instantiations?: Map<Type>; // Instantiations of generic type alias (undefined if non-generic)
|
||||
mapper?: TypeMapper; // Type mapper for instantiation alias
|
||||
referenced?: boolean; // True if alias symbol has been referenced as a value
|
||||
@@ -2005,6 +2027,7 @@ namespace ts {
|
||||
exportsChecked?: boolean; // True if exports of external module have been checked
|
||||
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
|
||||
bindingElement?: BindingElement; // Binding element associated with property symbol
|
||||
exportsSomeValue?: boolean; // true if module exports some value (not just types)
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -2045,7 +2068,6 @@ namespace ts {
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
flags?: NodeCheckFlags; // Set of flags specific to Node
|
||||
enumMemberValue?: number; // Constant value of enum member
|
||||
isIllegalTypeReferenceInConstraint?: boolean; // Is type reference in constraint refers to the type parameter from the same list
|
||||
isVisible?: boolean; // Is this node visible
|
||||
generatedName?: string; // Generated name for module, enum, or import declaration
|
||||
generatedNames?: Map<string>; // Generated names table for source file
|
||||
@@ -2089,6 +2111,7 @@ namespace ts {
|
||||
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
|
||||
ThisType = 0x02000000, // This type
|
||||
ObjectLiteralPatternWithComputedProperties = 0x04000000, // Object literal type implied by binding pattern has computed properties
|
||||
PredicateType = 0x08000000, // Predicate types are also Boolean types, but should not be considered Intrinsics - there's no way to capture this with flags
|
||||
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
@@ -2100,7 +2123,7 @@ namespace ts {
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
StructuredType = ObjectType | Union | Intersection,
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral,
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral | PredicateType,
|
||||
/* @internal */
|
||||
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
|
||||
}
|
||||
@@ -2121,6 +2144,11 @@ namespace ts {
|
||||
intrinsicName: string; // Name of intrinsic type
|
||||
}
|
||||
|
||||
// Predicate types (TypeFlags.Predicate)
|
||||
export interface PredicateType extends Type {
|
||||
predicate: ThisTypePredicate | IdentifierTypePredicate;
|
||||
}
|
||||
|
||||
// String literal types (TypeFlags.StringLiteral)
|
||||
export interface StringLiteralType extends Type {
|
||||
text: string; // Text of string literal
|
||||
@@ -2237,7 +2265,6 @@ namespace ts {
|
||||
declaration: SignatureDeclaration; // Originating declaration
|
||||
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||
parameters: Symbol[]; // Parameters
|
||||
typePredicate?: TypePredicate; // Type predicate
|
||||
/* @internal */
|
||||
resolvedReturnType: Type; // Resolved return type
|
||||
/* @internal */
|
||||
@@ -2286,10 +2313,24 @@ namespace ts {
|
||||
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
|
||||
inferences: TypeInferences[]; // Inferences made for each type parameter
|
||||
inferredTypes: Type[]; // Inferred type for each type parameter
|
||||
mapper?: TypeMapper; // Type mapper for this inference context
|
||||
failedTypeParameterIndex?: number; // Index of type parameter for which inference failed
|
||||
// It is optional because in contextual signature instantiation, nothing fails
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export const enum SpecialPropertyAssignmentKind {
|
||||
None,
|
||||
/// exports.name = expr
|
||||
ExportsProperty,
|
||||
/// module.exports = expr
|
||||
ModuleExports,
|
||||
/// className.prototype.name = expr
|
||||
PrototypeProperty,
|
||||
/// this.name = expr
|
||||
ThisProperty
|
||||
}
|
||||
|
||||
export interface DiagnosticMessage {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
|
||||
+68
-54
@@ -342,6 +342,7 @@ namespace ts {
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
errorNode = (<Declaration>node).name;
|
||||
break;
|
||||
}
|
||||
@@ -692,6 +693,10 @@ namespace ts {
|
||||
return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression;
|
||||
}
|
||||
|
||||
export function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate {
|
||||
return predicate && predicate.kind === TypePredicateKind.Identifier;
|
||||
}
|
||||
|
||||
export function getContainingFunction(node: Node): FunctionLikeDeclaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
@@ -770,26 +775,38 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getSuperContainer(node: Node, includeFunctions: boolean): Node {
|
||||
/**
|
||||
* Given an super call\property node returns a closest node where either
|
||||
* - super call\property is legal in the node and not legal in the parent node the node.
|
||||
* i.e. super call is legal in constructor but not legal in the class body.
|
||||
* - node is arrow function (so caller might need to call getSuperContainer in case if he needs to climb higher)
|
||||
* - super call\property is definitely illegal in the node (but might be legal in some subnode)
|
||||
* i.e. super property access is illegal in function declaration but can be legal in the statement list
|
||||
*/
|
||||
export function getSuperContainer(node: Node, stopOnFunctions: boolean): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) return node;
|
||||
if (!node) {
|
||||
return node;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
// If the grandparent node is an object literal (as opposed to a class),
|
||||
// then the computed property is not a 'super' container.
|
||||
// A computed property name in a class needs to be a super container
|
||||
// so that we can error on it.
|
||||
if (isClassLike(node.parent.parent)) {
|
||||
return node;
|
||||
}
|
||||
// If this is a computed property, then the parent should not
|
||||
// make it a super container. The parent might be a property
|
||||
// in an object literal, like a method or accessor. But in order for
|
||||
// such a parent to be a super container, the reference must be in
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!stopOnFunctions) {
|
||||
continue;
|
||||
}
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
@@ -803,20 +820,6 @@ namespace ts {
|
||||
node = node.parent;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeFunctions) {
|
||||
continue;
|
||||
}
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1063,33 +1066,40 @@ namespace ts {
|
||||
(<CallExpression>expression).arguments[0].kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the node is an assignment to a property on the identifier 'exports'.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
export function isExportsPropertyAssignment(expression: Node): boolean {
|
||||
// of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary
|
||||
return isInJavaScriptFile(expression) &&
|
||||
(expression.kind === SyntaxKind.BinaryExpression) &&
|
||||
((<BinaryExpression>expression).operatorToken.kind === SyntaxKind.EqualsToken) &&
|
||||
((<BinaryExpression>expression).left.kind === SyntaxKind.PropertyAccessExpression) &&
|
||||
((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression.kind === SyntaxKind.Identifier) &&
|
||||
((<Identifier>((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression)).text === "exports");
|
||||
}
|
||||
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
|
||||
/// assignments we treat as special in the binder
|
||||
export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind {
|
||||
if (expression.kind !== SyntaxKind.BinaryExpression) {
|
||||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
const expr = <BinaryExpression>expression;
|
||||
if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || expr.left.kind !== SyntaxKind.PropertyAccessExpression) {
|
||||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
const lhs = <PropertyAccessExpression>expr.left;
|
||||
if (lhs.expression.kind === SyntaxKind.Identifier) {
|
||||
const lhsId = <Identifier>lhs.expression;
|
||||
if (lhsId.text === "exports") {
|
||||
// exports.name = expr
|
||||
return SpecialPropertyAssignmentKind.ExportsProperty;
|
||||
}
|
||||
else if (lhsId.text === "module" && lhs.name.text === "exports") {
|
||||
// module.exports = expr
|
||||
return SpecialPropertyAssignmentKind.ModuleExports;
|
||||
}
|
||||
}
|
||||
else if (lhs.expression.kind === SyntaxKind.ThisKeyword) {
|
||||
return SpecialPropertyAssignmentKind.ThisProperty;
|
||||
}
|
||||
else if (lhs.expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
// chained dot, e.g. x.y.z = expr; this var is the 'x.y' part
|
||||
const innerPropertyAccess = <PropertyAccessExpression>lhs.expression;
|
||||
if (innerPropertyAccess.expression.kind === SyntaxKind.Identifier && innerPropertyAccess.name.text === "prototype") {
|
||||
return SpecialPropertyAssignmentKind.PrototypeProperty;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the node is an assignment to the property access expression 'module.exports'.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
export function isModuleExportsAssignment(expression: Node): boolean {
|
||||
// of the form 'module.exports = expr' where 'expr' is arbitrary
|
||||
return isInJavaScriptFile(expression) &&
|
||||
(expression.kind === SyntaxKind.BinaryExpression) &&
|
||||
((<BinaryExpression>expression).operatorToken.kind === SyntaxKind.EqualsToken) &&
|
||||
((<BinaryExpression>expression).left.kind === SyntaxKind.PropertyAccessExpression) &&
|
||||
((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression.kind === SyntaxKind.Identifier) &&
|
||||
((<Identifier>((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression)).text === "module") &&
|
||||
((<PropertyAccessExpression>(<BinaryExpression>expression).left).name.text === "exports");
|
||||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
|
||||
export function getExternalModuleName(node: Node): Expression {
|
||||
@@ -2736,4 +2746,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
|
||||
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||
|
||||
const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true);
|
||||
const pullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ false);
|
||||
|
||||
const fullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
const pullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
|
||||
+22
-17
@@ -321,11 +321,6 @@ namespace FourSlash {
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
||||
};
|
||||
|
||||
this.testData.files.forEach(file => {
|
||||
const fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), "").substr(1);
|
||||
const fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf("."));
|
||||
});
|
||||
|
||||
// Open the first file by default
|
||||
this.openFile(0);
|
||||
}
|
||||
@@ -762,10 +757,6 @@ namespace FourSlash {
|
||||
return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private assertionMessage(name: string, actualValue: any, expectedValue: any) {
|
||||
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(expected: string) {
|
||||
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
|
||||
this.testDiagnostics(expected, diagnostics);
|
||||
@@ -910,7 +901,6 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public verifyCurrentParameterSpanIs(parameter: string) {
|
||||
const activeSignature = this.getActiveSignatureHelpItem();
|
||||
const activeParameter = this.getActiveParameter();
|
||||
assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter);
|
||||
}
|
||||
@@ -1162,7 +1152,7 @@ namespace FourSlash {
|
||||
|
||||
public printCurrentQuickInfo() {
|
||||
const quickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
Harness.IO.log(JSON.stringify(quickInfo));
|
||||
Harness.IO.log("Quick Info: " + quickInfo.displayParts.map(part => part.text).join(""));
|
||||
}
|
||||
|
||||
public printErrorList() {
|
||||
@@ -1204,12 +1194,26 @@ namespace FourSlash {
|
||||
|
||||
public printMemberListMembers() {
|
||||
const members = this.getMemberListAtCaret();
|
||||
Harness.IO.log(JSON.stringify(members));
|
||||
this.printMembersOrCompletions(members);
|
||||
}
|
||||
|
||||
public printCompletionListMembers() {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
Harness.IO.log(JSON.stringify(completions));
|
||||
this.printMembersOrCompletions(completions);
|
||||
}
|
||||
|
||||
private printMembersOrCompletions(info: ts.CompletionInfo) {
|
||||
function pad(s: string, length: number) {
|
||||
return s + new Array(length - s.length + 1).join(" ");
|
||||
}
|
||||
function max<T>(arr: T[], selector: (x: T) => number): number {
|
||||
return arr.reduce((prev, x) => Math.max(prev, selector(x)), 0);
|
||||
}
|
||||
const longestNameLength = max(info.entries, m => m.name.length);
|
||||
const longestKindLength = max(info.entries, m => m.kind.length);
|
||||
info.entries.sort((m, n) => m.sortText > n.sortText ? 1 : m.sortText < n.sortText ? -1 : m.name > n.name ? 1 : m.name < n.name ? -1 : 0);
|
||||
const membersString = info.entries.map(m => `${pad(m.name, longestNameLength)} ${pad(m.kind, longestKindLength)} ${m.kindModifiers}`).join("\n");
|
||||
Harness.IO.log(membersString);
|
||||
}
|
||||
|
||||
public printReferences() {
|
||||
@@ -2175,9 +2179,6 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
// TOOD: should these just use the Harness's stdout/stderr?
|
||||
const fsOutput = new Harness.Compiler.WriterAggregator();
|
||||
const fsErrors = new Harness.Compiler.WriterAggregator();
|
||||
export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) {
|
||||
const content = Harness.IO.readFile(fileName);
|
||||
runFourSlashTestContent(basePath, testType, content, fileName);
|
||||
@@ -2768,6 +2769,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative);
|
||||
}
|
||||
|
||||
public assertHasRanges(ranges: FourSlash.Range[]) {
|
||||
assert(ranges.length !== 0, "Array of ranges is expected to be non-empty");
|
||||
}
|
||||
|
||||
public completionListIsEmpty() {
|
||||
this.state.verifyCompletionListIsEmpty(this.negative);
|
||||
}
|
||||
@@ -3287,4 +3292,4 @@ namespace FourSlashInterface {
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
// this will work in the browser via browserify
|
||||
var _chai: typeof chai = require("chai");
|
||||
var assert: typeof _chai.assert = _chai.assert;
|
||||
var expect: typeof _chai.expect = _chai.expect;
|
||||
declare var __dirname: string; // Node-specific
|
||||
var global = <any>Function("return this").call(null);
|
||||
/* tslint:enable:no-var-keyword */
|
||||
@@ -513,7 +512,6 @@ namespace Harness {
|
||||
}
|
||||
|
||||
const folder: any = fso.GetFolder(path);
|
||||
const paths: string[] = [];
|
||||
|
||||
return filesInFolder(folder, path);
|
||||
};
|
||||
@@ -617,7 +615,6 @@ namespace Harness {
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => {};
|
||||
|
||||
const supportsCodePage = () => false;
|
||||
export let log = (s: string) => console.log(s);
|
||||
|
||||
namespace Http {
|
||||
@@ -627,18 +624,6 @@ namespace Harness {
|
||||
}
|
||||
|
||||
/// Ask the server to use node's path.resolve to resolve the given path
|
||||
function getResolvedPathFromServer(path: string) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
try {
|
||||
xhr.open("GET", path + "?resolve", /*async*/ false);
|
||||
xhr.send();
|
||||
}
|
||||
catch (e) {
|
||||
return { status: 404, responseText: null };
|
||||
}
|
||||
|
||||
return waitForXHR(xhr);
|
||||
}
|
||||
|
||||
export interface XHRResponse {
|
||||
status: number;
|
||||
|
||||
@@ -315,13 +315,6 @@ namespace Harness.LanguageService {
|
||||
class LanguageServiceShimProxy implements ts.LanguageService {
|
||||
constructor(private shim: ts.LanguageServiceShim) {
|
||||
}
|
||||
private unwrappJSONCallResult(result: string): any {
|
||||
const parsedResult = JSON.parse(result);
|
||||
if (parsedResult.error) {
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
||||
}
|
||||
return parsedResult.result;
|
||||
}
|
||||
cleanupSemanticCache(): void {
|
||||
this.shim.cleanupSemanticCache();
|
||||
}
|
||||
|
||||
@@ -305,25 +305,6 @@ namespace Playback {
|
||||
}
|
||||
}
|
||||
|
||||
const pathEquivCache: any = {};
|
||||
function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) {
|
||||
const key = left + "-~~-" + right;
|
||||
function areSame(a: string, b: string) {
|
||||
return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase();
|
||||
}
|
||||
function check() {
|
||||
if (Harness.Path.getFileName(left).toLowerCase() === Harness.Path.getFileName(right).toLowerCase()) {
|
||||
return areSame(left, right) || areSame(wrapper.resolvePath(left), right) || areSame(left, wrapper.resolvePath(right)) || areSame(wrapper.resolvePath(left), wrapper.resolvePath(right));
|
||||
}
|
||||
}
|
||||
if (pathEquivCache.hasOwnProperty(key)) {
|
||||
return pathEquivCache[key];
|
||||
}
|
||||
else {
|
||||
return pathEquivCache[key] = check();
|
||||
}
|
||||
}
|
||||
|
||||
function noOpReplay(name: string) {
|
||||
// console.log("Swallowed write operation during replay: " + name);
|
||||
}
|
||||
|
||||
Vendored
+23
-3
@@ -6923,7 +6923,7 @@ interface IDBDatabase extends EventTarget {
|
||||
onerror: (ev: Event) => any;
|
||||
version: string;
|
||||
close(): void;
|
||||
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
|
||||
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
|
||||
deleteObjectStore(name: string): void;
|
||||
transaction(storeNames: any, mode?: string): IDBTransaction;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
@@ -6948,10 +6948,11 @@ declare var IDBFactory: {
|
||||
}
|
||||
|
||||
interface IDBIndex {
|
||||
keyPath: string;
|
||||
keyPath: string | string[];
|
||||
name: string;
|
||||
objectStore: IDBObjectStore;
|
||||
unique: boolean;
|
||||
multiEntry: boolean;
|
||||
count(key?: any): IDBRequest;
|
||||
get(key: any): IDBRequest;
|
||||
getKey(key: any): IDBRequest;
|
||||
@@ -6988,7 +6989,7 @@ interface IDBObjectStore {
|
||||
add(value: any, key?: any): IDBRequest;
|
||||
clear(): IDBRequest;
|
||||
count(key?: any): IDBRequest;
|
||||
createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex;
|
||||
createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex;
|
||||
delete(key: any): IDBRequest;
|
||||
deleteIndex(indexName: string): void;
|
||||
get(key: any): IDBRequest;
|
||||
@@ -12575,6 +12576,16 @@ interface XMLHttpRequestEventTarget {
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
interface IDBObjectStoreParameters {
|
||||
keyPath?: string | string[];
|
||||
autoIncrement?: boolean;
|
||||
}
|
||||
|
||||
interface IDBIndexParameters {
|
||||
unique?: boolean;
|
||||
multiEntry?: boolean;
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> extends NodeList {
|
||||
length: number;
|
||||
item(index: number): TNode;
|
||||
@@ -12610,6 +12621,15 @@ interface ProgressEventInit extends EventInit {
|
||||
total?: number;
|
||||
}
|
||||
|
||||
interface HTMLTemplateElement extends HTMLElement {
|
||||
content: DocumentFragment;
|
||||
}
|
||||
|
||||
declare var HTMLTemplateElement: {
|
||||
prototype: HTMLTemplateElement;
|
||||
new(): HTMLTemplateElement;
|
||||
}
|
||||
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
|
||||
Vendored
+14
-3
@@ -311,7 +311,7 @@ interface IDBDatabase extends EventTarget {
|
||||
onerror: (ev: Event) => any;
|
||||
version: string;
|
||||
close(): void;
|
||||
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
|
||||
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
|
||||
deleteObjectStore(name: string): void;
|
||||
transaction(storeNames: any, mode?: string): IDBTransaction;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
@@ -336,10 +336,11 @@ declare var IDBFactory: {
|
||||
}
|
||||
|
||||
interface IDBIndex {
|
||||
keyPath: string;
|
||||
keyPath: string | string[];
|
||||
name: string;
|
||||
objectStore: IDBObjectStore;
|
||||
unique: boolean;
|
||||
multiEntry: boolean;
|
||||
count(key?: any): IDBRequest;
|
||||
get(key: any): IDBRequest;
|
||||
getKey(key: any): IDBRequest;
|
||||
@@ -376,7 +377,7 @@ interface IDBObjectStore {
|
||||
add(value: any, key?: any): IDBRequest;
|
||||
clear(): IDBRequest;
|
||||
count(key?: any): IDBRequest;
|
||||
createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex;
|
||||
createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex;
|
||||
delete(key: any): IDBRequest;
|
||||
deleteIndex(indexName: string): void;
|
||||
get(key: any): IDBRequest;
|
||||
@@ -892,6 +893,16 @@ interface WorkerUtils extends Object, WindowBase64 {
|
||||
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
|
||||
}
|
||||
|
||||
interface IDBObjectStoreParameters {
|
||||
keyPath?: string | string[];
|
||||
autoIncrement?: boolean;
|
||||
}
|
||||
|
||||
interface IDBIndexParameters {
|
||||
unique?: boolean;
|
||||
multiEntry?: boolean;
|
||||
}
|
||||
|
||||
interface BlobPropertyBag {
|
||||
type?: string;
|
||||
endings?: string;
|
||||
|
||||
@@ -263,13 +263,11 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
resolvePath(path: string): string {
|
||||
const start = new Date().getTime();
|
||||
const result = this.host.resolvePath(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
fileExists(path: string): boolean {
|
||||
const start = new Date().getTime();
|
||||
const result = this.host.fileExists(path);
|
||||
return result;
|
||||
}
|
||||
@@ -325,32 +323,6 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
// assumes normalized paths
|
||||
function getAbsolutePath(filename: string, directory: string) {
|
||||
const rootLength = ts.getRootLength(filename);
|
||||
if (rootLength > 0) {
|
||||
return filename;
|
||||
}
|
||||
else {
|
||||
const splitFilename = filename.split("/");
|
||||
const splitDir = directory.split("/");
|
||||
let i = 0;
|
||||
let dirTail = 0;
|
||||
const sflen = splitFilename.length;
|
||||
while ((i < sflen) && (splitFilename[i].charAt(0) == ".")) {
|
||||
const dots = splitFilename[i];
|
||||
if (dots == "..") {
|
||||
dirTail++;
|
||||
}
|
||||
else if (dots != ".") {
|
||||
return undefined;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join("/");
|
||||
}
|
||||
}
|
||||
|
||||
export interface ProjectOptions {
|
||||
// these fields can be present in the project file
|
||||
files?: string[];
|
||||
@@ -514,7 +486,7 @@ namespace ts.server {
|
||||
// number becomes 0 for a watcher, then we should close it.
|
||||
directoryWatchersRefCount: ts.Map<number> = {};
|
||||
hostConfiguration: HostConfiguration;
|
||||
timerForDetectingProjectFilelistChanges: Map<NodeJS.Timer> = {};
|
||||
timerForDetectingProjectFileListChanges: Map<NodeJS.Timer> = {};
|
||||
|
||||
constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) {
|
||||
// ts.disableIncrementalParsing = true;
|
||||
@@ -569,21 +541,22 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
this.log("Detected source file changes: " + fileName);
|
||||
this.startTimerForDetectingProjectFilelistChanges(project);
|
||||
this.startTimerForDetectingProjectFileListChanges(project);
|
||||
}
|
||||
|
||||
startTimerForDetectingProjectFilelistChanges(project: Project) {
|
||||
if (this.timerForDetectingProjectFilelistChanges[project.projectFilename]) {
|
||||
clearTimeout(this.timerForDetectingProjectFilelistChanges[project.projectFilename]);
|
||||
startTimerForDetectingProjectFileListChanges(project: Project) {
|
||||
if (this.timerForDetectingProjectFileListChanges[project.projectFilename]) {
|
||||
clearTimeout(this.timerForDetectingProjectFileListChanges[project.projectFilename]);
|
||||
}
|
||||
this.timerForDetectingProjectFilelistChanges[project.projectFilename] = setTimeout(
|
||||
() => this.handleProjectFilelistChanges(project),
|
||||
this.timerForDetectingProjectFileListChanges[project.projectFilename] = setTimeout(
|
||||
() => this.handleProjectFileListChanges(project),
|
||||
250
|
||||
);
|
||||
}
|
||||
|
||||
handleProjectFilelistChanges(project: Project) {
|
||||
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename);
|
||||
handleProjectFileListChanges(project: Project) {
|
||||
const { projectOptions } = this.configFileToProjectOptions(project.projectFilename);
|
||||
|
||||
const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
|
||||
const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
|
||||
|
||||
@@ -611,7 +584,8 @@ namespace ts.server {
|
||||
|
||||
this.log("Detected newly added tsconfig file: " + fileName);
|
||||
|
||||
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(fileName);
|
||||
const { projectOptions } = this.configFileToProjectOptions(fileName);
|
||||
|
||||
const rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f));
|
||||
const openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName));
|
||||
|
||||
@@ -1109,7 +1083,6 @@ namespace ts.server {
|
||||
* Close file whose contents is managed by the client
|
||||
* @param filename is absolute pathname
|
||||
*/
|
||||
|
||||
closeClientFile(filename: string) {
|
||||
const info = ts.lookUp(this.filenameToScriptInfo, filename);
|
||||
if (info) {
|
||||
@@ -1765,9 +1738,9 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getLineMapper() {
|
||||
return ((line: number) => {
|
||||
return (line: number) => {
|
||||
return this.index.lineNumberToInfo(line).offset;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
getTextChangeRangeSinceVersion(scriptVersion: number) {
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
namespace ts.server {
|
||||
const nodeproto: typeof NodeJS._debugger = require("_debugger");
|
||||
const readline: NodeJS.ReadLine = require("readline");
|
||||
const path: NodeJS.Path = require("path");
|
||||
const fs: typeof NodeJS.fs = require("fs");
|
||||
|
||||
const rl = readline.createInterface({
|
||||
|
||||
@@ -129,9 +129,6 @@ namespace ts.server {
|
||||
|
||||
export class Session {
|
||||
protected projectService: ProjectService;
|
||||
private pendingOperation = false;
|
||||
private fileHash: ts.Map<number> = {};
|
||||
private nextFileId = 1;
|
||||
private errorTimer: any; /*NodeJS.Timer | number*/
|
||||
private immediateId: any;
|
||||
private changeSeq = 0;
|
||||
@@ -239,11 +236,6 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private errorCheck(file: string, project: Project) {
|
||||
this.syntacticCheck(file, project);
|
||||
this.semanticCheck(file, project);
|
||||
}
|
||||
|
||||
private reloadProjects() {
|
||||
this.projectService.reloadProjects();
|
||||
}
|
||||
@@ -901,7 +893,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getDiagnosticsForProject(delay: number, fileName: string) {
|
||||
const { configFileName, fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
|
||||
const { fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
|
||||
// No need to analyze lib.d.ts
|
||||
let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0);
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace ts.formatting {
|
||||
* the first token in line so it should be indented
|
||||
*/
|
||||
interface DynamicIndentation {
|
||||
getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind): number;
|
||||
getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number): number;
|
||||
getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind, container: Node): number;
|
||||
getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number, container: Node): number;
|
||||
/**
|
||||
* Indentation for open and close tokens of the node if it is block or another node that needs special indentation
|
||||
* ... {
|
||||
@@ -54,7 +54,7 @@ namespace ts.formatting {
|
||||
* so bar inherits indentation from foo and bar.delta will be 4
|
||||
*
|
||||
*/
|
||||
getDelta(): number;
|
||||
getDelta(child: TextRangeWithKind): number;
|
||||
/**
|
||||
* Formatter calls this function when rule adds or deletes new lines from the text
|
||||
* so indentation scope can adjust values of indentation and delta.
|
||||
@@ -282,19 +282,19 @@ namespace ts.formatting {
|
||||
*/
|
||||
function getOwnOrInheritedDelta(n: Node, options: FormatCodeOptions, sourceFile: SourceFile): number {
|
||||
let previousLine = Constants.Unknown;
|
||||
let childKind = SyntaxKind.Unknown;
|
||||
let child: Node;
|
||||
while (n) {
|
||||
let line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
if (previousLine !== Constants.Unknown && line !== previousLine) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (SmartIndenter.shouldIndentChildNode(n.kind, childKind)) {
|
||||
if (SmartIndenter.shouldIndentChildNode(n, child)) {
|
||||
return options.IndentSize;
|
||||
}
|
||||
|
||||
previousLine = line;
|
||||
childKind = n.kind;
|
||||
child = n;
|
||||
n = n.parent;
|
||||
}
|
||||
return 0;
|
||||
@@ -386,34 +386,7 @@ namespace ts.formatting {
|
||||
effectiveParentStartLine: number): Indentation {
|
||||
|
||||
let indentation = inheritedIndentation;
|
||||
if (indentation === Constants.Unknown) {
|
||||
if (isSomeBlock(node.kind)) {
|
||||
// blocks should be indented in
|
||||
// - other blocks
|
||||
// - source file
|
||||
// - switch\default clauses
|
||||
if (isSomeBlock(parent.kind) ||
|
||||
parent.kind === SyntaxKind.SourceFile ||
|
||||
parent.kind === SyntaxKind.CaseClause ||
|
||||
parent.kind === SyntaxKind.DefaultClause) {
|
||||
|
||||
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta();
|
||||
}
|
||||
else {
|
||||
indentation = parentDynamicIndentation.getIndentation();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) {
|
||||
indentation = parentDynamicIndentation.getIndentation();
|
||||
}
|
||||
else {
|
||||
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var delta = SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown) ? options.IndentSize : 0;
|
||||
var delta = SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0;
|
||||
|
||||
if (effectiveParentStartLine === startLine) {
|
||||
// if node is located on the same line with the parent
|
||||
@@ -422,8 +395,17 @@ namespace ts.formatting {
|
||||
indentation = startLine === lastIndentedLine
|
||||
? indentationOnLastIndentedLine
|
||||
: parentDynamicIndentation.getIndentation();
|
||||
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
|
||||
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta(node) + delta);
|
||||
}
|
||||
else if (indentation === Constants.Unknown) {
|
||||
if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) {
|
||||
indentation = parentDynamicIndentation.getIndentation();
|
||||
}
|
||||
else {
|
||||
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(node);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
indentation,
|
||||
delta
|
||||
@@ -455,7 +437,7 @@ namespace ts.formatting {
|
||||
|
||||
function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation {
|
||||
return {
|
||||
getIndentationForComment: (kind, tokenIndentation) => {
|
||||
getIndentationForComment: (kind, tokenIndentation, container) => {
|
||||
switch (kind) {
|
||||
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
|
||||
// .. {
|
||||
@@ -464,11 +446,11 @@ namespace ts.formatting {
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
case SyntaxKind.CloseBracketToken:
|
||||
case SyntaxKind.CloseParenToken:
|
||||
return indentation + delta;
|
||||
return indentation + getEffectiveDelta(delta, container);
|
||||
}
|
||||
return tokenIndentation !== Constants.Unknown ? tokenIndentation : indentation;
|
||||
},
|
||||
getIndentationForToken: (line, kind) => {
|
||||
getIndentationForToken: (line, kind, container) => {
|
||||
if (nodeStartLine !== line && node.decorators) {
|
||||
if (kind === getFirstNonDecoratorTokenOfNode(node)) {
|
||||
// if this token is the first token following the list of decorators, we do not need to indent
|
||||
@@ -489,13 +471,13 @@ namespace ts.formatting {
|
||||
return indentation;
|
||||
default:
|
||||
// if token line equals to the line of containing node (this is a first token in the node) - use node indentation
|
||||
return nodeStartLine !== line ? indentation + delta : indentation;
|
||||
return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation;
|
||||
}
|
||||
},
|
||||
getIndentation: () => indentation,
|
||||
getDelta: () => delta,
|
||||
getDelta: child => getEffectiveDelta(delta, child),
|
||||
recomputeIndentation: lineAdded => {
|
||||
if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent.kind, node.kind)) {
|
||||
if (node.parent && SmartIndenter.shouldIndentChildNode(node.parent, node)) {
|
||||
if (lineAdded) {
|
||||
indentation += options.IndentSize;
|
||||
}
|
||||
@@ -503,14 +485,19 @@ namespace ts.formatting {
|
||||
indentation -= options.IndentSize;
|
||||
}
|
||||
|
||||
if (SmartIndenter.shouldIndentChildNode(node.kind, SyntaxKind.Unknown)) {
|
||||
if (SmartIndenter.shouldIndentChildNode(node)) {
|
||||
delta = options.IndentSize;
|
||||
}
|
||||
else {
|
||||
delta = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function getEffectiveDelta(delta: number, child: TextRangeWithKind) {
|
||||
// Delta value should be zero when the node explicitly prevents indentation of the child node
|
||||
return SmartIndenter.nodeWillIndentChild(node, child, true) ? delta : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,7 +597,7 @@ namespace ts.formatting {
|
||||
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
|
||||
let tokenInfo = formattingScanner.readTokenInfo(child);
|
||||
Debug.assert(tokenInfo.token.end === child.end);
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation);
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
@@ -679,7 +666,7 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation): void {
|
||||
function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation, container?: Node): void {
|
||||
Debug.assert(rangeContainsRange(parent, currentTokenInfo.token));
|
||||
|
||||
let lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine();
|
||||
@@ -720,11 +707,11 @@ namespace ts.formatting {
|
||||
|
||||
if (indentToken) {
|
||||
let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
|
||||
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
|
||||
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) :
|
||||
Constants.Unknown;
|
||||
|
||||
if (currentTokenInfo.leadingTrivia) {
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container);
|
||||
let indentNextTokenOrTrivia = true;
|
||||
|
||||
for (let triviaItem of currentTokenInfo.leadingTrivia) {
|
||||
|
||||
@@ -123,6 +123,7 @@ namespace ts.formatting {
|
||||
public SpaceAfterModuleName: Rule;
|
||||
|
||||
// Lambda expressions
|
||||
public SpaceBeforeArrow: Rule;
|
||||
public SpaceAfterArrow: Rule;
|
||||
|
||||
// Optional parameters and let args
|
||||
@@ -254,7 +255,7 @@ namespace ts.formatting {
|
||||
|
||||
// No space before and after indexer
|
||||
this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext ), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
|
||||
|
||||
// Place a space before open brace in a function declaration
|
||||
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
|
||||
@@ -342,6 +343,7 @@ namespace ts.formatting {
|
||||
this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space));
|
||||
|
||||
// Lambda expressions
|
||||
this.SpaceBeforeArrow = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.EqualsGreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterArrow = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsGreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Optional parameters and let args
|
||||
@@ -379,8 +381,7 @@ namespace ts.formatting {
|
||||
this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// These rules are higher in priority than user-configurable rules.
|
||||
this.HighPriorityCommonRules =
|
||||
[
|
||||
this.HighPriorityCommonRules = [
|
||||
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
|
||||
this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator,
|
||||
this.NoSpaceAfterQuestionMark,
|
||||
@@ -411,7 +412,7 @@ namespace ts.formatting {
|
||||
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
|
||||
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
|
||||
this.SpaceAfterModuleName,
|
||||
this.SpaceAfterArrow,
|
||||
this.SpaceBeforeArrow, this.SpaceAfterArrow,
|
||||
this.NoSpaceAfterEllipsis,
|
||||
this.NoSpaceAfterOptionalParameters,
|
||||
this.NoSpaceBetweenEmptyInterfaceBraceBrackets,
|
||||
@@ -427,8 +428,7 @@ namespace ts.formatting {
|
||||
];
|
||||
|
||||
// These rules are lower in priority than user-configurable rules.
|
||||
this.LowPriorityCommonRules =
|
||||
[
|
||||
this.LowPriorityCommonRules = [
|
||||
this.NoSpaceBeforeSemicolon,
|
||||
this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock,
|
||||
this.NoSpaceBeforeComma,
|
||||
@@ -732,7 +732,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
static IsStartOfVariableDeclarationList(context: FormattingContext): boolean {
|
||||
return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList &&
|
||||
return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList &&
|
||||
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace ts.formatting {
|
||||
let indentationDelta: number;
|
||||
|
||||
while (current) {
|
||||
if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : SyntaxKind.Unknown)) {
|
||||
if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) {
|
||||
currentStart = getStartLineAndCharacterForNode(current, sourceFile);
|
||||
|
||||
if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) {
|
||||
@@ -153,7 +153,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
// increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line
|
||||
if (shouldIndentChildNode(parent.kind, current.kind) && !parentAndChildShareLine) {
|
||||
if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) {
|
||||
indentationDelta += options.IndentSize;
|
||||
}
|
||||
|
||||
@@ -466,12 +466,10 @@ namespace ts.formatting {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function shouldIndentChildNode(parent: SyntaxKind, child: SyntaxKind): boolean {
|
||||
if (nodeContentIsAlwaysIndented(parent)) {
|
||||
return true;
|
||||
}
|
||||
switch (parent) {
|
||||
|
||||
export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) {
|
||||
let childKind = child ? child.kind : SyntaxKind.Unknown;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
@@ -485,10 +483,17 @@ namespace ts.formatting {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return child !== SyntaxKind.Block;
|
||||
default:
|
||||
return false;
|
||||
return childKind !== SyntaxKind.Block;
|
||||
}
|
||||
// No explicit rule for given nodes so the result will follow the default value argument
|
||||
return indentByDefault;
|
||||
}
|
||||
|
||||
/*
|
||||
Function returns true when the parent node should indent the given child by an explicit rule
|
||||
*/
|
||||
export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean {
|
||||
return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+550
-542
File diff suppressed because it is too large
Load Diff
@@ -20,12 +20,12 @@ var Cell = (function () {
|
||||
function Cell() {
|
||||
}
|
||||
return Cell;
|
||||
})();
|
||||
}());
|
||||
var Ship = (function () {
|
||||
function Ship() {
|
||||
}
|
||||
return Ship;
|
||||
})();
|
||||
}());
|
||||
var Board = (function () {
|
||||
function Board() {
|
||||
}
|
||||
@@ -33,4 +33,4 @@ var Board = (function () {
|
||||
return this.ships.every(function (val) { return val.isSunk; });
|
||||
};
|
||||
return Board;
|
||||
})();
|
||||
}());
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ var A;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
})(A || (A = {}));
|
||||
//// [test.js]
|
||||
|
||||
+6
-6
@@ -55,7 +55,7 @@ var clodule1 = (function () {
|
||||
function clodule1() {
|
||||
}
|
||||
return clodule1;
|
||||
})();
|
||||
}());
|
||||
var clodule1;
|
||||
(function (clodule1) {
|
||||
function f(x) { }
|
||||
@@ -64,7 +64,7 @@ var clodule2 = (function () {
|
||||
function clodule2() {
|
||||
}
|
||||
return clodule2;
|
||||
})();
|
||||
}());
|
||||
var clodule2;
|
||||
(function (clodule2) {
|
||||
var x;
|
||||
@@ -72,13 +72,13 @@ var clodule2;
|
||||
function D() {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
}());
|
||||
})(clodule2 || (clodule2 = {}));
|
||||
var clodule3 = (function () {
|
||||
function clodule3() {
|
||||
}
|
||||
return clodule3;
|
||||
})();
|
||||
}());
|
||||
var clodule3;
|
||||
(function (clodule3) {
|
||||
clodule3.y = { id: T };
|
||||
@@ -87,12 +87,12 @@ var clodule4 = (function () {
|
||||
function clodule4() {
|
||||
}
|
||||
return clodule4;
|
||||
})();
|
||||
}());
|
||||
var clodule4;
|
||||
(function (clodule4) {
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
}());
|
||||
})(clodule4 || (clodule4 = {}));
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ var clodule = (function () {
|
||||
}
|
||||
clodule.fn = function (id) { };
|
||||
return clodule;
|
||||
})();
|
||||
}());
|
||||
var clodule;
|
||||
(function (clodule) {
|
||||
// error: duplicate identifier expected
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ var clodule = (function () {
|
||||
}
|
||||
clodule.fn = function (id) { };
|
||||
return clodule;
|
||||
})();
|
||||
}());
|
||||
var clodule;
|
||||
(function (clodule) {
|
||||
// error: duplicate identifier expected
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ var clodule = (function () {
|
||||
}
|
||||
clodule.sfn = function (id) { return 42; };
|
||||
return clodule;
|
||||
})();
|
||||
}());
|
||||
var clodule;
|
||||
(function (clodule) {
|
||||
// error: duplicate identifier expected
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ var Point = (function () {
|
||||
}
|
||||
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
var Point;
|
||||
(function (Point) {
|
||||
function Origin() { return null; }
|
||||
@@ -45,7 +45,7 @@ var A;
|
||||
}
|
||||
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
var Point;
|
||||
(function (Point) {
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ var Point = (function () {
|
||||
}
|
||||
Point.Origin = function () { return { x: 0, y: 0 }; };
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
var Point;
|
||||
(function (Point) {
|
||||
function Origin() { return ""; } // not an error, since not exported
|
||||
@@ -44,7 +44,7 @@ var A;
|
||||
}
|
||||
Point.Origin = function () { return { x: 0, y: 0 }; };
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
var Point;
|
||||
(function (Point) {
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ var Point = (function () {
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
var Point;
|
||||
(function (Point) {
|
||||
Point.Origin = ""; //expected duplicate identifier error
|
||||
@@ -44,7 +44,7 @@ var A;
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
var Point;
|
||||
(function (Point) {
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ var Point = (function () {
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
var Point;
|
||||
(function (Point) {
|
||||
var Origin = ""; // not an error, since not exported
|
||||
@@ -44,7 +44,7 @@ var A;
|
||||
}
|
||||
Point.Origin = { x: 0, y: 0 };
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
var Point;
|
||||
(function (Point) {
|
||||
|
||||
@@ -51,7 +51,7 @@ var X;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
Y.Point = Point;
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
})(X || (X = {}));
|
||||
@@ -75,7 +75,7 @@ var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
}());
|
||||
var A;
|
||||
(function (A) {
|
||||
A.Instance = new A();
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -10,4 +10,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -10,4 +10,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.bar = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -10,4 +10,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype[1] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -10,4 +10,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype["bar"] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -7,4 +7,4 @@ var any = (function () {
|
||||
function any() {
|
||||
}
|
||||
return any;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -14,4 +14,4 @@ var List = (function () {
|
||||
function List() {
|
||||
}
|
||||
return List;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -11,5 +11,5 @@ var C = (function () {
|
||||
this.foo = 10;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
var constructor = function () { };
|
||||
|
||||
@@ -8,4 +8,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -8,4 +8,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var AtomicNumbers = (function () {
|
||||
}
|
||||
AtomicNumbers.H = 1;
|
||||
return AtomicNumbers;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -10,4 +10,4 @@ var C = (function () {
|
||||
this.x = 10;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts(4,8): error TS4033: Property 'f' of exported interface has or is using private name 'T'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts (1 errors) ====
|
||||
|
||||
type T = { x : number }
|
||||
export interface I {
|
||||
f: T;
|
||||
~
|
||||
!!! error TS4033: Property 'f' of exported interface has or is using private name 'T'.
|
||||
}
|
||||
@@ -32,4 +32,4 @@ var StringIterator = (function () {
|
||||
return this;
|
||||
};
|
||||
return StringIterator;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -19,7 +19,7 @@ var M;
|
||||
}
|
||||
C.prototype[Symbol.iterator] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
M.C = C;
|
||||
(new C)[Symbol.iterator];
|
||||
})(M || (M = {}));
|
||||
|
||||
@@ -14,5 +14,5 @@ var C = (function () {
|
||||
}
|
||||
C.prototype[Symbol.iterator] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
(new C)[Symbol.iterator];
|
||||
|
||||
@@ -14,5 +14,5 @@ var C = (function () {
|
||||
}
|
||||
C.prototype[Symbol.iterator] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
(new C)[Symbol.iterator];
|
||||
|
||||
@@ -14,5 +14,5 @@ var C = (function () {
|
||||
}
|
||||
C.prototype[Symbol.iterator] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
(new C)[Symbol.iterator](0); // Should error
|
||||
|
||||
@@ -11,5 +11,5 @@ var C = (function () {
|
||||
}
|
||||
C.prototype[Symbol.iterator] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
(new C)[Symbol.iterator];
|
||||
|
||||
@@ -14,5 +14,5 @@ var C = (function () {
|
||||
}
|
||||
C.prototype[Symbol.iterator] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
(new C)[Symbol.iterator];
|
||||
|
||||
@@ -30,7 +30,7 @@ var enumdule;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
enumdule.Point = Point;
|
||||
})(enumdule || (enumdule = {}));
|
||||
var x;
|
||||
|
||||
@@ -10,5 +10,5 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
exports.C = C;
|
||||
|
||||
@@ -10,5 +10,5 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
exports.C = C;
|
||||
|
||||
@@ -31,6 +31,6 @@ var A;
|
||||
return 1;
|
||||
};
|
||||
return Point2d;
|
||||
})();
|
||||
}());
|
||||
A.Point2d = Point2d;
|
||||
})(A || (A = {}));
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ var A;
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
A.Origin = { x: 0, y: 0 };
|
||||
var Point3d = (function (_super) {
|
||||
@@ -41,7 +41,7 @@ var A;
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return Point3d;
|
||||
})(Point);
|
||||
}(Point));
|
||||
A.Point3d = Point3d;
|
||||
A.Origin3d = { x: 0, y: 0, z: 0 };
|
||||
var Line = (function () {
|
||||
@@ -50,6 +50,6 @@ var A;
|
||||
this.end = end;
|
||||
}
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
A.Line = Line;
|
||||
})(A || (A = {}));
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ var A;
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
var points = (function () {
|
||||
function points() {
|
||||
}
|
||||
return points;
|
||||
})();
|
||||
}());
|
||||
A.points = points;
|
||||
})(A || (A = {}));
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ var A;
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Origin = { x: 0, y: 0 };
|
||||
var Point3d = (function (_super) {
|
||||
__extends(Point3d, _super);
|
||||
@@ -44,7 +44,7 @@ var A;
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return Point3d;
|
||||
})(Point);
|
||||
}(Point));
|
||||
A.Point3d = Point3d;
|
||||
A.Origin3d = { x: 0, y: 0, z: 0 };
|
||||
var Line = (function () {
|
||||
@@ -56,6 +56,6 @@ var A;
|
||||
return null;
|
||||
};
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
A.Line = Line;
|
||||
})(A || (A = {}));
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ var A;
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
var Line = (function () {
|
||||
function Line(start, end) {
|
||||
@@ -30,7 +30,7 @@ var A;
|
||||
this.end = end;
|
||||
}
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
A.Line = Line;
|
||||
function fromOrigin(p) {
|
||||
return new Line({ x: 0, y: 0 }, p);
|
||||
|
||||
+2
-2
@@ -22,14 +22,14 @@ var A;
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
var Line = (function () {
|
||||
function Line(start, end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
A.Line = Line;
|
||||
function fromOrigin(p) {
|
||||
return new Line({ x: 0, y: 0 }, p);
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ var A;
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
var Line = (function () {
|
||||
function Line(start, end) {
|
||||
@@ -30,7 +30,7 @@ var A;
|
||||
this.end = end;
|
||||
}
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
function fromOrigin(p) {
|
||||
return new Line({ x: 0, y: 0 }, p);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ var A;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
var B;
|
||||
(function (B) {
|
||||
@@ -41,7 +41,7 @@ var A;
|
||||
return new Line({ x: 0, y: 0 }, p);
|
||||
};
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
B.Line = Line;
|
||||
})(B = A.B || (A.B = {}));
|
||||
})(A || (A = {}));
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ var A;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Origin = { x: 0, y: 0 };
|
||||
A.Unity = { start: new Point(0, 0), end: new Point(1, 0) };
|
||||
})(A || (A = {}));
|
||||
|
||||
+1
-1
@@ -20,6 +20,6 @@ var A;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.UnitSquare = null;
|
||||
})(A || (A = {}));
|
||||
|
||||
+1
-1
@@ -15,6 +15,6 @@ var A;
|
||||
function B() {
|
||||
}
|
||||
return B;
|
||||
})();
|
||||
}());
|
||||
A.beez2 = new Array();
|
||||
})(A || (A = {}));
|
||||
|
||||
@@ -13,4 +13,4 @@ var C = (function () {
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype[foo] = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype. = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -8,4 +8,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -8,4 +8,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -19,4 +19,4 @@ var C = (function () {
|
||||
return bar;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -54,7 +54,7 @@ var X;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
Y.Point = Point;
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
})(X || (X = {}));
|
||||
@@ -68,4 +68,4 @@ var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -25,7 +25,7 @@ var enumdule;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
enumdule.Point = Point;
|
||||
})(enumdule || (enumdule = {}));
|
||||
var enumdule;
|
||||
|
||||
@@ -40,24 +40,24 @@ var A;
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
}());
|
||||
A_1.A = A;
|
||||
var AG = (function () {
|
||||
function AG() {
|
||||
}
|
||||
return AG;
|
||||
})();
|
||||
}());
|
||||
A_1.AG = AG;
|
||||
var A2 = (function () {
|
||||
function A2() {
|
||||
}
|
||||
return A2;
|
||||
})();
|
||||
}());
|
||||
var AG2 = (function () {
|
||||
function AG2() {
|
||||
}
|
||||
return AG2;
|
||||
})();
|
||||
}());
|
||||
})(A || (A = {}));
|
||||
// no errors expected, these are all exported
|
||||
var a;
|
||||
|
||||
@@ -48,7 +48,7 @@ var B;
|
||||
this.end = end;
|
||||
}
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
B.Line = Line;
|
||||
})(B || (B = {}));
|
||||
var Geometry;
|
||||
|
||||
@@ -45,7 +45,7 @@ var Inner;
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
}());
|
||||
var B;
|
||||
(function (B) {
|
||||
B.a = 1, B.c = 2;
|
||||
@@ -63,7 +63,7 @@ var Inner;
|
||||
function D() {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
}());
|
||||
Inner.e1 = new D;
|
||||
Inner.f1 = new D;
|
||||
Inner.g1 = new D;
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
function C(C) {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -11,4 +11,4 @@ var C1 = (function () {
|
||||
this.p3 = p3;
|
||||
} // OK
|
||||
return C1;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -7,4 +7,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -8,4 +8,4 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
}
|
||||
C.prototype.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
@@ -9,4 +9,4 @@ var C = (function () {
|
||||
this.p = p;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
}());
|
||||
|
||||
+4
-4
@@ -47,7 +47,7 @@ var A;
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
A.Point = Point;
|
||||
})(A || (A = {}));
|
||||
var A;
|
||||
@@ -59,7 +59,7 @@ var A;
|
||||
return { x: p.x, y: p.y };
|
||||
};
|
||||
return Point;
|
||||
})();
|
||||
}());
|
||||
})(A || (A = {}));
|
||||
// ensure merges as expected
|
||||
var p;
|
||||
@@ -74,7 +74,7 @@ var X;
|
||||
function Line() {
|
||||
}
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
Z.Line = Line;
|
||||
})(Z = Y.Z || (Y.Z = {}));
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
@@ -89,7 +89,7 @@ var X;
|
||||
function Line() {
|
||||
}
|
||||
return Line;
|
||||
})();
|
||||
}());
|
||||
})(Z = Y.Z || (Y.Z = {}));
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
})(X || (X = {}));
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ var A;
|
||||
this.br = br;
|
||||
}
|
||||
return Plane;
|
||||
})();
|
||||
}());
|
||||
Utils.Plane = Plane;
|
||||
})(Utils = A.Utils || (A.Utils = {}));
|
||||
})(A || (A = {}));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user