merge with master/address PR feedback

This commit is contained in:
Vladimir Matveev
2015-10-16 11:21:32 -07:00
864 changed files with 21947 additions and 3723 deletions
+5 -1
View File
@@ -3,7 +3,11 @@ doc
scripts
src
tests
internal
tslint.json
Jakefile.js
.travis.yml
.editorconfig
.gitattributes
.settings/
.travis.yml
.vscode/
+2 -1
View File
@@ -1,6 +1,7 @@
language: node_js
node_js:
- '4'
- '0.10'
sudo: false
sudo: false
+11 -7
View File
@@ -628,10 +628,9 @@ function deleteTemporaryProjectOutput() {
var testTimeout = 20000;
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]', debug=true.");
task("runtests", ["tests", builtLocalDirectory], function() {
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
cleanTestDirs();
var debug = process.env.debug || process.env.d;
host = "mocha"
tests = process.env.test || process.env.tests || process.env.t;
var light = process.env.light || false;
var testConfigFile = 'test.config';
@@ -653,9 +652,16 @@ task("runtests", ["tests", builtLocalDirectory], function() {
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
var cmd = host + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
console.log(cmd);
exec(cmd, deleteTemporaryProjectOutput);
exec(cmd, function() {
deleteTemporaryProjectOutput();
var lint = jake.Task['lint'];
lint.addListener('complete', function () {
complete();
});
lint.invoke();
});
}, {async: true});
desc("Generates code coverage data via instanbul");
@@ -825,7 +831,7 @@ var tslintRulesOutFiles = tslintRules.map(function(p) {
desc("Compiles tslint rules to js");
task("build-rules", tslintRulesOutFiles);
tslintRulesFiles.forEach(function(ruleFile, i) {
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ true, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint"));
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint"));
});
function getLinterOptions() {
@@ -859,8 +865,6 @@ function lintFileAsync(options, path, cb) {
var lintTargets = compilerSources.concat(harnessCoreSources);
// if the codebase were free of linter errors we could make jake runtests
// run this task automatically
desc("Runs tslint on the compiler sources");
task("lint", ["build-rules"], function() {
var lintOptions = getLinterOptions();
+1 -28
View File
@@ -3965,34 +3965,7 @@ interface ObjectConstructor {
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source The source object from which to copy properties.
*/
assign<T, U>(target: T, source: U): T & U;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
*/
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
* @param source3 The third source object from which to copy properties.
*/
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
* @param sources One or more source objects to copy properties from.
*/
assign(target: any, ...sources: any[]): any;
+1 -1
View File
@@ -40,7 +40,7 @@
},
"scripts": {
"pretest": "jake tests",
"test": "jake runtests && npm run lint",
"test": "jake runtests",
"build": "npm run build:compiler && npm run build:tests",
"build:compiler": "jake local",
"build:tests": "jake tests",
+9 -1
View File
@@ -185,8 +185,9 @@ namespace ts {
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
Debug.assert(!hasDynamicName(node));
let isDefaultExport = node.flags & NodeFlags.Default;
// The exported symbol for an export default function/class node is always named "default"
let name = node.flags & NodeFlags.Default && parent ? "default" : getDeclarationName(node);
let name = isDefaultExport && parent ? "default" : getDeclarationName(node);
let symbol: Symbol;
if (name !== undefined) {
@@ -227,6 +228,13 @@ namespace ts {
let message = symbol.flags & SymbolFlags.BlockScopedVariable
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
: Diagnostics.Duplicate_identifier_0;
forEach(symbol.declarations, declaration => {
if (declaration.flags & NodeFlags.Default) {
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
}
});
forEach(symbol.declarations, declaration => {
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
});
+185 -133
View File
@@ -383,20 +383,72 @@ namespace ts {
// return undefined if we can't find a symbol.
}
/** Returns true if node1 is defined before node 2**/
function isDefinedBefore(node1: Node, node2: Node): boolean {
let file1 = getSourceFileOfNode(node1);
let file2 = getSourceFileOfNode(node2);
if (file1 === file2) {
return node1.pos <= node2.pos;
function isBlockScopedNameDeclaredBeforeUse(declaration: Declaration, usage: Node): boolean {
const declarationFile = getSourceFileOfNode(declaration);
const useFile = getSourceFileOfNode(usage);
if (declarationFile !== useFile) {
if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) {
// nodes are in different files and order cannot be determines
return true;
}
const sourceFiles = host.getSourceFiles();
return indexOf(sourceFiles, declarationFile) <= indexOf(sourceFiles, useFile);
}
if (!compilerOptions.outFile && !compilerOptions.out) {
return true;
if (declaration.pos <= usage.pos) {
// declaration is before usage
// still might be illegal if usage is in the initializer of the variable declaration
return declaration.kind !== SyntaxKind.VariableDeclaration ||
!isImmediatelyUsedInInitializerOfBlockScopedVariable(<VariableDeclaration>declaration, usage);
}
let sourceFiles = host.getSourceFiles();
return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2);
// declaration is after usage
// can be legal if usage is deferred (i.e. inside function or in initializer of instance property)
return isUsedInFunctionOrNonStaticProperty(declaration, usage);
function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean {
const container = getEnclosingBlockScopeContainer(declaration);
if (declaration.parent.parent.kind === SyntaxKind.VariableStatement ||
declaration.parent.parent.kind === SyntaxKind.ForStatement) {
// variable statement/for statement case,
// use site should not be inside variable declaration (initializer of declaration or binding element)
return isSameScopeDescendentOf(usage, declaration, container);
}
else if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement ||
declaration.parent.parent.kind === SyntaxKind.ForInStatement) {
// ForIn/ForOf case - use site should not be used in expression part
let expression = (<ForInStatement | ForOfStatement>declaration.parent.parent).expression;
return isSameScopeDescendentOf(usage, expression, container);
}
}
function isUsedInFunctionOrNonStaticProperty(declaration: Declaration, usage: Node): boolean {
const container = getEnclosingBlockScopeContainer(declaration);
let current = usage;
while (current) {
if (current === container) {
return false;
}
if (isFunctionLike(current)) {
return true;
}
const initializerOfNonStaticProperty = current.parent &&
current.parent.kind === SyntaxKind.PropertyDeclaration &&
(current.parent.flags & NodeFlags.Static) === 0 &&
(<PropertyDeclaration>current.parent).initializer === current;
if (initializerOfNonStaticProperty) {
return true;
}
current = current.parent;
}
return false;
}
}
// Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
@@ -610,8 +662,11 @@ namespace ts {
// block - scope variable and namespace module. However, only when we
// try to resolve name in /*1*/ which is used in variable position,
// we want to check for block- scoped
if (meaning & SymbolFlags.BlockScopedVariable && result.flags & SymbolFlags.BlockScopedVariable) {
checkResolvedBlockScopedVariable(result, errorLocation);
if (meaning & SymbolFlags.BlockScopedVariable) {
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable) {
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
}
}
}
return result;
@@ -624,34 +679,7 @@ namespace ts {
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
// first check if usage is lexically located after the declaration
let isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation);
if (!isUsedBeforeDeclaration) {
// lexical check succeeded however code still can be illegal.
// - block scoped variables cannot be used in its initializers
// let x = x; // illegal but usage is lexically after definition
// - in ForIn/ForOf statements variable cannot be contained in expression part
// for (let x in x)
// for (let x of x)
// climb up to the variable declaration skipping binding patterns
let variableDeclaration = <VariableDeclaration>getAncestor(declaration, SyntaxKind.VariableDeclaration);
let container = getEnclosingBlockScopeContainer(variableDeclaration);
if (variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement ||
variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement) {
// variable statement/for statement case,
// use site should not be inside variable declaration (initializer of declaration or binding element)
isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container);
}
else if (variableDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement ||
variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
// ForIn/ForOf case - use site should not be used in expression part
let expression = (<ForInStatement | ForOfStatement>variableDeclaration.parent.parent).expression;
isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container);
}
}
if (isUsedBeforeDeclaration) {
if (!isBlockScopedNameDeclaredBeforeUse(<Declaration>getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) {
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
}
}
@@ -2209,7 +2237,7 @@ namespace ts {
/**
* Push an entry on the type resolution stack. If an entry with the given target and the given property name
* is already on the stack, and no entries in between already have a type, then a circularity has occurred.
* is already on the stack, and no entries in between already have a type, then a circularity has occurred.
* In this case, the result values of the existing entry and all entries pushed after it are changed to false,
* and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned.
* In order to see if the same query has already been done before, the target object and the propertyName both
@@ -3171,8 +3199,8 @@ namespace ts {
members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1);
callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature);
constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature);
stringIndexType = source.declaredStringIndexType ? instantiateType(source.declaredStringIndexType, mapper) : undefined;
numberIndexType = source.declaredNumberIndexType ? instantiateType(source.declaredNumberIndexType, mapper) : undefined;
stringIndexType = instantiateType(source.declaredStringIndexType, mapper);
numberIndexType = instantiateType(source.declaredNumberIndexType, mapper);
}
let baseTypes = getBaseTypes(source);
if (baseTypes.length) {
@@ -3371,7 +3399,7 @@ namespace ts {
setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType);
}
function resolveAnonymousTypeMembers(type: ObjectType) {
function resolveAnonymousTypeMembers(type: AnonymousType) {
let symbol = type.symbol;
let members: SymbolTable;
let callSignatures: Signature[];
@@ -3379,7 +3407,14 @@ namespace ts {
let stringIndexType: Type;
let numberIndexType: Type;
if (symbol.flags & SymbolFlags.TypeLiteral) {
if (type.target) {
members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
callSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Call), type.mapper, instantiateSignature);
constructSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper, instantiateSignature);
stringIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.String), type.mapper);
numberIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.Number), type.mapper);
}
else if (symbol.flags & SymbolFlags.TypeLiteral) {
members = symbol.members;
callSignatures = getSignaturesOfSymbol(members["__call"]);
constructSignatures = getSignaturesOfSymbol(members["__new"]);
@@ -3424,7 +3459,7 @@ namespace ts {
resolveClassOrInterfaceMembers(<InterfaceType>type);
}
else if (type.flags & TypeFlags.Anonymous) {
resolveAnonymousTypeMembers(<ObjectType>type);
resolveAnonymousTypeMembers(<AnonymousType>type);
}
else if (type.flags & TypeFlags.Tuple) {
resolveTupleTypeMembers(<TupleType>type);
@@ -4543,7 +4578,7 @@ namespace ts {
}
let result = createSignature(signature.declaration, freshTypeParameters,
instantiateList(signature.parameters, mapper, instantiateSymbol),
signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined,
instantiateType(signature.resolvedReturnType, mapper),
freshTypePredicate,
signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals);
result.target = signature;
@@ -4575,7 +4610,7 @@ namespace ts {
return result;
}
function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType {
function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): ObjectType {
if (mapper.instantiations) {
let cachedType = mapper.instantiations[type.id];
if (cachedType) {
@@ -4586,27 +4621,21 @@ namespace ts {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
let result = <ResolvedType>createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
result.members = createSymbolTable(result.properties);
result.callSignatures = instantiateList(getSignaturesOfType(type, SignatureKind.Call), mapper, instantiateSignature);
result.constructSignatures = instantiateList(getSignaturesOfType(type, SignatureKind.Construct), mapper, instantiateSignature);
let stringIndexType = getIndexTypeOfType(type, IndexKind.String);
let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
let result = <AnonymousType>createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol);
result.target = type;
result.mapper = mapper;
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type: Type, mapper: TypeMapper): Type {
if (mapper !== identityMapper) {
if (type && mapper !== identityMapper) {
if (type.flags & TypeFlags.TypeParameter) {
return mapper(<TypeParameter>type);
}
if (type.flags & TypeFlags.Anonymous) {
return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) ?
instantiateAnonymousType(<ObjectType>type, mapper) : type;
instantiateAnonymousType(<AnonymousType>type, mapper) : type;
}
if (type.flags & TypeFlags.Reference) {
return createTypeReference((<TypeReference>type).target, instantiateList((<TypeReference>type).typeArguments, mapper, instantiateType));
@@ -5242,7 +5271,7 @@ namespace ts {
// Only want to compare the construct signatures for abstractness guarantees.
// Because the "abstractness" of a class is the same across all construct signatures
// (internally we are checking the corresponding declaration), it is enough to perform
// (internally we are checking the corresponding declaration), it is enough to perform
// the check and report an error once over all pairs of source and target construct signatures.
//
// sourceSig and targetSig are (possibly) undefined.
@@ -6641,7 +6670,7 @@ namespace ts {
let needToCaptureLexicalThis = false;
if (!isCallExpression) {
// adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
// adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
while (container && container.kind === SyntaxKind.ArrowFunction) {
container = getSuperContainer(container, /*includeFunctions*/ true);
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
@@ -6651,7 +6680,7 @@ namespace ts {
let canUseSuperExpression = isLegalUsageOfSuperExpression(container);
let nodeCheckFlag: NodeCheckFlags = 0;
// always set NodeCheckFlags for 'super' expression node
// always set NodeCheckFlags for 'super' expression node
if (canUseSuperExpression) {
if ((container.flags & NodeFlags.Static) || isCallExpression) {
nodeCheckFlag = NodeCheckFlags.SuperStatic;
@@ -7312,15 +7341,15 @@ namespace ts {
}
function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type {
let inDestructuringPattern = isAssignmentTarget(node);
// Grammar checking
checkGrammarObjectLiteralExpression(node);
checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
let propertiesTable: SymbolTable = {};
let propertiesArray: Symbol[] = [];
let contextualType = getContextualType(node);
let contextualTypeHasPattern = contextualType && contextualType.pattern &&
(contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression);
let inDestructuringPattern = isAssignmentTarget(node);
let typeFlags: TypeFlags = 0;
for (let memberDecl of node.properties) {
@@ -7344,7 +7373,10 @@ namespace ts {
if (inDestructuringPattern) {
// If object literal is an assignment pattern and if the assignment pattern specifies a default value
// for the property, make the property optional.
if (memberDecl.kind === SyntaxKind.PropertyAssignment && hasDefaultValue((<PropertyAssignment>memberDecl).initializer)) {
const isOptional =
(memberDecl.kind === SyntaxKind.PropertyAssignment && hasDefaultValue((<PropertyAssignment>memberDecl).initializer)) ||
(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment && (<ShorthandPropertyAssignment>memberDecl).objectAssignmentInitializer);
if (isOptional) {
prop.flags |= SymbolFlags.Optional;
}
}
@@ -7631,7 +7663,9 @@ namespace ts {
// Look up the value in the current scope
if (valueSymbol && valueSymbol !== unknownSymbol) {
links.jsxFlags |= JsxFlags.ClassElement;
getSymbolLinks(valueSymbol).referenced = true;
if (valueSymbol.flags & SymbolFlags.Alias) {
markAliasSymbolAsReferenced(valueSymbol);
}
}
return valueSymbol || unknownSymbol;
@@ -7975,6 +8009,11 @@ namespace ts {
return true;
}
// An instance property must be accessed through an instance of the enclosing class
if (type.flags & TypeFlags.ThisType) {
// get the original type -- represented as the type constraint of the 'this' type
type = getConstraintOfTypeParameter(<TypeParameter>type);
}
// TODO: why is the first part of this check here?
if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(<InterfaceType>type, enclosingClass))) {
error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
@@ -8122,6 +8161,7 @@ namespace ts {
/**
* If indexArgumentExpression is a string literal or number literal, returns its text.
* If indexArgumentExpression is a constant value, returns its string value.
* If indexArgumentExpression is a well known symbol, returns the property name corresponding
* to this symbol, as long as it is a proper symbol reference.
* Otherwise, returns undefined.
@@ -8130,6 +8170,12 @@ namespace ts {
if (indexArgumentExpression.kind === SyntaxKind.StringLiteral || indexArgumentExpression.kind === SyntaxKind.NumericLiteral) {
return (<LiteralExpression>indexArgumentExpression).text;
}
if (indexArgumentExpression.kind === SyntaxKind.ElementAccessExpression || indexArgumentExpression.kind === SyntaxKind.PropertyAccessExpression) {
let value = getConstantValue(<ElementAccessExpression | PropertyAccessExpression>indexArgumentExpression);
if (value !== undefined) {
return value.toString();
}
}
if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) {
let rightHandSideName = (<Identifier>(<PropertyAccessExpression>indexArgumentExpression).name).text;
return getPropertyNameForKnownSymbolName(rightHandSideName);
@@ -8565,7 +8611,7 @@ namespace ts {
// A method or accessor declaration decorator will have two or three arguments (see
// `PropertyDecorator` and `MethodDecorator` in core.d.ts)
// If we are emitting decorators for ES3, we will only pass two arguments.
// If we are emitting decorators for ES3, we will only pass two arguments.
if (languageVersion === ScriptTarget.ES3) {
return 2;
}
@@ -9741,7 +9787,7 @@ namespace ts {
return !symbol || symbol === unknownSymbol || (symbol.flags & ~SymbolFlags.EnumMember) !== 0;
}
case SyntaxKind.ElementAccessExpression:
// old compiler doesn't check indexed assess
// old compiler doesn't check indexed access
return true;
case SyntaxKind.ParenthesizedExpression:
return isReferenceOrErrorExpression((<ParenthesizedExpression>n).expression);
@@ -9899,32 +9945,32 @@ namespace ts {
return (symbol.flags & SymbolFlags.ConstEnum) !== 0;
}
function checkInstanceOfExpression(node: BinaryExpression, leftType: Type, rightType: Type): Type {
function checkInstanceOfExpression(left: Expression, right: Expression, leftType: Type, rightType: Type): Type {
// TypeScript 1.0 spec (April 2014): 4.15.4
// The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type,
// and the right operand to be of type Any or a subtype of the 'Function' interface type.
// The result is always of the Boolean primitive type.
// NOTE: do not raise error if leftType is unknown as related error was already reported
if (allConstituentTypesHaveKind(leftType, TypeFlags.Primitive)) {
error(node.left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
// NOTE: do not raise error if right is unknown as related error was already reported
if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
error(node.right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
error(right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
}
return booleanType;
}
function checkInExpression(node: BinaryExpression, leftType: Type, rightType: Type): Type {
function checkInExpression(left: Expression, right: Expression, leftType: Type, rightType: Type): Type {
// TypeScript 1.0 spec (April 2014): 4.15.5
// The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type,
// and the right operand to be of type Any, an object type, or a type parameter type.
// The result is always of the Boolean primitive type.
if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
error(node.left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
}
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
error(node.right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
return booleanType;
}
@@ -9941,7 +9987,12 @@ namespace ts {
isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) ||
getIndexTypeOfType(sourceType, IndexKind.String);
if (type) {
checkDestructuringAssignment((<PropertyAssignment>p).initializer || name, type);
if (p.kind === SyntaxKind.ShorthandPropertyAssignment) {
checkDestructuringAssignment(<ShorthandPropertyAssignment>p, type);
}
else {
checkDestructuringAssignment((<PropertyAssignment>p).initializer || name, type);
}
}
else {
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), declarationNameToString(name));
@@ -10001,7 +10052,19 @@ namespace ts {
return sourceType;
}
function checkDestructuringAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type {
function checkDestructuringAssignment(exprOrAssignment: Expression | ShorthandPropertyAssignment, sourceType: Type, contextualMapper?: TypeMapper): Type {
let target: Expression;
if (exprOrAssignment.kind === SyntaxKind.ShorthandPropertyAssignment) {
const prop = <ShorthandPropertyAssignment>exprOrAssignment;
if (prop.objectAssignmentInitializer) {
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper);
}
target = (<ShorthandPropertyAssignment>exprOrAssignment).name;
}
else {
target = <Expression>exprOrAssignment;
}
if (target.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>target).operatorToken.kind === SyntaxKind.EqualsToken) {
checkBinaryExpression(<BinaryExpression>target, contextualMapper);
target = (<BinaryExpression>target).left;
@@ -10024,15 +10087,21 @@ namespace ts {
}
function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) {
let operator = node.operatorToken.kind;
if (operator === SyntaxKind.EqualsToken && (node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) {
return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper);
return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node);
}
function checkBinaryLikeExpression(left: Expression, operatorToken: Node, right: Expression, contextualMapper?: TypeMapper, errorNode?: Node) {
let operator = operatorToken.kind;
if (operator === SyntaxKind.EqualsToken && (left.kind === SyntaxKind.ObjectLiteralExpression || left.kind === SyntaxKind.ArrayLiteralExpression)) {
return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper);
}
let leftType = checkExpression(node.left, contextualMapper);
let rightType = checkExpression(node.right, contextualMapper);
let leftType = checkExpression(left, contextualMapper);
let rightType = checkExpression(right, contextualMapper);
switch (operator) {
case SyntaxKind.AsteriskToken:
case SyntaxKind.AsteriskAsteriskToken:
case SyntaxKind.AsteriskEqualsToken:
case SyntaxKind.AsteriskAsteriskEqualsToken:
case SyntaxKind.SlashToken:
case SyntaxKind.SlashEqualsToken:
case SyntaxKind.PercentToken:
@@ -10051,7 +10120,7 @@ namespace ts {
case SyntaxKind.CaretEqualsToken:
case SyntaxKind.AmpersandToken:
case SyntaxKind.AmpersandEqualsToken:
// TypeScript 1.0 spec (April 2014): 4.15.1
// TypeScript 1.0 spec (April 2014): 4.19.1
// These operators require their operands to be of type Any, the Number primitive type,
// or an enum type. Operands of an enum type are treated
// as having the primitive type Number. If one operand is the null or undefined value,
@@ -10065,13 +10134,13 @@ namespace ts {
// try and return them a helpful suggestion
if ((leftType.flags & TypeFlags.Boolean) &&
(rightType.flags & TypeFlags.Boolean) &&
(suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) {
error(node, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(node.operatorToken.kind), tokenToString(suggestedOperator));
(suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
error(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
}
else {
// otherwise just check each operand separately and report errors as normal
let leftOk = checkArithmeticOperandType(node.left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
let rightOk = checkArithmeticOperandType(node.right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
let leftOk = checkArithmeticOperandType(left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
let rightOk = checkArithmeticOperandType(right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
if (leftOk && rightOk) {
checkAssignmentOperator(numberType);
}
@@ -10080,7 +10149,7 @@ namespace ts {
return numberType;
case SyntaxKind.PlusToken:
case SyntaxKind.PlusEqualsToken:
// TypeScript 1.0 spec (April 2014): 4.15.2
// TypeScript 1.0 spec (April 2014): 4.19.2
// The binary + operator requires both operands to be of the Number primitive type or an enum type,
// or at least one of the operands to be of type Any or the String primitive type.
@@ -10137,9 +10206,9 @@ namespace ts {
}
return booleanType;
case SyntaxKind.InstanceOfKeyword:
return checkInstanceOfExpression(node, leftType, rightType);
return checkInstanceOfExpression(left, right, leftType, rightType);
case SyntaxKind.InKeyword:
return checkInExpression(node, leftType, rightType);
return checkInExpression(left, right, leftType, rightType);
case SyntaxKind.AmpersandAmpersandToken:
return rightType;
case SyntaxKind.BarBarToken:
@@ -10154,8 +10223,8 @@ namespace ts {
// Return true if there was no error, false if there was an error.
function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean {
let offendingSymbolOperand =
someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? node.left :
someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right :
someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? left :
someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? right :
undefined;
if (offendingSymbolOperand) {
error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator));
@@ -10189,17 +10258,17 @@ namespace ts {
// requires VarExpr to be classified as a reference
// A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1)
// and the type of the non - compound operation to be assignable to the type of VarExpr.
let ok = checkReferenceExpression(node.left, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant);
let ok = checkReferenceExpression(left, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant);
// Use default messages
if (ok) {
// to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported
checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined);
checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined);
}
}
}
function reportOperatorError() {
error(node, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType));
error(errorNode || operatorToken, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType));
}
}
@@ -11303,7 +11372,8 @@ namespace ts {
}
function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) {
if (!(type.flags & TypeFlags.Any) && isTypeAssignableTo(type, getGlobalThenableType())) {
type = getWidenedType(type);
if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
if (location) {
if (!message) {
message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member;
@@ -11721,10 +11791,6 @@ namespace ts {
checkSignatureDeclaration(node);
let isAsync = isAsyncFunctionLike(node);
if (isAsync) {
if (!compilerOptions.experimentalAsyncFunctions) {
error(node, Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning);
}
emitAwaiter = true;
}
@@ -12541,7 +12607,12 @@ namespace ts {
if (isAsyncFunctionLike(func)) {
let promisedType = getPromisedType(returnType);
let awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
checkTypeAssignableTo(awaitedType, promisedType, node.expression);
if (promisedType) {
// If the function has a return type, but promisedType is
// undefined, an error will be reported in checkAsyncFunctionReturnType
// so we don't need to report one here.
checkTypeAssignableTo(awaitedType, promisedType, node.expression);
}
}
else {
checkTypeAssignableTo(exprType, returnType, node.expression);
@@ -13151,13 +13222,13 @@ namespace ts {
autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient);
}
else if (ambient && !enumIsConst) {
// In ambient enum declarations that specify no const modifier, enum member declarations
// In ambient enum declarations that specify no const modifier, enum member declarations
// that omit a value are considered computed members (as opposed to having auto-incremented values assigned).
autoValue = undefined;
}
else if (previousEnumMemberIsNonConstant) {
// If the member declaration specifies no value, the member is considered a constant enum member.
// If the member is the first member in the enum declaration, it is assigned the value zero.
// If the member declaration specifies no value, the member is considered a constant enum member.
// If the member is the first member in the enum declaration, it is assigned the value zero.
// Otherwise, it is assigned the value of the immediately preceding member plus one,
// and an error occurs if the immediately preceding member is not a constant enum member
error(member.name, Diagnostics.Enum_member_must_have_initializer);
@@ -13308,7 +13379,7 @@ namespace ts {
}
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) {
reportError = false;
error(e, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
@@ -13857,6 +13928,7 @@ namespace ts {
break;
case SyntaxKind.ClassExpression:
forEach((<ClassExpression>node).members, checkSourceElement);
forEachChild(node, checkFunctionAndClassExpressionBodies);
break;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
@@ -14097,7 +14169,7 @@ namespace ts {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
// If we didn't come from static member of class or interface,
// add the type parameters into the symbol table
// add the type parameters into the symbol table
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
// Note: that the memberFlags come from previous iteration.
if (!(memberFlags & NodeFlags.Static)) {
@@ -14504,7 +14576,7 @@ namespace ts {
moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
const symbolLinks = getSymbolLinks(moduleSymbol);
if (symbolLinks.exportsSomeValue == undefined) {
if (symbolLinks.exportsSomeValue === undefined) {
// for export assignments - check if resolved symbol for RHS is itself a value
// otherwise - check if at least one export is value
symbolLinks.exportsSomeValue = hasExportAssignment
@@ -14788,31 +14860,6 @@ namespace ts {
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
}
function getBlockScopedVariableId(n: Identifier): number {
Debug.assert(!nodeIsSynthesized(n));
let isVariableDeclarationOrBindingElement =
n.parent.kind === SyntaxKind.BindingElement || (n.parent.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>n.parent).name === n);
let symbol =
(isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) ||
getNodeLinks(n).resolvedSymbol ||
resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
let isLetOrConst =
symbol &&
(symbol.flags & SymbolFlags.BlockScopedVariable) &&
symbol.valueDeclaration.parent.kind !== SyntaxKind.CatchClause;
if (isLetOrConst) {
// side-effect of calling this method:
// assign id to symbol if it was not yet set
getSymbolLinks(symbol);
return symbol.id;
}
return undefined;
}
function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type {
if (functionType === unknownType) {
return unknownType;
@@ -14847,7 +14894,6 @@ namespace ts {
isEntityNameVisible,
getConstantValue,
collectLinkedAliases,
getBlockScopedVariableId,
getReferencedValueDeclaration,
getTypeReferenceSerializationKind,
isOptionalParameter,
@@ -15459,7 +15505,7 @@ namespace ts {
}
}
function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression) {
function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) {
let seen: Map<SymbolFlags> = {};
let Property = 1;
let GetAccessor = 2;
@@ -15475,6 +15521,12 @@ namespace ts {
continue;
}
if (prop.kind === SyntaxKind.ShorthandPropertyAssignment && !inDestructuring && (<ShorthandPropertyAssignment>prop).objectAssignmentInitializer) {
// having objectAssignmentInitializer is only valid in ObjectAssignmentPattern
// outside of destructuring it is a syntax error
return grammarErrorOnNode((<ShorthandPropertyAssignment>prop).equalsToken, Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
}
// ECMA-262 11.1.5 Object Initialiser
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
+14 -10
View File
@@ -77,6 +77,7 @@ namespace ts {
"system": ModuleKind.System,
"umd": ModuleKind.UMD,
"es6": ModuleKind.ES6,
"es2015": ModuleKind.ES2015,
},
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
paramType: Diagnostics.KIND,
@@ -205,7 +206,12 @@ namespace ts {
{
name: "target",
shortName: "t",
type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6 },
type: {
"es3": ScriptTarget.ES3,
"es5": ScriptTarget.ES5,
"es6": ScriptTarget.ES6,
"es2015": ScriptTarget.ES2015,
},
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
paramType: Diagnostics.VERSION,
error: Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
@@ -222,11 +228,6 @@ namespace ts {
type: "boolean",
description: Diagnostics.Watch_input_files,
},
{
name: "experimentalAsyncFunctions",
type: "boolean",
description: Diagnostics.Enables_experimental_support_for_ES7_async_functions
},
{
name: "experimentalDecorators",
type: "boolean",
@@ -389,7 +390,7 @@ namespace ts {
catch (e) {
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
}
return parseConfigFileText(fileName, text);
return parseConfigFileTextToJson(fileName, text);
}
/**
@@ -397,7 +398,7 @@ namespace ts {
* @param fileName The path to the config file
* @param jsonText The text of the config file
*/
export function parseConfigFileText(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } {
export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } {
try {
return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} };
}
@@ -412,7 +413,7 @@ namespace ts {
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
let errors: Diagnostic[] = [];
return {
@@ -448,6 +449,9 @@ namespace ts {
}
if (opt.isFilePath) {
value = normalizePath(combinePaths(basePath, value));
if (value === "") {
value = ".";
}
}
options[opt.name] = value;
}
@@ -497,4 +501,4 @@ namespace ts {
return fileNames;
}
}
}
}
+37 -3
View File
@@ -437,8 +437,12 @@ namespace ts {
}
export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain {
Debug.assert(!headChain.next);
headChain.next = tailChain;
let lastChain = headChain;
while (lastChain.next) {
lastChain = lastChain.next;
}
lastChain.next = tailChain;
return headChain;
}
@@ -700,6 +704,9 @@ namespace ts {
}
export function getBaseFileName(path: string) {
if (!path) {
return undefined;
}
let i = path.lastIndexOf(directorySeparator);
return i < 0 ? path : path.substring(i + 1);
}
@@ -722,6 +729,23 @@ namespace ts {
* List of supported extensions in order of file resolution precedence.
*/
export const supportedExtensions = [".ts", ".tsx", ".d.ts"];
/**
* List of extensions that will be used to look for external modules.
* This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation,
* but still would like to load only TypeScript files as modules
*/
export const moduleFileExtensions = supportedExtensions;
export function isSupportedSourceFileName(fileName: string) {
if (!fileName) { return false; }
for (let extension of supportedExtensions) {
if (fileExtensionIs(fileName, extension)) {
return true;
}
}
return false;
}
const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"];
export function removeFileExtension(path: string): string {
@@ -817,4 +841,14 @@ namespace ts {
Debug.assert(false, message);
}
}
}
export function copyListRemovingItem<T>(item: T, list: T[]) {
let copiedList: T[] = [];
for (var i = 0, len = list.length; i < len; i++) {
if (list[i] !== item) {
copiedList.push(list[i]);
}
}
return copiedList;
}
}
+16 -8
View File
@@ -783,10 +783,6 @@
"category": "Error",
"code": 1245
},
"Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": {
"category": "Error",
"code": 1246
},
"'with' statements are not allowed in an async function block.": {
"category": "Error",
@@ -800,6 +796,10 @@
"category": "Error",
"code": 1311
},
"'=' can only be used in an object literal property inside a destructuring assignment.": {
"category": "Error",
"code": 1312
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
@@ -1656,6 +1656,10 @@
"category": "Error",
"code": 2527
},
"A module cannot have multiple default exports.": {
"category": "Error",
"code": 2528
},
"JSX element attributes type '{0}' must be an object type.": {
"category": "Error",
"code": 2600
@@ -2274,10 +2278,6 @@
"category": "Message",
"code": 6066
},
"Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower.": {
"category": "Message",
"code": 6067
},
"Enables experimental support for ES7 async functions.": {
"category": "Message",
"code": 6068
@@ -2469,5 +2469,13 @@
"A constructor cannot contain a 'super' call when its class extends 'null'": {
"category": "Error",
"code": 17005
},
"An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
"category": "Error",
"code": 17006
},
"A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
"category": "Error",
"code": 17007
}
}
+183 -70
View File
@@ -446,7 +446,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
/** If removeComments is true, no leading-comments needed to be emitted **/
let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker;
let moduleEmitDelegates: Map<(node: SourceFile, startIndex: number) => void> = {
let moduleEmitDelegates: Map<(node: SourceFile) => void> = {
[ModuleKind.ES6]: emitES6Module,
[ModuleKind.AMD]: emitAMDModule,
[ModuleKind.System]: emitSystemModule,
@@ -2311,6 +2311,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(": ");
emit(node.name);
}
if (languageVersion >= ScriptTarget.ES6 && node.objectAssignmentInitializer) {
write(" = ");
emit(node.objectAssignmentInitializer);
}
}
function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean {
@@ -2778,6 +2783,68 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
/**
* Emit ES7 exponentiation operator downlevel using Math.pow
* @param node a binary expression node containing exponentiationOperator (**, **=)
*/
function emitExponentiationOperator(node: BinaryExpression) {
let leftHandSideExpression = node.left;
if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) {
let synthesizedLHS: ElementAccessExpression | PropertyAccessExpression;
let shouldEmitParentheses = false;
if (isElementAccessExpression(leftHandSideExpression)) {
shouldEmitParentheses = true;
write("(");
synthesizedLHS = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression, /*startsOnNewLine*/ false);
let identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false);
synthesizedLHS.expression = identifier;
if (leftHandSideExpression.argumentExpression.kind !== SyntaxKind.NumericLiteral &&
leftHandSideExpression.argumentExpression.kind !== SyntaxKind.StringLiteral) {
let tempArgumentExpression = createAndRecordTempVariable(TempFlags._i);
(<ElementAccessExpression>synthesizedLHS).argumentExpression = tempArgumentExpression;
emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true);
}
else {
(<ElementAccessExpression>synthesizedLHS).argumentExpression = leftHandSideExpression.argumentExpression;
}
write(", ");
}
else if (isPropertyAccessExpression(leftHandSideExpression)) {
shouldEmitParentheses = true;
write("(");
synthesizedLHS = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression, /*startsOnNewLine*/ false);
let identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false);
synthesizedLHS.expression = identifier;
(<PropertyAccessExpression>synthesizedLHS).dotToken = leftHandSideExpression.dotToken;
(<PropertyAccessExpression>synthesizedLHS).name = leftHandSideExpression.name;
write(", ");
}
emit(synthesizedLHS || leftHandSideExpression);
write(" = ");
write("Math.pow(");
emit(synthesizedLHS || leftHandSideExpression);
write(", ");
emit(node.right);
write(")");
if (shouldEmitParentheses) {
write(")");
}
}
else {
write("Math.pow(");
emit(leftHandSideExpression);
write(", ");
emit(node.right);
write(")");
}
}
function emitBinaryExpression(node: BinaryExpression) {
if (languageVersion < ScriptTarget.ES6 && node.operatorToken.kind === SyntaxKind.EqualsToken &&
(node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) {
@@ -2795,12 +2862,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitNodeWithoutSourceMap(node.left);
write(`", `);
}
emit(node.left);
let indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== SyntaxKind.CommaToken ? " " : undefined);
write(tokenToString(node.operatorToken.kind));
let indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " ");
emit(node.right);
decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator);
if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskToken || node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) {
// Downleveled emit exponentiation operator using Math.pow
emitExponentiationOperator(node);
}
else {
emit(node.left);
// Add indentation before emit the operator if the operator is on different line
// For example:
// 3
// + 2;
// emitted as
// 3
// + 2;
let indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== SyntaxKind.CommaToken ? " " : undefined);
write(tokenToString(node.operatorToken.kind));
let indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " ");
emit(node.right);
decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator);
}
if (exportChanged) {
write(")");
}
@@ -3437,6 +3519,58 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(";");
}
/**
* Emit an assignment to a given identifier, 'name', with a given expression, 'value'.
* @param name an identifier as a left-hand-side operand of the assignment
* @param value an expression as a right-hand-side operand of the assignment
* @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma
*/
function emitAssignment(name: Identifier, value: Expression, shouldEmitCommaBeforeAssignment: boolean) {
if (shouldEmitCommaBeforeAssignment) {
write(", ");
}
let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name);
if (exportChanged) {
write(`${exportFunctionForFile}("`);
emitNodeWithCommentsAndWithoutSourcemap(name);
write(`", `);
}
const isVariableDeclarationOrBindingElement =
name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement);
if (isVariableDeclarationOrBindingElement) {
emitModuleMemberName(<Declaration>name.parent);
}
else {
emit(name);
}
write(" = ");
emit(value);
if (exportChanged) {
write(")");
}
}
/**
* Create temporary variable, emit an assignment of the variable the given expression
* @param expression an expression to assign to the newly created temporary variable
* @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location
* @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma
*/
function emitTempVariableAssignment(expression: Expression, canDefineTempVariablesInPlace: boolean, shouldEmitCommaBeforeAssignment: boolean): Identifier {
let identifier = createTempVariable(TempFlags.Auto);
if (!canDefineTempVariablesInPlace) {
recordTempDeclaration(identifier);
}
emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment);
return identifier;
}
function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration, isAssignmentExpressionStatement: boolean, value?: Expression) {
let emitCount = 0;
@@ -3462,36 +3596,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitBindingElement(<BindingElement>root, value);
}
function emitAssignment(name: Identifier, value: Expression) {
if (emitCount++) {
write(", ");
}
const isVariableDeclarationOrBindingElement =
name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement);
let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name);
if (exportChanged) {
write(`${exportFunctionForFile}("`);
emitNodeWithCommentsAndWithoutSourcemap(name);
write(`", `);
}
if (isVariableDeclarationOrBindingElement) {
emitModuleMemberName(<Declaration>name.parent);
}
else {
emit(name);
}
write(" = ");
emit(value);
if (exportChanged) {
write(")");
}
}
/**
* Ensures that there exists a declared identifier whose value holds the given expression.
@@ -3507,11 +3611,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return expr;
}
let identifier = createTempVariable(TempFlags.Auto);
if (!canDefineTempVariablesInPlace) {
recordTempDeclaration(identifier);
}
emitAssignment(identifier, expr);
let identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0);
emitCount++;
return identifier;
}
@@ -3574,7 +3675,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
for (let p of properties) {
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
let propName = <Identifier | LiteralExpression>(<PropertyAssignment>p).name;
emitDestructuringAssignment((<PropertyAssignment>p).initializer || propName, createPropertyAccessForDestructuringProperty(value, propName));
let target = p.kind === SyntaxKind.ShorthandPropertyAssignment ? <ShorthandPropertyAssignment>p : (<PropertyAssignment>p).initializer || propName;
emitDestructuringAssignment(target, createPropertyAccessForDestructuringProperty(value, propName));
}
}
}
@@ -3599,8 +3701,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
function emitDestructuringAssignment(target: Expression, value: Expression) {
if (target.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>target).operatorToken.kind === SyntaxKind.EqualsToken) {
function emitDestructuringAssignment(target: Expression | ShorthandPropertyAssignment, value: Expression) {
if (target.kind === SyntaxKind.ShorthandPropertyAssignment) {
if ((<ShorthandPropertyAssignment>target).objectAssignmentInitializer) {
value = createDefaultValueCheck(value, (<ShorthandPropertyAssignment>target).objectAssignmentInitializer);
}
target = (<ShorthandPropertyAssignment>target).name;
}
else if (target.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>target).operatorToken.kind === SyntaxKind.EqualsToken) {
value = createDefaultValueCheck(value, (<BinaryExpression>target).right);
target = (<BinaryExpression>target).left;
}
@@ -3611,7 +3719,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitArrayLiteralAssignment(<ArrayLiteralExpression>target, value);
}
else {
emitAssignment(<Identifier>target, value);
emitAssignment(<Identifier>target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0);
emitCount++;
}
}
@@ -3680,7 +3789,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
else {
emitAssignment(<Identifier>target.name, value);
emitAssignment(<Identifier>target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0);
emitCount++;
}
}
}
@@ -3785,7 +3895,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(";");
}
}
if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) {
if (modulekind !== ModuleKind.ES6 && node.parent === currentSourceFile) {
forEach(node.declarationList.declarations, emitExportVariableAssignments);
}
}
@@ -4011,7 +4121,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
emitSignatureAndBody(node);
if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
if (modulekind !== ModuleKind.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
emitExportMemberAssignments((<FunctionDeclaration>node).name);
}
@@ -4687,6 +4797,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
emitClassLikeDeclarationForES6AndHigher(node);
}
if (modulekind !== ModuleKind.ES6 && node.parent === currentSourceFile && node.name) {
emitExportMemberAssignments(node.name);
}
}
function emitClassLikeDeclarationForES6AndHigher(node: ClassLikeDeclaration) {
@@ -4785,8 +4898,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// emit name if
// - node has a name
// - this is default export and target is not ES6 (for ES6 `export default` does not need to be compiled downlevel)
if ((node.name || (node.flags & NodeFlags.Default && languageVersion < ScriptTarget.ES6)) && !thisNodeIsDecorated) {
// - this is default export with static initializers
if ((node.name || (node.flags & NodeFlags.Default && staticProperties.length > 0)) && !thisNodeIsDecorated) {
write(" ");
emitDeclarationName(node);
}
@@ -4934,10 +5047,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (node.kind === SyntaxKind.ClassDeclaration) {
emitExportMemberAssignment(<ClassDeclaration>node);
}
if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile && node.name) {
emitExportMemberAssignments(node.name);
}
}
function emitClassMemberPrefix(node: ClassLikeDeclaration, member: Node) {
@@ -5509,7 +5618,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitEnd(node);
write(";");
}
if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) {
if (modulekind !== ModuleKind.ES6 && node.parent === currentSourceFile) {
if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) {
// write the call to exporter for enum
writeLine();
@@ -5645,8 +5754,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
/*
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
* Here we check if alternative name was provided for a given moduleName and return it if possible.
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
* Here we check if alternative name was provided for a given moduleName and return it if possible.
*/
function tryRenameExternalModule(moduleName: LiteralExpression): string {
if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) {
@@ -6600,7 +6709,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("}"); // execute
}
function emitSystemModule(node: SourceFile, startIndex: number): void {
function emitSystemModule(node: SourceFile): void {
collectExternalModuleInfo(node);
// System modules has the following shape
// System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */})
@@ -6645,6 +6754,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(`], function(${exportFunctionForFile}) {`);
writeLine();
increaseIndent();
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true);
emitEmitHelpers(node);
emitCaptureThisForNodeIfNecessary(node);
emitSystemModuleBody(node, dependencyGroups, startIndex);
@@ -6738,7 +6848,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(") {");
}
function emitAMDModule(node: SourceFile, startIndex: number) {
function emitAMDModule(node: SourceFile) {
emitEmitHelpers(node);
collectExternalModuleInfo(node);
@@ -6749,6 +6859,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true);
increaseIndent();
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -6759,7 +6870,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("});");
}
function emitCommonJSModule(node: SourceFile, startIndex: number) {
function emitCommonJSModule(node: SourceFile) {
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
emitEmitHelpers(node);
collectExternalModuleInfo(node);
emitExportStarHelper();
@@ -6769,7 +6881,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitExportEquals(/*emitAsReturn*/ false);
}
function emitUMDModule(node: SourceFile, startIndex: number) {
function emitUMDModule(node: SourceFile) {
emitEmitHelpers(node);
collectExternalModuleInfo(node);
@@ -6788,6 +6900,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
})(`);
emitAMDFactoryHeader(dependencyNames);
increaseIndent();
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -6798,11 +6911,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("});");
}
function emitES6Module(node: SourceFile, startIndex: number) {
function emitES6Module(node: SourceFile) {
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
hasExportStarsToExportValues = false;
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
emitEmitHelpers(node);
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -6849,7 +6963,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (isLineBreak(c)) {
if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) {
let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1);
result = (result ? result + "\" + ' ' + \"" : "") + part;
result = (result ? result + "\" + ' ' + \"" : "") + escapeString(part);
}
firstNonWhitespace = -1;
}
@@ -6863,7 +6977,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (firstNonWhitespace !== -1) {
let part = text.substr(firstNonWhitespace);
result = (result ? result + "\" + ' ' + \"" : "") + part;
result = (result ? result + "\" + ' ' + \"" : "") + escapeString(part);
}
if (result) {
@@ -6991,14 +7105,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitShebang();
emitDetachedComments(node);
// emit prologue directives prior to __extends
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
if (isExternalModule(node) || compilerOptions.isolatedModules) {
let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS];
emitModule(node, startIndex);
emitModule(node);
}
else {
// emit prologue directives prior to __extends
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
@@ -7076,7 +7189,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return shouldEmitEnumDeclaration(<EnumDeclaration>node);
}
// If the node is emitted in specialized fashion, dont emit comments as this node will handle
// If the node is emitted in specialized fashion, dont emit comments as this node will handle
// emitting comments when emitting itself
Debug.assert(!isSpecializedCommentHandling(node));
+175 -27
View File
@@ -57,11 +57,17 @@ namespace ts {
return visitNode(cbNode, (<TypeParameterDeclaration>node).name) ||
visitNode(cbNode, (<TypeParameterDeclaration>node).constraint) ||
visitNode(cbNode, (<TypeParameterDeclaration>node).expression);
case SyntaxKind.ShorthandPropertyAssignment:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).name) ||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).questionToken) ||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).equalsToken) ||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).objectAssignmentInitializer);
case SyntaxKind.Parameter:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.PropertyAssignment:
case SyntaxKind.ShorthandPropertyAssignment:
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
return visitNodes(cbNodes, node.decorators) ||
@@ -856,7 +862,7 @@ namespace ts {
let saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
// Note: it is not actually necessary to save/restore the context flags here. That's
// because the saving/restorating of these flags happens naturally through the recursive
// because the saving/restoring of these flags happens naturally through the recursive
// descent nature of our parser. However, we still store this here just so we can
// assert that that invariant holds.
let saveContextFlags = contextFlags;
@@ -1124,7 +1130,15 @@ namespace ts {
if (token === SyntaxKind.DefaultKeyword) {
return nextTokenIsClassOrFunction();
}
if (token === SyntaxKind.StaticKeyword) {
nextToken();
return canFollowModifier();
}
nextToken();
if (scanner.hasPrecedingLineBreak()) {
return false;
}
return canFollowModifier();
}
@@ -3017,7 +3031,31 @@ namespace ts {
let newPrecedence = getBinaryOperatorPrecedence();
// Check the precedence to see if we should "take" this operator
if (newPrecedence <= precedence) {
// - For left associative operator (all operator but **), consume the operator,
// recursively call the function below, and parse binaryExpression as a rightOperand
// of the caller if the new precendence of the operator is greater then or equal to the current precendence.
// For example:
// a - b - c;
// ^token; leftOperand = b. Return b to the caller as a rightOperand
// a * b - c
// ^token; leftOperand = b. Return b to the caller as a rightOperand
// a - b * c;
// ^token; leftOperand = b. Return b * c to the caller as a rightOperand
// - For right associative operator (**), consume the operator, recursively call the function
// and parse binaryExpression as a rightOperand of the caller if the new precendence of
// the operator is strictly grater than the current precendence
// For example:
// a ** b ** c;
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand
// a - b ** c;
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand
// a ** b - c
// ^token; leftOperand = b. Return b to the caller as a rightOperand
const consumeCurrentOperator = token === SyntaxKind.AsteriskAsteriskToken ?
newPrecedence >= precedence :
newPrecedence > precedence;
if (!consumeCurrentOperator) {
break;
}
@@ -3091,6 +3129,8 @@ namespace ts {
case SyntaxKind.SlashToken:
case SyntaxKind.PercentToken:
return 10;
case SyntaxKind.AsteriskAsteriskToken:
return 11;
}
// -1 is lower than all other precedences. Returning it will cause binary expression
@@ -3117,28 +3157,29 @@ namespace ts {
let node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression);
node.operator = token;
nextToken();
node.operand = parseUnaryExpressionOrHigher();
node.operand = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseDeleteExpression() {
let node = <DeleteExpression>createNode(SyntaxKind.DeleteExpression);
nextToken();
node.expression = parseUnaryExpressionOrHigher();
node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseTypeOfExpression() {
let node = <TypeOfExpression>createNode(SyntaxKind.TypeOfExpression);
nextToken();
node.expression = parseUnaryExpressionOrHigher();
node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseVoidExpression() {
let node = <VoidExpression>createNode(SyntaxKind.VoidExpression);
nextToken();
node.expression = parseUnaryExpressionOrHigher();
node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
@@ -3158,22 +3199,63 @@ namespace ts {
function parseAwaitExpression() {
const node = <AwaitExpression>createNode(SyntaxKind.AwaitExpression);
nextToken();
node.expression = parseUnaryExpressionOrHigher();
node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseUnaryExpressionOrHigher(): UnaryExpression {
/**
* Parse ES7 unary expression and await expression
*
* ES7 UnaryExpression:
* 1) SimpleUnaryExpression[?yield]
* 2) IncrementExpression[?yield] ** UnaryExpression[?yield]
*/
function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression {
if (isAwaitExpression()) {
return parseAwaitExpression();
}
if (isIncrementExpression()) {
let incrementExpression = parseIncrementExpression();
return token === SyntaxKind.AsteriskAsteriskToken ?
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) :
incrementExpression;
}
let unaryOperator = token;
let simpleUnaryExpression = parseSimpleUnaryExpression();
if (token === SyntaxKind.AsteriskAsteriskToken) {
let diagnostic: Diagnostic;
let start = skipTrivia(sourceText, simpleUnaryExpression.pos);
if (simpleUnaryExpression.kind === SyntaxKind.TypeAssertionExpression) {
parseErrorAtPosition(start, simpleUnaryExpression.end - start, Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses);
}
else {
parseErrorAtPosition(start, simpleUnaryExpression.end - start, Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, tokenToString(unaryOperator));
}
}
return simpleUnaryExpression;
}
/**
* Parse ES7 simple-unary expression or higher:
*
* ES7 SimpleUnaryExpression:
* 1) IncrementExpression[?yield]
* 2) delete UnaryExpression[?yield]
* 3) void UnaryExpression[?yield]
* 4) typeof UnaryExpression[?yield]
* 5) + UnaryExpression[?yield]
* 6) - UnaryExpression[?yield]
* 7) ~ UnaryExpression[?yield]
* 8) ! UnaryExpression[?yield]
*/
function parseSimpleUnaryExpression(): UnaryExpression {
switch (token) {
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
case SyntaxKind.TildeToken:
case SyntaxKind.ExclamationToken:
case SyntaxKind.PlusPlusToken:
case SyntaxKind.MinusMinusToken:
return parsePrefixUnaryExpression();
case SyntaxKind.DeleteKeyword:
return parseDeleteExpression();
@@ -3182,19 +3264,73 @@ namespace ts {
case SyntaxKind.VoidKeyword:
return parseVoidExpression();
case SyntaxKind.LessThanToken:
if (sourceFile.languageVariant !== LanguageVariant.JSX) {
return parseTypeAssertion();
}
if (lookAhead(nextTokenIsIdentifierOrKeyword)) {
return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true);
}
// Fall through
// This is modified UnaryExpression grammar in TypeScript
// UnaryExpression (modified):
// < type > UnaryExpression
return parseTypeAssertion();
default:
return parsePostfixExpressionOrHigher();
return parseIncrementExpression();
}
}
function parsePostfixExpressionOrHigher(): PostfixExpression {
/**
* Check if the current token can possibly be an ES7 increment expression.
*
* ES7 IncrementExpression:
* LeftHandSideExpression[?Yield]
* LeftHandSideExpression[?Yield][no LineTerminator here]++
* LeftHandSideExpression[?Yield][no LineTerminator here]--
* ++LeftHandSideExpression[?Yield]
* --LeftHandSideExpression[?Yield]
*/
function isIncrementExpression(): boolean {
// This function is called inside parseUnaryExpression to decide
// whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly
switch (token) {
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
case SyntaxKind.TildeToken:
case SyntaxKind.ExclamationToken:
case SyntaxKind.DeleteKeyword:
case SyntaxKind.TypeOfKeyword:
case SyntaxKind.VoidKeyword:
return false;
case SyntaxKind.LessThanToken:
// If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression
if (sourceFile.languageVariant !== LanguageVariant.JSX) {
return false;
}
// We are in JSX context and the token is part of JSXElement.
// Fall through
default:
return true;
}
}
/**
* Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression.
*
* ES7 IncrementExpression[yield]:
* 1) LeftHandSideExpression[?yield]
* 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++
* 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]--
* 4) ++LeftHandSideExpression[?yield]
* 5) --LeftHandSideExpression[?yield]
* In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression
*/
function parseIncrementExpression(): IncrementExpression {
if (token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) {
let node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression);
node.operator = token;
nextToken();
node.operand = parseLeftHandSideExpressionOrHigher();
return finishNode(node);
}
else if (sourceFile.languageVariant === LanguageVariant.JSX && token === SyntaxKind.LessThanToken && lookAhead(nextTokenIsIdentifierOrKeyword)) {
// JSXElement is part of primaryExpression
return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true);
}
let expression = parseLeftHandSideExpressionOrHigher();
Debug.assert(isLeftHandSideExpression(expression));
@@ -3491,7 +3627,7 @@ namespace ts {
parseExpected(SyntaxKind.LessThanToken);
node.type = parseType();
parseExpected(SyntaxKind.GreaterThanToken);
node.expression = parseUnaryExpressionOrHigher();
node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
@@ -3750,11 +3886,23 @@ namespace ts {
return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken);
}
// Parse to check if it is short-hand property assignment or normal property assignment
if ((token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBraceToken) && tokenIsIdentifier) {
// check if it is short-hand property assignment or normal property assignment
// NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production
// CoverInitializedName[Yield] :
// IdentifierReference[?Yield] Initializer[In, ?Yield]
// this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern
const isShorthandPropertyAssignment =
tokenIsIdentifier && (token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBraceToken || token === SyntaxKind.EqualsToken);
if (isShorthandPropertyAssignment) {
let shorthandDeclaration = <ShorthandPropertyAssignment>createNode(SyntaxKind.ShorthandPropertyAssignment, fullStart);
shorthandDeclaration.name = <Identifier>propertyName;
shorthandDeclaration.questionToken = questionToken;
const equalsToken = parseOptionalToken(SyntaxKind.EqualsToken);
if (equalsToken) {
shorthandDeclaration.equalsToken = equalsToken;
shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
}
return finishNode(shorthandDeclaration);
}
else {
@@ -4157,8 +4305,12 @@ namespace ts {
case SyntaxKind.ModuleKeyword:
case SyntaxKind.NamespaceKeyword:
return nextTokenIsIdentifierOrStringLiteralOnSameLine();
case SyntaxKind.AbstractKeyword:
case SyntaxKind.AsyncKeyword:
case SyntaxKind.DeclareKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.PublicKeyword:
nextToken();
// ASI takes effect for this modifier.
if (scanner.hasPrecedingLineBreak()) {
@@ -4178,11 +4330,7 @@ namespace ts {
}
continue;
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.AbstractKeyword:
nextToken();
continue;
default:
+9 -19
View File
@@ -53,13 +53,13 @@ namespace ts {
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
let failedLookupLocations: string[] = [];
let candidate = normalizePath(combinePaths(containingDirectory, moduleName));
let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
let resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
return resolvedFileName
? { resolvedModule: { resolvedFileName }, failedLookupLocations }
: { resolvedModule: undefined, failedLookupLocations };
@@ -69,13 +69,8 @@ namespace ts {
}
}
function loadNodeModuleFromFile(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
if (loadOnlyDts) {
return tryLoad(".d.ts");
}
else {
return forEach(supportedExtensions, tryLoad);
}
function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
return forEach(moduleFileExtensions, tryLoad);
function tryLoad(ext: string): string {
let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
@@ -89,7 +84,7 @@ namespace ts {
}
}
function loadNodeModuleFromDirectory(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
function loadNodeModuleFromDirectory(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
let packageJsonPath = combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
@@ -105,7 +100,7 @@ namespace ts {
}
if (jsonContent.typings) {
let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
if (result) {
return result;
}
@@ -116,7 +111,7 @@ namespace ts {
failedLookupLocation.push(packageJsonPath);
}
return loadNodeModuleFromFile(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
return loadNodeModuleFromFile(combinePaths(candidate, "index"), failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
@@ -127,12 +122,12 @@ namespace ts {
if (baseName !== "node_modules") {
let nodeModulesFolder = combinePaths(directory, "node_modules");
let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
let result = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
if (result) {
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
if (result) {
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
}
@@ -1076,11 +1071,6 @@ namespace ts {
!options.experimentalDecorators) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
if (options.experimentalAsyncFunctions &&
options.target !== ScriptTarget.ES6) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
}
}
}
}
+8
View File
@@ -136,6 +136,7 @@ namespace ts {
"=>": SyntaxKind.EqualsGreaterThanToken,
"+": SyntaxKind.PlusToken,
"-": SyntaxKind.MinusToken,
"**": SyntaxKind.AsteriskAsteriskToken,
"*": SyntaxKind.AsteriskToken,
"/": SyntaxKind.SlashToken,
"%": SyntaxKind.PercentToken,
@@ -158,6 +159,7 @@ namespace ts {
"+=": SyntaxKind.PlusEqualsToken,
"-=": SyntaxKind.MinusEqualsToken,
"*=": SyntaxKind.AsteriskEqualsToken,
"**=": SyntaxKind.AsteriskAsteriskEqualsToken,
"/=": SyntaxKind.SlashEqualsToken,
"%=": SyntaxKind.PercentEqualsToken,
"<<=": SyntaxKind.LessThanLessThanEqualsToken,
@@ -1200,6 +1202,12 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
return pos += 2, token = SyntaxKind.AsteriskEqualsToken;
}
if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) {
if (text.charCodeAt(pos + 2) === CharacterCodes.equals) {
return pos += 3, token = SyntaxKind.AsteriskAsteriskEqualsToken;
}
return pos += 2, token = SyntaxKind.AsteriskAsteriskToken;
}
return pos++, token = SyntaxKind.AsteriskToken;
case CharacterCodes.plus:
if (text.charCodeAt(pos + 1) === CharacterCodes.plus) {
+134 -19
View File
@@ -8,7 +8,8 @@ namespace ts {
write(s: string): void;
readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string, removed: boolean) => void): FileWatcher;
watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher;
watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
@@ -20,6 +21,12 @@ namespace ts {
exit(exitCode?: number): void;
}
interface WatchedFile {
fileName: string;
callback: (fileName: string, removed?: boolean) => void;
mtime: Date;
}
export interface FileWatcher {
close(): void;
}
@@ -192,6 +199,103 @@ namespace ts {
const _path = require("path");
const _os = require("os");
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
function createWatchedFileSet(interval = 2500, chunkSize = 30) {
let watchedFiles: WatchedFile[] = [];
let nextFileToCheck = 0;
let watchTimer: any;
function getModifiedTime(fileName: string): Date {
return _fs.statSync(fileName).mtime;
}
function poll(checkedIndex: number) {
let watchedFile = watchedFiles[checkedIndex];
if (!watchedFile) {
return;
}
_fs.stat(watchedFile.fileName, (err: any, stats: any) => {
if (err) {
watchedFile.callback(watchedFile.fileName);
}
else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) {
watchedFile.mtime = getModifiedTime(watchedFile.fileName);
watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0);
}
});
}
// this implementation uses polling and
// stat due to inconsistencies of fs.watch
// and efficiency of stat on modern filesystems
function startWatchTimer() {
watchTimer = setInterval(() => {
let count = 0;
let nextToCheck = nextFileToCheck;
let firstCheck = -1;
while ((count < chunkSize) && (nextToCheck !== firstCheck)) {
poll(nextToCheck);
if (firstCheck < 0) {
firstCheck = nextToCheck;
}
nextToCheck++;
if (nextToCheck === watchedFiles.length) {
nextToCheck = 0;
}
count++;
}
nextFileToCheck = nextToCheck;
}, interval);
}
function addFile(fileName: string, callback: (fileName: string, removed?: boolean) => void): WatchedFile {
let file: WatchedFile = {
fileName,
callback,
mtime: getModifiedTime(fileName)
};
watchedFiles.push(file);
if (watchedFiles.length === 1) {
startWatchTimer();
}
return file;
}
function removeFile(file: WatchedFile) {
watchedFiles = copyListRemovingItem(file, watchedFiles);
}
return {
getModifiedTime: getModifiedTime,
poll: poll,
startWatchTimer: startWatchTimer,
addFile: addFile,
removeFile: removeFile
};
}
// REVIEW: for now this implementation uses polling.
// The advantage of polling is that it works reliably
// on all os and with network mounted files.
// For 90 referenced files, the average time to detect
// changes is 2*msInterval (by default 5 seconds).
// The overhead of this is .04 percent (1/2500) with
// average pause of < 1 millisecond (and max
// pause less than 1.5 milliseconds); question is
// do we anticipate reference sets in the 100s and
// do we care about waiting 10-20 seconds to detect
// changes for large reference sets? If so, do we want
// to increase the chunk size or decrease the interval
// time dynamically to match the large reference set?
let 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";
@@ -284,25 +388,36 @@ namespace ts {
readFile,
writeFile,
watchFile: (fileName, callback) => {
// watchFile polls a file every 250ms, picking up file notifications.
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
return {
close() { _fs.unwatchFile(fileName, fileChanged); }
};
function fileChanged(curr: any, prev: any) {
// mtime.getTime() equals 0 if file was removed
if (curr.mtime.getTime() === 0) {
callback(fileName, /* removed */ true);
return;
}
if (+curr.mtime <= +prev.mtime) {
return;
}
callback(fileName, /* removed */ false);
// Node 4.0 stablized the `fs.watch` function on Windows which avoids polling
// 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));
}
let watchedFile = watchedFileSet.addFile(fileName, callback);
return {
close: () => watchedFileSet.removeFile(watchedFile)
};
},
watchDirectory: (path, callback, recursive) => {
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
return _fs.watch(
path,
{ persisten: true, recursive: !!recursive },
(eventName: string, relativeFileName: string) => {
// In watchDirectory we only care about adding and removing files (when event name is
// "rename"); changes made within files are handled by corresponding fileWatchers (when
// event name is "change")
if (eventName === "rename") {
// When deleting a file, the passed baseFileName is null
callback(!relativeFileName ? relativeFileName : normalizePath(ts.combinePaths(path, relativeFileName)));
};
}
);
},
resolvePath: function (path: string): string {
return _path.resolve(path);
+81 -30
View File
@@ -147,14 +147,17 @@ namespace ts {
export function executeCommandLine(args: string[]): void {
let commandLine = parseCommandLine(args);
let configFileName: string; // Configuration file name (if any)
let configFileWatcher: FileWatcher; // Configuration file watcher
let cachedProgram: Program; // Program cached from last compilation
let rootFileNames: string[]; // Root fileNames for compilation
let compilerOptions: CompilerOptions; // Compiler options for compilation
let compilerHost: CompilerHost; // Compiler host
let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
let timerHandle: number; // Handle for 0.25s wait timer
let configFileName: string; // Configuration file name (if any)
let cachedConfigFileText: string; // Cached configuration file text, used for reparsing (if any)
let configFileWatcher: FileWatcher; // Configuration file watcher
let directoryWatcher: FileWatcher; // Directory watcher to monitor source file addition/removal
let cachedProgram: Program; // Program cached from last compilation
let rootFileNames: string[]; // Root fileNames for compilation
let compilerOptions: CompilerOptions; // Compiler options for compilation
let compilerHost: CompilerHost; // Compiler host
let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
let timerHandleForRecompilation: number; // Handle for 0.25s wait timer to trigger recompilation
let timerHandleForDirectoryChanges: number; // Handle for 0.25s wait timer to trigger directory change handler
if (commandLine.options.locale) {
if (!isJSONSupported()) {
@@ -218,28 +221,49 @@ namespace ts {
if (configFileName) {
configFileWatcher = sys.watchFile(configFileName, configFileChanged);
}
if (sys.watchDirectory && configFileName) {
let directory = ts.getDirectoryPath(configFileName);
directoryWatcher = sys.watchDirectory(
// When the configFileName is just "tsconfig.json", the watched directory should be
// the current direcotry; if there is a given "project" parameter, then the configFileName
// is an absolute file name.
directory == "" ? "." : directory,
watchedDirectoryChanged, /*recursive*/ true);
}
}
performCompilation();
function parseConfigFile(): ParsedCommandLine {
if (!cachedConfigFileText) {
try {
cachedConfigFileText = sys.readFile(configFileName);
}
catch (e) {
let error = createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message);
reportWatchDiagnostic(error);
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
return;
}
}
let result = parseConfigFileTextToJson(configFileName, cachedConfigFileText);
let configObject = result.config;
let configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName));
if (configParseResult.errors.length > 0) {
reportDiagnostics(configParseResult.errors);
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
return;
}
return configParseResult;
}
// Invoked to perform initial compilation or re-compilation in watch mode
function performCompilation() {
if (!cachedProgram) {
if (configFileName) {
let result = readConfigFile(configFileName, sys.readFile);
if (result.error) {
reportWatchDiagnostic(result.error);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
let configObject = result.config;
let configParseResult = parseConfigFile(configObject, sys, getDirectoryPath(configFileName));
if (configParseResult.errors.length > 0) {
reportDiagnostics(configParseResult.errors);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
let configParseResult = parseConfigFile();
rootFileNames = configParseResult.fileNames;
compilerOptions = extend(commandLine.options, configParseResult.options);
}
@@ -275,7 +299,7 @@ namespace ts {
let sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
if (sourceFile && compilerOptions.watch) {
// Attach a file watcher
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName, removed) => sourceFileChanged(sourceFile, removed));
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
}
return sourceFile;
}
@@ -297,7 +321,7 @@ namespace ts {
}
// If a source file changes, mark it as unwatched and start the recompilation timer
function sourceFileChanged(sourceFile: SourceFile, removed: boolean) {
function sourceFileChanged(sourceFile: SourceFile, removed?: boolean) {
sourceFile.fileWatcher.close();
sourceFile.fileWatcher = undefined;
if (removed) {
@@ -306,27 +330,54 @@ namespace ts {
rootFileNames.splice(index, 1);
}
}
startTimer();
startTimerForRecompilation();
}
// If the configuration file changes, forget cached program and start the recompilation timer
function configFileChanged() {
setCachedProgram(undefined);
startTimer();
cachedConfigFileText = undefined;
startTimerForRecompilation();
}
function watchedDirectoryChanged(fileName: string) {
if (fileName && !ts.isSupportedSourceFileName(fileName)) {
return;
}
startTimerForHandlingDirectoryChanges();
}
function startTimerForHandlingDirectoryChanges() {
if (timerHandleForDirectoryChanges) {
clearTimeout(timerHandleForDirectoryChanges);
}
timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250);
}
function directoryChangeHandler() {
let parsedCommandLine = parseConfigFile();
let newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName);
let canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName);
if (!arrayStructurallyIsEqualTo(newFileNames, canonicalRootFileNames)) {
setCachedProgram(undefined);
startTimerForRecompilation();
}
}
// Upon detecting a file change, wait for 250ms and then perform a recompilation. This gives batch
// operations (such as saving all modified files in an editor) a chance to complete before we kick
// off a new compilation.
function startTimer() {
if (timerHandle) {
clearTimeout(timerHandle);
function startTimerForRecompilation() {
if (timerHandleForRecompilation) {
clearTimeout(timerHandleForRecompilation);
}
timerHandle = setTimeout(recompile, 250);
timerHandleForRecompilation = setTimeout(recompile, 250);
}
function recompile() {
timerHandle = undefined;
timerHandleForRecompilation = undefined;
reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation));
performCompilation();
}
+24 -7
View File
@@ -64,6 +64,7 @@ namespace ts {
PlusToken,
MinusToken,
AsteriskToken,
AsteriskAsteriskToken,
SlashToken,
PercentToken,
PlusPlusToken,
@@ -86,6 +87,7 @@ namespace ts {
PlusEqualsToken,
MinusEqualsToken,
AsteriskEqualsToken,
AsteriskAsteriskEqualsToken,
SlashEqualsToken,
PercentEqualsToken,
LessThanLessThanEqualsToken,
@@ -562,6 +564,10 @@ namespace ts {
export interface ShorthandPropertyAssignment extends ObjectLiteralElement {
name: Identifier;
questionToken?: Node;
// used when ObjectLiteralExpression is used in ObjectAssignmentPattern
// it is grammar error to appear in actual object initializer
equalsToken?: Node;
objectAssignmentInitializer?: Expression;
}
// SyntaxKind.VariableDeclaration
@@ -707,12 +713,16 @@ namespace ts {
_unaryExpressionBrand: any;
}
export interface PrefixUnaryExpression extends UnaryExpression {
export interface IncrementExpression extends UnaryExpression {
_incrementExpressionBrand: any;
}
export interface PrefixUnaryExpression extends IncrementExpression {
operator: SyntaxKind;
operand: UnaryExpression;
}
export interface PostfixUnaryExpression extends PostfixExpression {
export interface PostfixUnaryExpression extends IncrementExpression {
operand: LeftHandSideExpression;
operator: SyntaxKind;
}
@@ -721,7 +731,7 @@ namespace ts {
_postfixExpressionBrand: any;
}
export interface LeftHandSideExpression extends PostfixExpression {
export interface LeftHandSideExpression extends IncrementExpression {
_leftHandSideExpressionBrand: any;
}
@@ -1598,7 +1608,6 @@ namespace ts {
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
getBlockScopedVariableId(node: Identifier): number;
getReferencedValueDeclaration(reference: Identifier): Declaration;
getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind;
isOptionalParameter(node: ParameterDeclaration): boolean;
@@ -1882,7 +1891,7 @@ namespace ts {
}
export interface TupleType extends ObjectType {
elementTypes: Type[]; // Element types
elementTypes: Type[]; // Element types
}
export interface UnionOrIntersectionType extends Type {
@@ -1897,6 +1906,13 @@ namespace ts {
export interface IntersectionType extends UnionOrIntersectionType { }
/* @internal */
// An instantiated anonymous type has a target and a mapper
export interface AnonymousType extends ObjectType {
target?: AnonymousType; // Instantiation target
mapper?: TypeMapper; // Instantiation mapper
}
/* @internal */
// Resolved object, union, or intersection type
export interface ResolvedType extends ObjectType, UnionOrIntersectionType {
@@ -2072,7 +2088,6 @@ namespace ts {
watch?: boolean;
isolatedModules?: boolean;
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind;
/* @internal */ stripInternal?: boolean;
@@ -2090,6 +2105,7 @@ namespace ts {
UMD = 3,
System = 4,
ES6 = 5,
ES2015 = ES6,
}
export const enum JsxEmit {
@@ -2115,12 +2131,13 @@ namespace ts {
ES3 = 0,
ES5 = 1,
ES6 = 2,
ES2015 = ES6,
Latest = ES6,
}
export const enum LanguageVariant {
Standard,
JSX
JSX,
}
export interface ParsedCommandLine {
+23 -3
View File
@@ -896,6 +896,14 @@ namespace ts {
return nodeIsDecorated(node) || childIsDecorated(node);
}
export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression {
return node.kind === SyntaxKind.PropertyAccessExpression;
}
export function isElementAccessExpression(node: Node): node is ElementAccessExpression {
return node.kind === SyntaxKind.ElementAccessExpression;
}
export function isExpression(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.SuperKeyword:
@@ -1414,7 +1422,7 @@ namespace ts {
* where Symbol is literally the word "Symbol", and name is any identifierName
*/
export function isWellKnownSymbolSyntactically(node: Expression): boolean {
return node.kind === SyntaxKind.PropertyAccessExpression && isESSymbolIdentifier((<PropertyAccessExpression>node).expression);
return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
}
export function getPropertyNameForPropertyNameNode(name: DeclarationName): string {
@@ -2047,8 +2055,8 @@ namespace ts {
if (node.kind === SyntaxKind.Identifier) {
return true;
}
else if (node.kind === SyntaxKind.PropertyAccessExpression) {
return isSupportedExpressionWithTypeArgumentsRest((<PropertyAccessExpression>node).expression);
else if (isPropertyAccessExpression(node)) {
return isSupportedExpressionWithTypeArgumentsRest(node.expression);
}
else {
return false;
@@ -2406,4 +2414,16 @@ namespace ts {
}
}
}
export function arrayStructurallyIsEqualTo<T>(array1: Array<T>, array2: Array<T>): boolean {
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
return arrayIsEqualTo(array1.sort(), array2.sort());
}
}
+23 -9
View File
@@ -100,6 +100,8 @@ namespace FourSlash {
end: number;
}
export import IndentStyle = ts.IndentStyle;
let entityMap: ts.Map<string> = {
"&": "&amp;",
"\"": "&quot;",
@@ -309,6 +311,7 @@ namespace FourSlash {
TabSize: 4,
NewLineCharacter: Harness.IO.newLine(),
ConvertTabsToSpaces: true,
IndentStyle: ts.IndentStyle.Smart,
InsertSpaceAfterCommaDelimiter: true,
InsertSpaceAfterSemicolonInForStatements: true,
InsertSpaceBeforeAndAfterBinaryOperators: true,
@@ -588,14 +591,21 @@ namespace FourSlash {
}
}
public verifyCompletionListItemsCountIsGreaterThan(count: number) {
public verifyCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) {
this.taoInvalidReason = "verifyCompletionListItemsCountIsGreaterThan NYI";
let completions = this.getCompletionListAtCaret();
let itemsCount = completions.entries.length;
if (itemsCount <= count) {
this.raiseError(`Expected completion list items count to be greater than ${count}, but is actually ${itemsCount}`);
if (negative) {
if (itemsCount > count) {
this.raiseError(`Expected completion list items count to not be greater than ${count}, but is actually ${itemsCount}`);
}
}
else {
if (itemsCount <= count) {
this.raiseError(`Expected completion list items count to be greater than ${count}, but is actually ${itemsCount}`);
}
}
}
@@ -1695,24 +1705,28 @@ namespace FourSlash {
}
}
private getIndentation(fileName: string, position: number): number {
return this.languageService.getIndentationAtPosition(fileName, position, this.formatCodeOptions);
private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle): number {
let formatOptions = ts.clone(this.formatCodeOptions);
formatOptions.IndentStyle = indentStyle;
return this.languageService.getIndentationAtPosition(fileName, position, formatOptions);
}
public verifyIndentationAtCurrentPosition(numberOfSpaces: number) {
public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) {
this.taoInvalidReason = "verifyIndentationAtCurrentPosition NYI";
let actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition);
let actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle);
let lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);
if (actual !== numberOfSpaces) {
this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
}
}
public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number) {
public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) {
this.taoInvalidReason = "verifyIndentationAtPosition NYI";
let actual = this.getIndentation(fileName, position);
let actual = this.getIndentation(fileName, position, indentStyle);
let lineCol = this.getLineColStringAtPosition(position);
if (actual !== numberOfSpaces) {
this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
+7 -1
View File
@@ -572,6 +572,10 @@ namespace Harness.LanguageService {
return { close() { } };
}
watchDirectory(path: string, callback: (path: string) => void, recursive?: boolean): ts.FileWatcher {
return { close() { } };
}
close(): void {
}
@@ -614,7 +618,9 @@ namespace Harness.LanguageService {
// This host is just a proxy for the clientHost, it uses the client
// host to answer server queries about files on disk
let serverHost = new SessionServerHost(clientHost);
let server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost);
let server = new ts.server.Session(serverHost,
Buffer ? Buffer.byteLength : (string: string, encoding?: string) => string.length,
process.hrtime, serverHost);
// Fake the connection between the client and the server
serverHost.writeMessage = client.onMessage.bind(client);
+2 -2
View File
@@ -78,8 +78,8 @@ namespace RWC {
let tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
if (tsconfigFile) {
let tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path);
let parsedTsconfigFileContents = ts.parseConfigFileText(tsconfigFile.path, tsconfigFileContents.content);
let configParseResult = ts.parseConfigFile(parsedTsconfigFileContents.config, Harness.IO, ts.getDirectoryPath(tsconfigFile.path));
let parsedTsconfigFileContents = ts.parseConfigFileTextToJson(tsconfigFile.path, tsconfigFileContents.content);
let configParseResult = ts.parseJsonConfigFileContent(parsedTsconfigFileContents.config, Harness.IO, ts.getDirectoryPath(tsconfigFile.path));
fileNames = configParseResult.fileNames;
opts.options = ts.extend(opts.options, configParseResult.options);
}
+3 -1
View File
@@ -57,7 +57,9 @@ class TypeWriterWalker {
symbolString += ", ";
let declSourceFile = declaration.getSourceFile();
let declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos);
symbolString += `Decl(${ ts.getBaseFileName(declSourceFile.fileName) }, ${ declLineAndCharacter.line }, ${ declLineAndCharacter.character })`;
let fileName = ts.getBaseFileName(declSourceFile.fileName);
let isLibFile = /lib(.*)\.d\.ts/i.test(fileName);
symbolString += `Decl(${ fileName }, ${ isLibFile ? "--" : declLineAndCharacter.line }, ${ isLibFile ? "--" : declLineAndCharacter.character })`;
}
}
symbolString += ")";
+9 -107
View File
@@ -1067,7 +1067,7 @@ declare var CanvasPattern: {
interface CanvasRenderingContext2D {
canvas: HTMLCanvasElement;
fillStyle: any;
fillStyle: string | CanvasGradient | CanvasPattern;
font: string;
globalAlpha: number;
globalCompositeOperation: string;
@@ -1082,7 +1082,7 @@ interface CanvasRenderingContext2D {
shadowColor: string;
shadowOffsetX: number;
shadowOffsetY: number;
strokeStyle: any;
strokeStyle: string | CanvasGradient | CanvasPattern;
textAlign: string;
textBaseline: string;
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void;
@@ -2450,8 +2450,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
importNode(importedNode: Node, deep: boolean): Node;
msElementsFromPoint(x: number, y: number): NodeList;
msElementsFromRect(left: number, top: number, width: number, height: number): NodeList;
msGetPrintDocumentForNamedFlow(flowName: string): Document;
msSetPrintDocumentUriForNamedFlow(flowName: string, uri: string): void;
/**
* Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method.
* @param url Specifies a MIME type for the document.
@@ -7273,27 +7271,6 @@ declare var MSHTMLWebViewElement: {
new(): MSHTMLWebViewElement;
}
interface MSHeaderFooter {
URL: string;
dateLong: string;
dateShort: string;
font: string;
htmlFoot: string;
htmlHead: string;
page: number;
pageTotal: number;
textFoot: string;
textHead: string;
timeLong: string;
timeShort: string;
title: string;
}
declare var MSHeaderFooter: {
prototype: MSHeaderFooter;
new(): MSHeaderFooter;
}
interface MSInputMethodContext extends EventTarget {
compositionEndOffset: number;
compositionStartOffset: number;
@@ -7452,24 +7429,6 @@ declare var MSPointerEvent: {
new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent;
}
interface MSPrintManagerTemplatePrinter extends MSTemplatePrinter, EventTarget {
percentScale: number;
showHeaderFooter: boolean;
shrinkToFit: boolean;
drawPreviewPage(element: HTMLElement, pageNumber: number): void;
endPrint(): void;
getPrintTaskOptionValue(key: string): any;
invalidatePreview(): void;
setPageCount(pageCount: number): void;
startPrint(): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
declare var MSPrintManagerTemplatePrinter: {
prototype: MSPrintManagerTemplatePrinter;
new(): MSPrintManagerTemplatePrinter;
}
interface MSRangeCollection {
length: number;
item(index: number): Range;
@@ -7517,63 +7476,6 @@ declare var MSStreamReader: {
new(): MSStreamReader;
}
interface MSTemplatePrinter {
collate: boolean;
copies: number;
currentPage: boolean;
currentPageAvail: boolean;
duplex: boolean;
footer: string;
frameActive: boolean;
frameActiveEnabled: boolean;
frameAsShown: boolean;
framesetDocument: boolean;
header: string;
headerFooterFont: string;
marginBottom: number;
marginLeft: number;
marginRight: number;
marginTop: number;
orientation: string;
pageFrom: number;
pageHeight: number;
pageTo: number;
pageWidth: number;
selectedPages: boolean;
selection: boolean;
selectionEnabled: boolean;
unprintableBottom: number;
unprintableLeft: number;
unprintableRight: number;
unprintableTop: number;
usePrinterCopyCollate: boolean;
createHeaderFooter(): MSHeaderFooter;
deviceSupports(property: string): any;
ensurePrintDialogDefaults(): boolean;
getPageMarginBottom(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any;
getPageMarginBottomImportant(pageRule: CSSPageRule): boolean;
getPageMarginLeft(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any;
getPageMarginLeftImportant(pageRule: CSSPageRule): boolean;
getPageMarginRight(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any;
getPageMarginRightImportant(pageRule: CSSPageRule): boolean;
getPageMarginTop(pageRule: CSSPageRule, pageWidth: number, pageHeight: number): any;
getPageMarginTopImportant(pageRule: CSSPageRule): boolean;
printBlankPage(): void;
printNonNative(document: any): boolean;
printNonNativeFrames(document: any, activeFrame: boolean): void;
printPage(element: HTMLElement): void;
showPageSetupDialog(): boolean;
showPrintDialog(): boolean;
startDoc(title: string): boolean;
stopDoc(): void;
updatePageStatus(status: number): void;
}
declare var MSTemplatePrinter: {
prototype: MSTemplatePrinter;
new(): MSTemplatePrinter;
}
interface MSWebViewAsyncOperation extends EventTarget {
error: DOMError;
oncomplete: (ev: Event) => any;
@@ -7991,6 +7893,10 @@ declare var Node: {
}
interface NodeFilter {
acceptNode(n: Node): number;
}
declare var NodeFilter: {
FILTER_ACCEPT: number;
FILTER_REJECT: number;
FILTER_SKIP: number;
@@ -8008,7 +7914,6 @@ interface NodeFilter {
SHOW_PROCESSING_INSTRUCTION: number;
SHOW_TEXT: number;
}
declare var NodeFilter: NodeFilter;
interface NodeIterator {
expandEntityReferences: boolean;
@@ -8718,7 +8623,6 @@ declare var SVGDescElement: {
interface SVGElement extends Element {
id: string;
className: any;
onclick: (ev: MouseEvent) => any;
ondblclick: (ev: MouseEvent) => any;
onfocusin: (ev: FocusEvent) => any;
@@ -8732,6 +8636,7 @@ interface SVGElement extends Element {
ownerSVGElement: SVGSVGElement;
viewportElement: SVGElement;
xmlbase: string;
className: any;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -11871,7 +11776,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
locationbar: BarProp;
menubar: BarProp;
msAnimationStartTime: number;
msTemplatePrinter: MSTemplatePrinter;
name: string;
navigator: Navigator;
offscreenBuffering: string | boolean;
@@ -12608,7 +12512,6 @@ interface XMLHttpRequestEventTarget {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface NodeListOf<TNode extends Node> extends NodeList {
length: number;
item(index: number): TNode;
@@ -12629,8 +12532,6 @@ interface EventListenerObject {
handleEvent(evt: Event): void;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
@@ -12646,6 +12547,8 @@ interface ProgressEventInit extends EventInit {
total?: number;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -12706,7 +12609,6 @@ declare var location: Location;
declare var locationbar: BarProp;
declare var menubar: BarProp;
declare var msAnimationStartTime: number;
declare var msTemplatePrinter: MSTemplatePrinter;
declare var name: string;
declare var navigator: Navigator;
declare var offscreenBuffering: string | boolean;
+2 -3
View File
@@ -894,7 +894,6 @@ interface WorkerUtils extends Object, WindowBase64 {
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
@@ -909,8 +908,6 @@ interface EventListenerObject {
handleEvent(evt: Event): void;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
@@ -926,6 +923,8 @@ interface ProgressEventInit extends EventInit {
total?: number;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
+204 -56
View File
@@ -78,19 +78,19 @@ namespace ts.server {
return this.snap().getChangeRange(oldSnapshot);
}
}
interface TimestampedResolvedModule extends ResolvedModuleWithFailedLookupLocations {
lastCheckTime: number;
lastCheckTime: number;
}
export class LSHost implements ts.LanguageServiceHost {
ls: ts.LanguageService = null;
compilationSettings: ts.CompilerOptions;
filenameToScript: ts.Map<ScriptInfo> = {};
roots: ScriptInfo[] = [];
private resolvedModuleNames: ts.FileMap<Map<TimestampedResolvedModule>>;
private resolvedModuleNames: ts.FileMap<Map<TimestampedResolvedModule>>;
private moduleResolutionHost: ts.ModuleResolutionHost;
constructor(public host: ServerHost, public project: Project) {
this.resolvedModuleNames = ts.createFileMap<Map<TimestampedResolvedModule>>(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))
this.moduleResolutionHost = {
@@ -98,15 +98,15 @@ namespace ts.server {
readFile: fileName => this.host.readFile(fileName)
}
}
resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] {
let currentResolutionsInFile = this.resolvedModuleNames.get(containingFile);
let newResolutions: Map<TimestampedResolvedModule> = {};
let resolvedModules: ResolvedModule[] = [];
let compilerOptions = this.getCompilationSettings();
for (let moduleName of moduleNames) {
// check if this is a duplicate entry in the list
let resolution = lookUp(newResolutions, moduleName);
@@ -122,21 +122,21 @@ namespace ts.server {
newResolutions[moduleName] = resolution;
}
}
ts.Debug.assert(resolution !== undefined);
resolvedModules.push(resolution.resolvedModule);
}
// replace old results with a new one
this.resolvedModuleNames.set(containingFile, newResolutions);
return resolvedModules;
function moduleResolutionIsValid(resolution: TimestampedResolvedModule): boolean {
if (!resolution) {
return false;
}
if (resolution.resolvedModule) {
// TODO: consider checking failedLookupLocations
// TODO: use lastCheckTime to track expiration for module name resolution
@@ -147,7 +147,7 @@ namespace ts.server {
// after all there is no point to invalidate it if we have no idea where to look for the module.
return resolution.failedLookupLocations.length === 0;
}
}
}
getDefaultLibFileName() {
var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath()));
@@ -224,12 +224,13 @@ namespace ts.server {
this.roots.push(info);
}
}
removeRoot(info: ScriptInfo) {
var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName);
if (scriptInfo) {
this.filenameToScript[info.fileName] = undefined;
this.roots = copyListRemovingItem(info, this.roots);
this.resolvedModuleNames.remove(info.fileName);
}
}
@@ -354,6 +355,9 @@ namespace ts.server {
compilerService: CompilerService;
projectFilename: string;
projectFileWatcher: FileWatcher;
directoryWatcher: FileWatcher;
// Used to keep track of what directories are watched for this project
directoriesWatchedForTsconfig: string[] = [];
program: ts.Program;
filenameToSourceFile: ts.Map<ts.SourceFile> = {};
updateGraphSeq = 0;
@@ -377,6 +381,10 @@ namespace ts.server {
return this.projectService.openFile(filename, false);
}
getRootFiles() {
return this.compilerService.host.roots.map(info => info.fileName);
}
getFileNames() {
let sourceFiles = this.program.getSourceFiles();
return sourceFiles.map(sourceFile => sourceFile.fileName);
@@ -429,13 +437,11 @@ namespace ts.server {
// add a root file to project
addRoot(info: ScriptInfo) {
info.defaultProject = this;
this.compilerService.host.addRoot(info);
}
// remove a root file from project
removeRoot(info: ScriptInfo) {
info.defaultProject = undefined;
this.compilerService.host.removeRoot(info);
}
@@ -491,7 +497,13 @@ namespace ts.server {
openFilesReferenced: ScriptInfo[] = [];
// open files that are roots of a configured project
openFileRootsConfigured: ScriptInfo[] = [];
// a path to directory watcher map that detects added tsconfig files
directoryWatchersForTsconfig: ts.Map<FileWatcher> = {};
// count of how many projects are using the directory watcher. If the
// number becomes 0 for a watcher, then we should close it.
directoryWatchersRefCount: ts.Map<number> = {};
hostConfiguration: HostConfiguration;
timerForDetectingProjectFilelistChanges: Map<NodeJS.Timer> = {};
constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) {
// ts.disableIncrementalParsing = true;
@@ -532,8 +544,82 @@ namespace ts.server {
}
}
/**
* This is the callback function when a watched directory has added or removed source code files.
* @param project the project that associates with this directory watcher
* @param fileName the absolute file name that changed in watched directory
*/
directoryWatchedForSourceFilesChanged(project: Project, fileName: string) {
// If a change was made inside "folder/file", node will trigger the callback twice:
// one with the fileName being "folder/file", and the other one with "folder".
// We don't respond to the second one.
if (fileName && !ts.isSupportedSourceFileName(fileName)) {
return;
}
this.log("Detected source file changes: " + fileName);
this.startTimerForDetectingProjectFilelistChanges(project);
}
startTimerForDetectingProjectFilelistChanges(project: Project) {
if (this.timerForDetectingProjectFilelistChanges[project.projectFilename]) {
clearTimeout(this.timerForDetectingProjectFilelistChanges[project.projectFilename]);
}
this.timerForDetectingProjectFilelistChanges[project.projectFilename] = setTimeout(
() => this.handleProjectFilelistChanges(project),
250
);
}
handleProjectFilelistChanges(project: Project) {
let { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename);
let newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
let currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
if (!arrayStructurallyIsEqualTo(currentRootFiles, newRootFiles)) {
// For configured projects, the change is made outside the tsconfig file, and
// it is not likely to affect the project for other files opened by the client. We can
// just update the current project.
this.updateConfiguredProject(project);
// Call updateProjectStructure to clean up inferred projects we may have
// created for the new files
this.updateProjectStructure();
}
}
/**
* This is the callback function when a watched directory has an added tsconfig file.
*/
directoryWatchedForTsconfigChanged(fileName: string) {
if (ts.getBaseFileName(fileName) != "tsconfig.json") {
this.log(fileName + " is not tsconfig.json");
return;
}
this.log("Detected newly added tsconfig file: " + fileName);
let { succeeded, projectOptions, error } = this.configFileToProjectOptions(fileName);
let rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f));
let openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName));
// We should only care about the new tsconfig file if it contains any
// opened root files of existing inferred projects
for (let openFileRoot of openFileRoots) {
if (rootFilesInTsconfig.indexOf(openFileRoot) >= 0) {
this.reloadProjects();
return;
}
}
}
getCanonicalFileName(fileName: string) {
let name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
return ts.normalizePath(name);
}
watchedProjectConfigFileChanged(project: Project) {
this.log("Config File Changed: " + project.projectFilename);
this.log("Config file changed: " + project.projectFilename);
this.updateConfiguredProject(project);
this.updateProjectStructure();
}
@@ -567,11 +653,29 @@ namespace ts.server {
}
createInferredProject(root: ScriptInfo) {
var iproj = new Project(this);
iproj.addRoot(root);
iproj.finishGraph();
this.inferredProjects.push(iproj);
return iproj;
var project = new Project(this);
project.addRoot(root);
let currentPath = ts.getDirectoryPath(root.fileName);
let parentPath = ts.getDirectoryPath(currentPath);
while (currentPath != parentPath) {
if (!project.projectService.directoryWatchersForTsconfig[currentPath]) {
this.log("Add watcher for: " + currentPath);
project.projectService.directoryWatchersForTsconfig[currentPath] =
this.host.watchDirectory(currentPath, fileName => this.directoryWatchedForTsconfigChanged(fileName));
project.projectService.directoryWatchersRefCount[currentPath] = 1;
}
else {
project.projectService.directoryWatchersRefCount[currentPath] += 1;
}
project.directoriesWatchedForTsconfig.push(currentPath);
currentPath = parentPath;
parentPath = ts.getDirectoryPath(parentPath);
}
project.finishGraph();
this.inferredProjects.push(project);
return project;
}
fileDeletedInFilesystem(info: ScriptInfo) {
@@ -585,6 +689,9 @@ namespace ts.server {
if (!info.isOpen) {
this.filenameToScriptInfo[info.fileName] = undefined;
var referencingProjects = this.findReferencingProjects(info);
if (info.defaultProject) {
info.defaultProject.removeRoot(info);
}
for (var i = 0, len = referencingProjects.length; i < len; i++) {
referencingProjects[i].removeReferencedFile(info);
}
@@ -615,9 +722,24 @@ namespace ts.server {
this.configuredProjects = configuredProjects;
}
removeConfiguredProject(project: Project) {
project.projectFileWatcher.close();
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
removeProject(project: Project) {
this.log("remove project: " + project.getRootFiles().toString());
if (project.isConfiguredProject()) {
project.projectFileWatcher.close();
project.directoryWatcher.close();
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
}
else {
for (let directory of project.directoriesWatchedForTsconfig) {
// if the ref count for this directory watcher drops to 0, it's time to close it
if (!(--project.projectService.directoryWatchersRefCount[directory])) {
this.log("Close directory watcher for: " + directory);
project.projectService.directoryWatchersForTsconfig[directory].close();
delete project.projectService.directoryWatchersForTsconfig[directory];
}
}
this.inferredProjects = copyListRemovingItem(project, this.inferredProjects);
}
let fileNames = project.getFileNames();
for (let fileName of fileNames) {
@@ -659,8 +781,7 @@ namespace ts.server {
// if r referenced by the new project
if (info.defaultProject.getSourceFile(r)) {
// remove project rooted at r
this.inferredProjects =
copyListRemovingItem(r.defaultProject, this.inferredProjects);
this.removeProject(r.defaultProject);
// put r in referenced open file list
this.openFilesReferenced.push(r);
// set default project of r to the new project
@@ -683,6 +804,11 @@ namespace ts.server {
* @param info The file that has been closed or newly configured
*/
closeOpenFile(info: ScriptInfo) {
// Closing file should trigger re-reading the file content from disk. This is
// because the user may chose to discard the buffer content before saving
// to the disk, and the server's version of the file can be out of sync.
info.svc.reloadFromFile(info.fileName);
var openFileRoots: ScriptInfo[] = [];
var removedProject: Project;
for (var i = 0, len = this.openFileRoots.length; i < len; i++) {
@@ -713,19 +839,14 @@ namespace ts.server {
this.openFileRootsConfigured = openFileRootsConfigured;
}
if (removedProject) {
if (removedProject.isConfiguredProject()) {
this.configuredProjects = copyListRemovingItem(removedProject, this.configuredProjects);
}
else {
this.inferredProjects = copyListRemovingItem(removedProject, this.inferredProjects);
}
this.removeProject(removedProject);
var openFilesReferenced: ScriptInfo[] = [];
var orphanFiles: ScriptInfo[] = [];
// for all open, referenced files f
for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) {
var f = this.openFilesReferenced[i];
// if f was referenced by the removed project, remember it
if (f.defaultProject === removedProject) {
if (f.defaultProject === removedProject || !f.defaultProject) {
f.defaultProject = undefined;
orphanFiles.push(f);
}
@@ -769,7 +890,11 @@ namespace ts.server {
return referencingProjects;
}
/**
* This function rebuilds the project for every file opened by the client
*/
reloadProjects() {
this.log("reload projects.");
// First check if there is new tsconfig file added for inferred project roots
for (let info of this.openFileRoots) {
this.openOrUpdateConfiguredProjectForFile(info.fileName);
@@ -830,14 +955,25 @@ namespace ts.server {
var rootFile = this.openFileRoots[i];
var rootedProject = rootFile.defaultProject;
var referencingProjects = this.findReferencingProjects(rootFile, rootedProject);
if (referencingProjects.length === 0) {
rootFile.defaultProject = rootedProject;
openFileRoots.push(rootFile);
if (rootFile.defaultProject && rootFile.defaultProject.isConfiguredProject()) {
// If the root file has already been added into a configured project,
// meaning the original inferred project is gone already.
if (!rootedProject.isConfiguredProject()) {
this.removeProject(rootedProject);
}
this.openFileRootsConfigured.push(rootFile);
}
else {
// remove project from inferred projects list because root captured
this.inferredProjects = copyListRemovingItem(rootedProject, this.inferredProjects);
this.openFilesReferenced.push(rootFile);
if (referencingProjects.length === 0) {
rootFile.defaultProject = rootedProject;
openFileRoots.push(rootFile);
}
else {
// remove project from inferred projects list because root captured
this.removeProject(rootedProject);
this.openFilesReferenced.push(rootFile);
}
}
}
this.openFileRoots = openFileRoots;
@@ -922,6 +1058,11 @@ namespace ts.server {
return info;
}
/**
* This function tries to search for a tsconfig.json for the given file. If we found it,
* we first detect if there is already a configured project created for it: if so, we re-read
* the tsconfig file content and update the project; otherwise we create a new one.
*/
openOrUpdateConfiguredProjectForFile(fileName: string) {
let searchPath = ts.normalizePath(getDirectoryPath(fileName));
this.log("Search path: " + searchPath, "Info");
@@ -1041,17 +1182,17 @@ namespace ts.server {
// file references will be relative to dirPath (or absolute)
var dirPath = ts.getDirectoryPath(configFilename);
var contents = this.host.readFile(configFilename)
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileText(configFilename, contents);
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileTextToJson(configFilename, contents);
if (rawConfig.error) {
return { succeeded: false, error: rawConfig.error };
}
else {
var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath);
var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath);
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
return { succeeded: false, error: { errorMsg: "tsconfig option errors" } };
}
else if (parsedCommandLine.fileNames == null) {
return { succeeded: false, error: { errorMsg: "no files found" } }
return { succeeded: false, error: { errorMsg: "no files found" } };
}
else {
var projectOptions: ProjectOptions = {
@@ -1070,27 +1211,32 @@ namespace ts.server {
return error;
}
else {
let proj = this.createProject(configFilename, projectOptions);
for (let i = 0, len = projectOptions.files.length; i < len; i++) {
let rootFilename = projectOptions.files[i];
let project = this.createProject(configFilename, projectOptions);
for (let rootFilename of projectOptions.files) {
if (this.host.fileExists(rootFilename)) {
let info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename);
proj.addRoot(info);
project.addRoot(info);
}
else {
return { errorMsg: "specified file " + rootFilename + " not found" };
}
}
proj.finishGraph();
proj.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(proj));
return { success: true, project: proj };
project.finishGraph();
project.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(project));
this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename));
project.directoryWatcher = this.host.watchDirectory(
ts.getDirectoryPath(configFilename),
path => this.directoryWatchedForSourceFilesChanged(project, path),
/*recursive*/ true
);
return { success: true, project: project };
}
}
updateConfiguredProject(project: Project) {
if (!this.host.fileExists(project.projectFilename)) {
this.log("Config file deleted");
this.removeConfiguredProject(project);
this.removeProject(project);
}
else {
let { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename);
@@ -1105,7 +1251,9 @@ namespace ts.server {
for (let fileName of fileNamesToRemove) {
let info = this.getScriptInfo(fileName);
project.removeRoot(info);
if (info) {
project.removeRoot(info);
}
}
for (let fileName of fileNamesToAdd) {
@@ -1177,6 +1325,7 @@ namespace ts.server {
TabSize: 4,
NewLineCharacter: ts.sys ? ts.sys.newLine : '\n',
ConvertTabsToSpaces: true,
IndentStyle: ts.IndentStyle.Smart,
InsertSpaceAfterCommaDelimiter: true,
InsertSpaceAfterSemicolonInForStatements: true,
InsertSpaceBeforeAndAfterBinaryOperators: true,
@@ -1187,7 +1336,6 @@ namespace ts.server {
PlaceOpenBraceOnNewLineForFunctions: false,
PlaceOpenBraceOnNewLineForControlBlocks: false,
}
}
export interface LineCollection {
@@ -1217,9 +1365,9 @@ namespace ts.server {
goSubtree: boolean;
done: boolean;
leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void;
pre? (relativeStart: number, relativeLength: number, lineCollection: LineCollection,
pre?(relativeStart: number, relativeLength: number, lineCollection: LineCollection,
parent: LineNode, nodeType: CharRangeSection): LineCollection;
post? (relativeStart: number, relativeLength: number, lineCollection: LineCollection,
post?(relativeStart: number, relativeLength: number, lineCollection: LineCollection,
parent: LineNode, nodeType: CharRangeSection): LineCollection;
}
+3 -113
View File
@@ -11,7 +11,7 @@ namespace ts.server {
input: process.stdin,
output: process.stdout,
terminal: false,
});
});
class Logger implements ts.server.Logger {
fd = -1;
@@ -58,7 +58,7 @@ namespace ts.server {
isVerbose() {
return this.loggingEnabled() && (this.level == "verbose");
}
msg(s: string, type = "Err") {
if (this.fd < 0) {
@@ -83,95 +83,6 @@ namespace ts.server {
}
}
interface WatchedFile {
fileName: string;
callback: (fileName: string, removed: boolean) => void;
mtime: Date;
}
class WatchedFileSet {
private watchedFiles: WatchedFile[] = [];
private nextFileToCheck = 0;
private watchTimer: NodeJS.Timer;
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
constructor(public interval = 2500, public chunkSize = 30) {
}
private static copyListRemovingItem<T>(item: T, list: T[]) {
var copiedList: T[] = [];
for (var i = 0, len = list.length; i < len; i++) {
if (list[i] != item) {
copiedList.push(list[i]);
}
}
return copiedList;
}
private static getModifiedTime(fileName: string): Date {
return fs.statSync(fileName).mtime;
}
private poll(checkedIndex: number) {
var watchedFile = this.watchedFiles[checkedIndex];
if (!watchedFile) {
return;
}
fs.stat(watchedFile.fileName,(err, stats) => {
if (err) {
watchedFile.callback(watchedFile.fileName, /* removed */ false);
}
else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) {
watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName);
watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0);
}
});
}
// this implementation uses polling and
// stat due to inconsistencies of fs.watch
// and efficiency of stat on modern filesystems
private startWatchTimer() {
this.watchTimer = setInterval(() => {
var count = 0;
var nextToCheck = this.nextFileToCheck;
var firstCheck = -1;
while ((count < this.chunkSize) && (nextToCheck !== firstCheck)) {
this.poll(nextToCheck);
if (firstCheck < 0) {
firstCheck = nextToCheck;
}
nextToCheck++;
if (nextToCheck === this.watchedFiles.length) {
nextToCheck = 0;
}
count++;
}
this.nextFileToCheck = nextToCheck;
}, this.interval);
}
addFile(fileName: string, callback: (fileName: string, removed: boolean) => void ): WatchedFile {
var file: WatchedFile = {
fileName,
callback,
mtime: WatchedFileSet.getModifiedTime(fileName)
};
this.watchedFiles.push(file);
if (this.watchedFiles.length === 1) {
this.startWatchTimer();
}
return file;
}
removeFile(file: WatchedFile) {
this.watchedFiles = WatchedFileSet.copyListRemovingItem(file, this.watchedFiles);
}
}
class IOSession extends Session {
constructor(host: ServerHost, logger: ts.server.Logger) {
super(host, Buffer.byteLength, process.hrtime, logger);
@@ -244,31 +155,10 @@ namespace ts.server {
var logger = createLoggerFromEnv();
// REVIEW: for now this implementation uses polling.
// The advantage of polling is that it works reliably
// on all os and with network mounted files.
// For 90 referenced files, the average time to detect
// changes is 2*msInterval (by default 5 seconds).
// The overhead of this is .04 percent (1/2500) with
// average pause of < 1 millisecond (and max
// pause less than 1.5 milliseconds); question is
// do we anticipate reference sets in the 100s and
// do we care about waiting 10-20 seconds to detect
// changes for large reference sets? If so, do we want
// to increase the chunk size or decrease the interval
// time dynamically to match the large reference set?
var watchedFileSet = new WatchedFileSet();
ts.sys.watchFile = function (fileName, callback) {
var watchedFile = watchedFileSet.addFile(fileName, callback);
return {
close: () => watchedFileSet.removeFile(watchedFile)
}
};
var ioSession = new IOSession(ts.sys, logger);
process.on('uncaughtException', function(err: Error) {
ioSession.logError(err, "unknown");
});
// Start listening
ioSession.listen();
}
}
+26 -11
View File
@@ -21,6 +21,21 @@ namespace ts.server {
return spaceCache[n];
}
export function generateIndentString(n: number, editorOptions: EditorOptions): string {
if (editorOptions.ConvertTabsToSpaces) {
return generateSpaces(n);
} else {
var result = "";
for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) {
result += "\t";
}
for (var i = 0; i < n % editorOptions.TabSize; i++) {
result += " ";
}
return result;
}
}
interface FileStart {
file: string;
start: ILineInfo;
@@ -606,28 +621,27 @@ namespace ts.server {
TabSize: formatOptions.TabSize,
NewLineCharacter: "\n",
ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces,
IndentStyle: ts.IndentStyle.Smart,
};
var indentPosition =
compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
var hasIndent = 0;
for (var i = 0, len = lineText.length; i < len; i++) {
if (lineText.charAt(i) == " ") {
indentPosition--;
hasIndent++;
}
else if (lineText.charAt(i) == "\t") {
indentPosition -= editorOptions.IndentSize;
hasIndent += editorOptions.TabSize;
}
else {
break;
}
}
if (indentPosition > 0) {
var spaces = generateSpaces(indentPosition);
edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces });
}
else if (indentPosition < 0) {
// i points to the first non whitespace character
if (preferredIndent !== hasIndent) {
var firstNoWhiteSpacePosition = lineInfo.offset + i;
edits.push({
span: ts.createTextSpanFromBounds(position, position - indentPosition),
newText: ""
span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition),
newText: generateIndentString(preferredIndent, editorOptions)
});
}
}
@@ -779,6 +793,7 @@ namespace ts.server {
}
private closeClientFile(fileName: string) {
if (!fileName) { return; }
var file = ts.normalizePath(fileName);
this.projectService.closeClientFile(file);
}
+13 -3
View File
@@ -214,10 +214,13 @@ namespace ts.formatting {
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
// Async functions
public SpaceBetweenAsyncAndOpenParen: Rule;
public SpaceBetweenAsyncAndFunctionKeyword: Rule;
// Tagged template string
// Template strings
public SpaceBetweenTagAndTemplateString: Rule;
public NoSpaceAfterTemplateHeadAndMiddle: Rule;
public NoSpaceBeforeTemplateMiddleAndTail: Rule;
constructor() {
///
@@ -367,10 +370,13 @@ namespace ts.formatting {
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
// Async-await
this.SpaceBetweenAsyncAndOpenParen = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
// template string
this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
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 =
@@ -398,8 +404,8 @@ namespace ts.formatting {
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword,
this.SpaceBetweenTagAndTemplateString,
this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
@@ -699,6 +705,10 @@ namespace ts.formatting {
return context.currentTokenSpan.kind !== SyntaxKind.CommaToken;
}
static IsArrowFunctionContext(context: FormattingContext): boolean {
return context.contextNode.kind === SyntaxKind.ArrowFunction;
}
static IsSameLineTokenContext(context: FormattingContext): boolean {
return context.TokensAreOnSameLine();
}
+29 -3
View File
@@ -13,6 +13,12 @@ namespace ts.formatting {
return 0; // past EOF
}
// no indentation when the indent style is set to none,
// so we can return fast
if (options.IndentStyle === IndentStyle.None) {
return 0;
}
let precedingToken = findPrecedingToken(position, sourceFile);
if (!precedingToken) {
return 0;
@@ -26,6 +32,26 @@ namespace ts.formatting {
let lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
// indentation is first non-whitespace character in a previous line
// for block indentation, we should look for a line which contains something that's not
// whitespace.
if (options.IndentStyle === IndentStyle.Block) {
// move backwards until we find a line with a non-whitespace character,
// then find the first non-whitespace character for that line.
let current = position;
while (current > 0){
let char = sourceFile.text.charCodeAt(current);
if (!isWhiteSpace(char) && !isLineBreak(char)) {
break;
}
current--;
}
let lineStart = ts.getLineStartPositionForPosition(current, sourceFile);
return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options);
}
if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
let actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
@@ -218,7 +244,7 @@ namespace ts.formatting {
function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter {
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
}
export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean {
if (parent.kind === SyntaxKind.IfStatement && (<IfStatement>parent).elseStatement === child) {
let elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile);
@@ -319,7 +345,7 @@ namespace ts.formatting {
}
return Value.Unknown;
function getStartingExpression(node: PropertyAccessExpression | CallExpression | ElementAccessExpression) {
while (true) {
switch (node.kind) {
@@ -465,4 +491,4 @@ namespace ts.formatting {
}
}
}
}
}
+57 -12
View File
@@ -1189,6 +1189,13 @@ namespace ts {
TabSize: number;
NewLineCharacter: string;
ConvertTabsToSpaces: boolean;
IndentStyle: IndentStyle;
}
export enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
export interface FormatCodeOptions extends EditorOptions {
@@ -1850,8 +1857,8 @@ namespace ts {
// so pass --noResolve to avoid reporting missing file errors.
options.noResolve = true;
// Parse
let inputFileName = transpileOptions.fileName || "module.ts";
// if jsx is specified then treat file as .tsx
let inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts");
let sourceFile = createSourceFile(inputFileName, input, options.target);
if (transpileOptions.moduleName) {
sourceFile.moduleName = transpileOptions.moduleName;
@@ -3105,6 +3112,7 @@ namespace ts {
let node = currentToken;
let isRightOfDot = false;
let isRightOfOpenTag = false;
let isStartingCloseTag = false;
let location = getTouchingPropertyName(sourceFile, position);
if (contextToken) {
@@ -3130,9 +3138,14 @@ namespace ts {
return undefined;
}
}
else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) {
isRightOfOpenTag = true;
location = contextToken;
else if (sourceFile.languageVariant === LanguageVariant.JSX) {
if (kind === SyntaxKind.LessThanToken) {
isRightOfOpenTag = true;
location = contextToken;
}
else if (kind === SyntaxKind.SlashToken && contextToken.parent.kind === SyntaxKind.JsxClosingElement) {
isStartingCloseTag = true;
}
}
}
@@ -3155,6 +3168,13 @@ namespace ts {
isMemberCompletion = true;
isNewIdentifierLocation = false;
}
else if (isStartingCloseTag) {
let tagName = (<JsxElement>contextToken.parent.parent).openingElement.tagName;
symbols = [typeChecker.getSymbolAtLocation(tagName)];
isMemberCompletion = true;
isNewIdentifierLocation = false;
}
else {
// For JavaScript or TypeScript, if we're not after a dot, then just try to get the
// global symbols in scope. These results should be valid for either language as
@@ -3311,11 +3331,29 @@ namespace ts {
let start = new Date().getTime();
let result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) ||
isSolelyIdentifierDefinitionLocation(contextToken) ||
isDotOfNumericLiteral(contextToken);
isDotOfNumericLiteral(contextToken) ||
isInJsxText(contextToken);
log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start));
return result;
}
function isInJsxText(contextToken: Node): boolean {
if (contextToken.kind === SyntaxKind.JsxText) {
return true;
}
if (contextToken.kind === SyntaxKind.GreaterThanToken && contextToken.parent) {
if (contextToken.parent.kind === SyntaxKind.JsxOpeningElement) {
return true;
}
if (contextToken.parent.kind === SyntaxKind.JsxClosingElement || contextToken.parent.kind === SyntaxKind.JsxSelfClosingElement) {
return contextToken.parent.parent && contextToken.parent.parent.kind === SyntaxKind.JsxElement;
}
}
return false;
}
function isNewIdentifierDefinitionLocation(previousToken: Node): boolean {
if (previousToken) {
let containingNodeKind = previousToken.parent.kind;
@@ -3683,14 +3721,20 @@ namespace ts {
// Previous token may have been a keyword that was converted to an identifier.
switch (contextToken.getText()) {
case "abstract":
case "async":
case "class":
case "interface":
case "const":
case "declare":
case "enum":
case "function":
case "var":
case "static":
case "interface":
case "let":
case "const":
case "private":
case "protected":
case "public":
case "static":
case "var":
case "yield":
return true;
}
@@ -4099,8 +4143,9 @@ namespace ts {
let useConstructSignatures = callExpression.kind === SyntaxKind.NewExpression || callExpression.expression.kind === SyntaxKind.SuperKeyword;
let allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
if (!contains(allSignatures, signature.target || signature)) {
// Get the first signature if there
if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) {
// Get the first signature if there is one -- allSignatures may contain
// either the original signature or its target, so check for either
signature = allSignatures.length ? allSignatures[0] : undefined;
}
+2 -2
View File
@@ -990,7 +990,7 @@ namespace ts {
() => {
let text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength());
let result = parseConfigFileText(fileName, text);
let result = parseConfigFileTextToJson(fileName, text);
if (result.error) {
return {
@@ -1000,7 +1000,7 @@ namespace ts {
};
}
var configFile = parseConfigFile(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName)));
var configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName)));
return {
options: configFile.options,
+2 -2
View File
@@ -25,11 +25,11 @@ class Board {
>allShipsSunk : Symbol(allShipsSunk, Decl(2dArrays.ts, 9, 18))
return this.ships.every(function (val) { return val.isSunk; });
>this.ships.every : Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
>this.ships.every : Symbol(Array.every, Decl(lib.d.ts, --, --))
>this.ships : Symbol(ships, Decl(2dArrays.ts, 7, 13))
>this : Symbol(Board, Decl(2dArrays.ts, 5, 1))
>ships : Symbol(ships, Decl(2dArrays.ts, 7, 13))
>every : Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
>every : Symbol(Array.every, Decl(lib.d.ts, --, --))
>val : Symbol(val, Decl(2dArrays.ts, 12, 42))
>val.isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
>val : Symbol(val, Decl(2dArrays.ts, 12, 42))
+10 -10
View File
@@ -75,26 +75,26 @@ function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
switch (node.kind) {
case 197 /* ForStatement */:
case 198 /* ForInStatement */:
case 196 /* WhileStatement */:
case 195 /* DoStatement */:
if (node.statement.kind !== 190 /* Block */) {
case 199 /* ForStatement */:
case 200 /* ForInStatement */:
case 198 /* WhileStatement */:
case 197 /* DoStatement */:
if (node.statement.kind !== 192 /* Block */) {
report(node, "A looping statement's contents should be wrapped in a block body.");
}
break;
case 194 /* IfStatement */:
case 196 /* IfStatement */:
var ifStatement = node;
if (ifStatement.thenStatement.kind !== 190 /* Block */) {
if (ifStatement.thenStatement.kind !== 192 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement &&
ifStatement.elseStatement.kind !== 190 /* Block */ &&
ifStatement.elseStatement.kind !== 194 /* IfStatement */) {
ifStatement.elseStatement.kind !== 192 /* Block */ &&
ifStatement.elseStatement.kind !== 196 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
case 179 /* BinaryExpression */:
case 181 /* BinaryExpression */:
var op = node.operatorToken.kind;
if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) {
report(node, "Use '===' and '!=='.");
@@ -3,7 +3,7 @@ var s: symbol;
>s : Symbol(s, Decl(ES5SymbolType1.ts, 0, 3))
s.toString();
>s.toString : Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
>s.toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
>s : Symbol(s, Decl(ES5SymbolType1.ts, 0, 3))
>toString : Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
@@ -11,11 +11,11 @@ module A {
export var beez: Array<B>;
>beez : Symbol(beez, Decl(ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.ts, 5, 14))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>B : Symbol(B, Decl(ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.ts, 0, 10))
export var beez2 = new Array<B>();
>beez2 : Symbol(beez2, Decl(ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.ts, 6, 14))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>B : Symbol(B, Decl(ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.ts, 0, 10))
}
@@ -14,12 +14,12 @@ function saySize(message: Message | Message[]) {
if (message instanceof Array) {
>message : Symbol(message, Decl(TypeGuardWithArrayUnion.ts, 4, 17))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
return message.length; // Should have type Message[] here
>message.length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
>message.length : Symbol(Array.length, Decl(lib.d.ts, --, --))
>message : Symbol(message, Decl(TypeGuardWithArrayUnion.ts, 4, 17))
>length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
>length : Symbol(Array.length, Decl(lib.d.ts, --, --))
}
}
@@ -35,7 +35,7 @@ var d: string;
var e: Object;
>e : Symbol(e, Decl(additionOperatorWithAnyAndEveryType.ts, 12, 3))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
// any as left operand, result is type Any except plusing string
var r1 = a + a;
@@ -19,7 +19,7 @@ var d: string;
var e: Object;
>e : Symbol(e, Decl(additionOperatorWithStringAndEveryType.ts, 6, 3))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var f: void;
>f : Symbol(f, Decl(additionOperatorWithStringAndEveryType.ts, 7, 3))
@@ -56,8 +56,8 @@ var r3 = foo3(a); // any
declare function foo5(x: Date): Date;
>foo5 : Symbol(foo5, Decl(anyAssignabilityInInheritance.ts, 19, 17), Decl(anyAssignabilityInInheritance.ts, 21, 37))
>x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 21, 22))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function foo5(x: any): any;
>foo5 : Symbol(foo5, Decl(anyAssignabilityInInheritance.ts, 19, 17), Decl(anyAssignabilityInInheritance.ts, 21, 37))
@@ -71,8 +71,8 @@ var r3 = foo3(a); // any
declare function foo6(x: RegExp): RegExp;
>foo6 : Symbol(foo6, Decl(anyAssignabilityInInheritance.ts, 23, 17), Decl(anyAssignabilityInInheritance.ts, 25, 41))
>x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 25, 22))
>RegExp : Symbol(RegExp, Decl(lib.d.ts, 825, 1), Decl(lib.d.ts, 876, 11))
>RegExp : Symbol(RegExp, Decl(lib.d.ts, 825, 1), Decl(lib.d.ts, 876, 11))
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function foo6(x: any): any;
>foo6 : Symbol(foo6, Decl(anyAssignabilityInInheritance.ts, 23, 17), Decl(anyAssignabilityInInheritance.ts, 25, 41))
@@ -277,8 +277,8 @@ var r3 = foo3(a); // any
declare function foo17(x: Object): Object;
>foo17 : Symbol(foo17, Decl(anyAssignabilityInInheritance.ts, 79, 17), Decl(anyAssignabilityInInheritance.ts, 81, 42))
>x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 81, 23))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function foo17(x: any): any;
>foo17 : Symbol(foo17, Decl(anyAssignabilityInInheritance.ts, 79, 17), Decl(anyAssignabilityInInheritance.ts, 81, 42))
@@ -44,7 +44,7 @@ var d: boolean = a;
var e: Date = a;
>e : Symbol(e, Decl(anyAssignableToEveryType.ts, 17, 3))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(anyAssignableToEveryType.ts, 0, 3))
var f: any = a;
@@ -57,7 +57,7 @@ var g: void = a;
var h: Object = a;
>h : Symbol(h, Decl(anyAssignableToEveryType.ts, 20, 3))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(anyAssignableToEveryType.ts, 0, 3))
var i: {} = a;
@@ -70,7 +70,7 @@ var j: () => {} = a;
var k: Function = a;
>k : Symbol(k, Decl(anyAssignableToEveryType.ts, 23, 3))
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(anyAssignableToEveryType.ts, 0, 3))
var l: (x: number) => string = a;
@@ -109,12 +109,12 @@ var o: <T>(x: T) => T = a;
var p: Number = a;
>p : Symbol(p, Decl(anyAssignableToEveryType.ts, 31, 3))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(anyAssignableToEveryType.ts, 0, 3))
var q: String = a;
>q : Symbol(q, Decl(anyAssignableToEveryType.ts, 32, 3))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11))
>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(anyAssignableToEveryType.ts, 0, 3))
function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) {
@@ -122,7 +122,7 @@ function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) {
>T : Symbol(T, Decl(anyAssignableToEveryType.ts, 34, 13))
>U : Symbol(U, Decl(anyAssignableToEveryType.ts, 34, 15))
>V : Symbol(V, Decl(anyAssignableToEveryType.ts, 34, 32))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(anyAssignableToEveryType.ts, 34, 49))
>T : Symbol(T, Decl(anyAssignableToEveryType.ts, 34, 13))
>y : Symbol(y, Decl(anyAssignableToEveryType.ts, 34, 54))
@@ -3,9 +3,9 @@ var paired: any[];
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
paired.reduce(function (a1, a2) {
>paired.reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>paired.reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a1 : Symbol(a1, Decl(anyInferenceAnonymousFunctions.ts, 2, 24))
>a2 : Symbol(a2, Decl(anyInferenceAnonymousFunctions.ts, 2, 27))
@@ -15,9 +15,9 @@ paired.reduce(function (a1, a2) {
} , []);
paired.reduce((b1, b2) => {
>paired.reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>paired.reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>b1 : Symbol(b1, Decl(anyInferenceAnonymousFunctions.ts, 8, 15))
>b2 : Symbol(b2, Decl(anyInferenceAnonymousFunctions.ts, 8, 18))
@@ -27,24 +27,24 @@ paired.reduce((b1, b2) => {
} , []);
paired.reduce((b3, b4) => b3.concat({}), []);
>paired.reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>paired.reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>b3 : Symbol(b3, Decl(anyInferenceAnonymousFunctions.ts, 13, 15))
>b4 : Symbol(b4, Decl(anyInferenceAnonymousFunctions.ts, 13, 18))
>b3 : Symbol(b3, Decl(anyInferenceAnonymousFunctions.ts, 13, 15))
paired.map((c1) => c1.count);
>paired.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12))
>c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12))
paired.map(function (c2) { return c2.count; });
>paired.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21))
>c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21))
@@ -11,9 +11,9 @@ class C {
for (var i = 0; i < arguments.length; i++) {
>i : Symbol(i, Decl(argsInScope.ts, 2, 15))
>i : Symbol(i, Decl(argsInScope.ts, 2, 15))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, 272, 25))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, 272, 25))
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>i : Symbol(i, Decl(argsInScope.ts, 2, 15))
// WScript.Echo("param: " + arguments[i]);
@@ -14,9 +14,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe
>arguments : Symbol(arguments)
result.push(arg + arg);
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>result.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
}
@@ -9,9 +9,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe
let blah = arguments[Symbol.iterator];
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
>arguments : Symbol(arguments)
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31))
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11))
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31))
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, --, --))
let result = [];
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
@@ -21,9 +21,9 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
result.push(arg + arg);
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>result.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
}
@@ -10,9 +10,9 @@ class A {
return {
selectedValue: arguments.length
>selectedValue : Symbol(selectedValue, Decl(argumentsUsedInObjectLiteralProperty.ts, 2, 16))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, 272, 25))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, 272, 25))
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
};
}
@@ -1,12 +1,12 @@
=== tests/cases/compiler/arrayAugment.ts ===
interface Array<T> {
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(arrayAugment.ts, 0, 0))
>T : Symbol(T, Decl(lib.d.ts, 1007, 16), Decl(arrayAugment.ts, 0, 16))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(arrayAugment.ts, 0, 0))
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(arrayAugment.ts, 0, 16))
split: (parts: number) => T[][];
>split : Symbol(split, Decl(arrayAugment.ts, 0, 20))
>parts : Symbol(parts, Decl(arrayAugment.ts, 1, 12))
>T : Symbol(T, Decl(lib.d.ts, 1007, 16), Decl(arrayAugment.ts, 0, 16))
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(arrayAugment.ts, 0, 16))
}
var x = [''];
@@ -3,21 +3,21 @@ var a: string[] = [];
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
a.concat("hello", 'world');
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
a.concat('Hello');
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>a.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcat2.ts, 0, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var b = new Array<string>();
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
b.concat('hello');
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>b.concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>b : Symbol(b, Decl(arrayConcat2.ts, 5, 3))
>concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
@@ -1,14 +1,14 @@
=== tests/cases/compiler/arrayConcatMap.ts ===
var x = [].concat([{ a: 1 }], [{ a: 2 }])
>x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3))
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>concat : Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20))
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32))
.map(b => b.a);
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15))
>b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15))
@@ -4,28 +4,28 @@ var x: string[];
x = new Array(1);
>x : Symbol(x, Decl(arrayConstructors1.ts, 0, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
x = new Array('hi', 'bye');
>x : Symbol(x, Decl(arrayConstructors1.ts, 0, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
x = new Array<string>('hi', 'bye');
>x : Symbol(x, Decl(arrayConstructors1.ts, 0, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var y: number[];
>y : Symbol(y, Decl(arrayConstructors1.ts, 5, 3))
y = new Array(1);
>y : Symbol(y, Decl(arrayConstructors1.ts, 5, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
y = new Array(1,2);
>y : Symbol(y, Decl(arrayConstructors1.ts, 5, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
y = new Array<number>(1, 2);
>y : Symbol(y, Decl(arrayConstructors1.ts, 5, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
@@ -6,7 +6,7 @@ var x = [];
var x = new Array(1);
>x : Symbol(x, Decl(arrayLiteral.ts, 2, 3), Decl(arrayLiteral.ts, 3, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var y = [1];
>y : Symbol(y, Decl(arrayLiteral.ts, 5, 3), Decl(arrayLiteral.ts, 6, 3), Decl(arrayLiteral.ts, 7, 3))
@@ -16,14 +16,14 @@ var y = [1, 2];
var y = new Array<number>();
>y : Symbol(y, Decl(arrayLiteral.ts, 5, 3), Decl(arrayLiteral.ts, 6, 3), Decl(arrayLiteral.ts, 7, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var x2: number[] = [];
>x2 : Symbol(x2, Decl(arrayLiteral.ts, 9, 3), Decl(arrayLiteral.ts, 10, 3))
var x2: number[] = new Array(1);
>x2 : Symbol(x2, Decl(arrayLiteral.ts, 9, 3), Decl(arrayLiteral.ts, 10, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var y2: number[] = [1];
>y2 : Symbol(y2, Decl(arrayLiteral.ts, 12, 3), Decl(arrayLiteral.ts, 13, 3), Decl(arrayLiteral.ts, 14, 3))
@@ -33,5 +33,5 @@ var y2: number[] = [1, 2];
var y2: number[] = new Array<number>();
>y2 : Symbol(y2, Decl(arrayLiteral.ts, 12, 3), Decl(arrayLiteral.ts, 13, 3), Decl(arrayLiteral.ts, 14, 3))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
@@ -35,14 +35,14 @@ var cs = [a, b, c]; // { x: number; y?: number };[]
var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[]
>ds : Symbol(ds, Decl(arrayLiteralWithMultipleBestCommonTypes.ts, 10, 3))
>x : Symbol(x, Decl(arrayLiteralWithMultipleBestCommonTypes.ts, 10, 11))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(arrayLiteralWithMultipleBestCommonTypes.ts, 10, 29))
var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[]
>es : Symbol(es, Decl(arrayLiteralWithMultipleBestCommonTypes.ts, 11, 3))
>x : Symbol(x, Decl(arrayLiteralWithMultipleBestCommonTypes.ts, 11, 11))
>x : Symbol(x, Decl(arrayLiteralWithMultipleBestCommonTypes.ts, 11, 29))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var fs = [(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => 2]; // (a: { x: number; y?: number }) => number[]
>fs : Symbol(fs, Decl(arrayLiteralWithMultipleBestCommonTypes.ts, 12, 3))
@@ -80,14 +80,14 @@ var temp4 = [];
interface myArray extends Array<Number> { }
>myArray : Symbol(myArray, Decl(arrayLiterals2ES5.ts, 42, 15))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
interface myArray2 extends Array<Number|String> { }
>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES5.ts, 44, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[]
>d0 : Symbol(d0, Decl(arrayLiterals2ES5.ts, 46, 3))
@@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]];
interface myArray extends Array<Number> { }
>myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
interface myArray2 extends Array<Number|String> { }
>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
>d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3))
@@ -39,29 +39,29 @@ class parser {
>this.options : Symbol(options, Decl(arrayconcat.ts, 10, 14))
>this : Symbol(parser, Decl(arrayconcat.ts, 8, 1))
>options : Symbol(options, Decl(arrayconcat.ts, 10, 14))
>this.options.sort : Symbol(Array.sort, Decl(lib.d.ts, 1054, 45))
>this.options.sort : Symbol(Array.sort, Decl(lib.d.ts, --, --))
>this.options : Symbol(options, Decl(arrayconcat.ts, 10, 14))
>this : Symbol(parser, Decl(arrayconcat.ts, 8, 1))
>options : Symbol(options, Decl(arrayconcat.ts, 10, 14))
>sort : Symbol(Array.sort, Decl(lib.d.ts, 1054, 45))
>sort : Symbol(Array.sort, Decl(lib.d.ts, --, --))
>a : Symbol(a, Decl(arrayconcat.ts, 14, 44))
>b : Symbol(b, Decl(arrayconcat.ts, 14, 46))
var aName = a.name.toLowerCase();
>aName : Symbol(aName, Decl(arrayconcat.ts, 15, 15))
>a.name.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, 399, 51))
>a.name.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>a.name : Symbol(IOptions.name, Decl(arrayconcat.ts, 0, 20))
>a : Symbol(a, Decl(arrayconcat.ts, 14, 44))
>name : Symbol(IOptions.name, Decl(arrayconcat.ts, 0, 20))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, 399, 51))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
var bName = b.name.toLowerCase();
>bName : Symbol(bName, Decl(arrayconcat.ts, 16, 15))
>b.name.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, 399, 51))
>b.name.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>b.name : Symbol(IOptions.name, Decl(arrayconcat.ts, 0, 20))
>b : Symbol(b, Decl(arrayconcat.ts, 14, 46))
>name : Symbol(IOptions.name, Decl(arrayconcat.ts, 0, 20))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, 399, 51))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
if (aName > bName) {
>aName : Symbol(aName, Decl(arrayconcat.ts, 15, 15))
@@ -3,16 +3,16 @@
var a = (p: string) => p.length;
>a : Symbol(a, Decl(arrowFunctionExpressions.ts, 1, 3), Decl(arrowFunctionExpressions.ts, 2, 3))
>p : Symbol(p, Decl(arrowFunctionExpressions.ts, 1, 9))
>p.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>p.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>p : Symbol(p, Decl(arrowFunctionExpressions.ts, 1, 9))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
var a = (p: string) => { return p.length; }
>a : Symbol(a, Decl(arrowFunctionExpressions.ts, 1, 3), Decl(arrowFunctionExpressions.ts, 2, 3))
>p : Symbol(p, Decl(arrowFunctionExpressions.ts, 2, 9))
>p.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>p.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>p : Symbol(p, Decl(arrowFunctionExpressions.ts, 2, 9))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
// Identifier => Block is equivalent to(Identifier) => Block
var b = j => { return 0; }
@@ -147,9 +147,9 @@ function someFn() {
>n : Symbol(n, Decl(arrowFunctionExpressions.ts, 45, 15))
arr(3)(4).toExponential();
>arr(3)(4).toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, 469, 45))
>arr(3)(4).toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
>arr : Symbol(arr, Decl(arrowFunctionExpressions.ts, 45, 7))
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, 469, 45))
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
}
// Arrow function used in function
@@ -162,9 +162,9 @@ function someOtherFn() {
>n : Symbol(n, Decl(arrowFunctionExpressions.ts, 51, 15))
arr(4).charAt(0);
>arr(4).charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
>arr(4).charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --))
>arr : Symbol(arr, Decl(arrowFunctionExpressions.ts, 51, 7))
>charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
>charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --))
}
// Arrow function used in nested function in function
@@ -222,9 +222,9 @@ function someOuterFn() {
>innerFn : Symbol(innerFn, Decl(arrowFunctionExpressions.ts, 77, 30))
return () => n.length;
>n.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>n.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>n : Symbol(n, Decl(arrowFunctionExpressions.ts, 77, 15))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
}
return innerFn;
>innerFn : Symbol(innerFn, Decl(arrowFunctionExpressions.ts, 77, 30))
@@ -237,9 +237,9 @@ var h = someOuterFn()('')()();
>someOuterFn : Symbol(someOuterFn, Decl(arrowFunctionExpressions.ts, 72, 14))
h.toExponential();
>h.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, 469, 45))
>h.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
>h : Symbol(h, Decl(arrowFunctionExpressions.ts, 85, 3))
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, 469, 45))
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
// Arrow function used in try/catch/finally in function
function tryCatchFn() {
@@ -1,13 +1,13 @@
=== tests/cases/compiler/arrowFunctionWithObjectLiteralBody5.ts ===
var a = () => <Error>{ name: "foo", message: "bar" };
>a : Symbol(a, Decl(arrowFunctionWithObjectLiteralBody5.ts, 0, 3))
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>name : Symbol(name, Decl(arrowFunctionWithObjectLiteralBody5.ts, 0, 22))
>message : Symbol(message, Decl(arrowFunctionWithObjectLiteralBody5.ts, 0, 35))
var b = () => (<Error>{ name: "foo", message: "bar" });
>b : Symbol(b, Decl(arrowFunctionWithObjectLiteralBody5.ts, 2, 3))
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>name : Symbol(name, Decl(arrowFunctionWithObjectLiteralBody5.ts, 2, 23))
>message : Symbol(message, Decl(arrowFunctionWithObjectLiteralBody5.ts, 2, 36))
@@ -18,7 +18,7 @@ var c = () => ({ name: "foo", message: "bar" });
var d = () => ((<Error>({ name: "foo", message: "bar" })));
>d : Symbol(d, Decl(arrowFunctionWithObjectLiteralBody5.ts, 6, 3))
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>name : Symbol(name, Decl(arrowFunctionWithObjectLiteralBody5.ts, 6, 25))
>message : Symbol(message, Decl(arrowFunctionWithObjectLiteralBody5.ts, 6, 38))
@@ -1,13 +1,13 @@
=== tests/cases/compiler/arrowFunctionWithObjectLiteralBody6.ts ===
var a = () => <Error>{ name: "foo", message: "bar" };
>a : Symbol(a, Decl(arrowFunctionWithObjectLiteralBody6.ts, 0, 3))
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>name : Symbol(name, Decl(arrowFunctionWithObjectLiteralBody6.ts, 0, 22))
>message : Symbol(message, Decl(arrowFunctionWithObjectLiteralBody6.ts, 0, 35))
var b = () => (<Error>{ name: "foo", message: "bar" });
>b : Symbol(b, Decl(arrowFunctionWithObjectLiteralBody6.ts, 2, 3))
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>name : Symbol(name, Decl(arrowFunctionWithObjectLiteralBody6.ts, 2, 23))
>message : Symbol(message, Decl(arrowFunctionWithObjectLiteralBody6.ts, 2, 36))
@@ -18,7 +18,7 @@ var c = () => ({ name: "foo", message: "bar" });
var d = () => ((<Error>({ name: "foo", message: "bar" })));
>d : Symbol(d, Decl(arrowFunctionWithObjectLiteralBody6.ts, 6, 3))
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>name : Symbol(name, Decl(arrowFunctionWithObjectLiteralBody6.ts, 6, 25))
>message : Symbol(message, Decl(arrowFunctionWithObjectLiteralBody6.ts, 6, 38))
@@ -8,12 +8,12 @@ var x = undefined as number;
var y = (null as string).length;
>y : Symbol(y, Decl(asOperator1.ts, 2, 3))
>(null as string).length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>(null as string).length : Symbol(String.length, Decl(lib.d.ts, --, --))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
var z = Date as any as string;
>z : Symbol(z, Decl(asOperator1.ts, 3, 3))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string'
var j = 32 as number|string;
@@ -0,0 +1,24 @@
tests/cases/compiler/asiAbstract.ts(1,1): error TS2304: Cannot find name 'abstract'.
tests/cases/compiler/asiAbstract.ts(3,3): error TS1244: Abstract methods can only appear within an abstract class.
==== tests/cases/compiler/asiAbstract.ts (2 errors) ====
abstract
~~~~~~~~
!!! error TS2304: Cannot find name 'abstract'.
class NonAbstractClass {
abstract s();
~~~~~~~~
!!! error TS1244: Abstract methods can only appear within an abstract class.
}
class C2 {
abstract
nonAbstractFunction() {
}
}
class C3 {
abstract
}
+36
View File
@@ -0,0 +1,36 @@
//// [asiAbstract.ts]
abstract
class NonAbstractClass {
abstract s();
}
class C2 {
abstract
nonAbstractFunction() {
}
}
class C3 {
abstract
}
//// [asiAbstract.js]
abstract;
var NonAbstractClass = (function () {
function NonAbstractClass() {
}
return NonAbstractClass;
})();
var C2 = (function () {
function C2() {
}
C2.prototype.nonAbstractFunction = function () {
};
return C2;
})();
var C3 = (function () {
function C3() {
}
return C3;
})();
@@ -0,0 +1,52 @@
tests/cases/compiler/asiPublicPrivateProtected.ts(1,1): error TS2304: Cannot find name 'public'.
tests/cases/compiler/asiPublicPrivateProtected.ts(12,1): error TS2304: Cannot find name 'private'.
tests/cases/compiler/asiPublicPrivateProtected.ts(23,1): error TS2304: Cannot find name 'protected'.
==== tests/cases/compiler/asiPublicPrivateProtected.ts (3 errors) ====
public
~~~~~~
!!! error TS2304: Cannot find name 'public'.
class NonPublicClass {
public s() {
}
}
class NonPublicClass2 {
public
private nonPublicFunction() {
}
}
private
~~~~~~~
!!! error TS2304: Cannot find name 'private'.
class NonPrivateClass {
private s() {
}
}
class NonPrivateClass2 {
private
public nonPrivateFunction() {
}
}
protected
~~~~~~~~~
!!! error TS2304: Cannot find name 'protected'.
class NonProtectedClass {
protected s() {
}
}
class NonProtectedClass2 {
protected
public nonProtectedFunction() {
}
}
class ClassWithThreeMembers {
public
private
protected
}
@@ -0,0 +1,93 @@
//// [asiPublicPrivateProtected.ts]
public
class NonPublicClass {
public s() {
}
}
class NonPublicClass2 {
public
private nonPublicFunction() {
}
}
private
class NonPrivateClass {
private s() {
}
}
class NonPrivateClass2 {
private
public nonPrivateFunction() {
}
}
protected
class NonProtectedClass {
protected s() {
}
}
class NonProtectedClass2 {
protected
public nonProtectedFunction() {
}
}
class ClassWithThreeMembers {
public
private
protected
}
//// [asiPublicPrivateProtected.js]
public;
var NonPublicClass = (function () {
function NonPublicClass() {
}
NonPublicClass.prototype.s = function () {
};
return NonPublicClass;
})();
var NonPublicClass2 = (function () {
function NonPublicClass2() {
}
NonPublicClass2.prototype.nonPublicFunction = function () {
};
return NonPublicClass2;
})();
private;
var NonPrivateClass = (function () {
function NonPrivateClass() {
}
NonPrivateClass.prototype.s = function () {
};
return NonPrivateClass;
})();
var NonPrivateClass2 = (function () {
function NonPrivateClass2() {
}
NonPrivateClass2.prototype.nonPrivateFunction = function () {
};
return NonPrivateClass2;
})();
protected;
var NonProtectedClass = (function () {
function NonProtectedClass() {
}
NonProtectedClass.prototype.s = function () {
};
return NonProtectedClass;
})();
var NonProtectedClass2 = (function () {
function NonProtectedClass2() {
}
NonProtectedClass2.prototype.nonProtectedFunction = function () {
};
return NonProtectedClass2;
})();
var ClassWithThreeMembers = (function () {
function ClassWithThreeMembers() {
}
return ClassWithThreeMembers;
})();
@@ -106,23 +106,23 @@ var a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base;
var a12: (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
>a12 : Symbol(a12, Decl(assignmentCompatWithCallSignatures3.ts, 18, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignatures3.ts, 18, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithCallSignatures3.ts, 18, 25))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithCallSignatures3.ts, 3, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures3.ts, 2, 27))
var a13: (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
>a13 : Symbol(a13, Decl(assignmentCompatWithCallSignatures3.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithCallSignatures3.ts, 19, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithCallSignatures3.ts, 19, 25))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures3.ts, 2, 27))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures3.ts, 2, 27))
var a14: (x: { a: string; b: number }) => Object;
@@ -130,7 +130,7 @@ var a14: (x: { a: string; b: number }) => Object;
>x : Symbol(x, Decl(assignmentCompatWithCallSignatures3.ts, 20, 10))
>a : Symbol(a, Decl(assignmentCompatWithCallSignatures3.ts, 20, 14))
>b : Symbol(b, Decl(assignmentCompatWithCallSignatures3.ts, 20, 25))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var a15: {
>a15 : Symbol(a15, Decl(assignmentCompatWithCallSignatures3.ts, 21, 3))
@@ -189,8 +189,8 @@ var a18: {
(a: Date): Date;
>a : Symbol(a, Decl(assignmentCompatWithCallSignatures3.ts, 40, 9))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}): any[];
}
@@ -407,14 +407,14 @@ b11 = a11; // ok
var b12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>;
>b12 : Symbol(b12, Decl(assignmentCompatWithCallSignatures3.ts, 77, 3))
>T : Symbol(T, Decl(assignmentCompatWithCallSignatures3.ts, 77, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures3.ts, 0, 0))
>x : Symbol(x, Decl(assignmentCompatWithCallSignatures3.ts, 77, 33))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithCallSignatures3.ts, 77, 48))
>T : Symbol(T, Decl(assignmentCompatWithCallSignatures3.ts, 77, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures3.ts, 2, 27))
a12 = b12; // ok
@@ -428,10 +428,10 @@ b12 = a12; // ok
var b13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T;
>b13 : Symbol(b13, Decl(assignmentCompatWithCallSignatures3.ts, 80, 3))
>T : Symbol(T, Decl(assignmentCompatWithCallSignatures3.ts, 80, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures3.ts, 2, 27))
>x : Symbol(x, Decl(assignmentCompatWithCallSignatures3.ts, 80, 36))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithCallSignatures3.ts, 80, 51))
>T : Symbol(T, Decl(assignmentCompatWithCallSignatures3.ts, 80, 10))
@@ -106,23 +106,23 @@ var a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base;
var a12: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
>a12 : Symbol(a12, Decl(assignmentCompatWithConstructSignatures3.ts, 18, 3))
>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures3.ts, 18, 14))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures3.ts, 18, 29))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithConstructSignatures3.ts, 3, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures3.ts, 2, 27))
var a13: new (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
>a13 : Symbol(a13, Decl(assignmentCompatWithConstructSignatures3.ts, 19, 3))
>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures3.ts, 19, 14))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures3.ts, 19, 29))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures3.ts, 2, 27))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures3.ts, 2, 27))
var a14: new (x: { a: string; b: number }) => Object;
@@ -130,7 +130,7 @@ var a14: new (x: { a: string; b: number }) => Object;
>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures3.ts, 20, 14))
>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures3.ts, 20, 18))
>b : Symbol(b, Decl(assignmentCompatWithConstructSignatures3.ts, 20, 29))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var a15: {
>a15 : Symbol(a15, Decl(assignmentCompatWithConstructSignatures3.ts, 21, 3))
@@ -189,8 +189,8 @@ var a18: {
new (a: Date): Date;
>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures3.ts, 40, 13))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}): any[];
}
@@ -407,14 +407,14 @@ b11 = a11; // ok
var b12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>;
>b12 : Symbol(b12, Decl(assignmentCompatWithConstructSignatures3.ts, 77, 3))
>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures3.ts, 77, 14))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures3.ts, 0, 0))
>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures3.ts, 77, 37))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures3.ts, 77, 52))
>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures3.ts, 77, 14))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures3.ts, 2, 27))
a12 = b12; // ok
@@ -428,10 +428,10 @@ b12 = a12; // ok
var b13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T;
>b13 : Symbol(b13, Decl(assignmentCompatWithConstructSignatures3.ts, 80, 3))
>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures3.ts, 80, 14))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures3.ts, 2, 27))
>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures3.ts, 80, 40))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures3.ts, 0, 0))
>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures3.ts, 80, 55))
>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures3.ts, 80, 14))
@@ -2,6 +2,6 @@
var foo = async (): Promise<void> => {
>foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
};
@@ -10,9 +10,9 @@ class C {
var fn = async () => await other.apply(this, arguments);
>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9))
>other.apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20))
>other.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13))
>apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20))
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0))
>arguments : Symbol(arguments)
}
@@ -2,16 +2,16 @@
type MyPromise<T> = Promise<T>;
>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11))
>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15))
declare var MyPromise: typeof Promise;
>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare var p: Promise<number>;
>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare var mp: MyPromise<number>;
>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11))
@@ -22,7 +22,7 @@ async function f0() { }
async function f1(): Promise<void> { }
>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async function f3(): MyPromise<void> { }
>f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38))
@@ -33,7 +33,7 @@ let f4 = async function() { }
let f5 = async function(): Promise<void> { }
>f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
let f6 = async function(): MyPromise<void> { }
>f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3))
@@ -44,7 +44,7 @@ let f7 = async () => { };
let f8 = async (): Promise<void> => { };
>f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
let f9 = async (): MyPromise<void> => { };
>f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3))
@@ -60,7 +60,7 @@ let f11 = async () => mp;
let f12 = async (): Promise<number> => mp;
>f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11))
let f13 = async (): MyPromise<number> => p;
@@ -76,7 +76,7 @@ let o = {
async m2(): Promise<void> { },
>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async m3(): MyPromise<void> { }
>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31))
@@ -92,7 +92,7 @@ class C {
async m2(): Promise<void> { }
>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async m3(): MyPromise<void> { }
>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30))
@@ -103,7 +103,7 @@ class C {
static async m5(): Promise<void> { }
>m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
static async m6(): MyPromise<void> { }
>m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37))
@@ -1,5 +1,5 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts ===
async function await(): Promise<void> {
>await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}
@@ -1,7 +1,7 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts ===
async function foo(): Promise<void> {
>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
return;
}
@@ -0,0 +1,56 @@
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,16): error TS1055: Type '{}' is not a valid async function return type.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(7,16): error TS1055: Type 'any' is not a valid async function return type.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,16): error TS1055: Type 'number' is not a valid async function return type.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,16): error TS1055: Type 'PromiseLike<void>' is not a valid async function return type.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,16): error TS1055: Type 'typeof Thenable' is not a valid async function return type.
Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
Types of property 'then' are incompatible.
Type '() => void' is not assignable to type '{ <TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>; }'.
Type 'void' is not assignable to type 'PromiseLike<any>'.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member.
==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts (7 errors) ====
declare class Thenable { then(): void; }
declare let a: any;
declare let obj: { then: string; };
declare let thenable: Thenable;
async function fn1() { } // valid: Promise<void>
async function fn2(): { } { } // error
~~~
!!! error TS1055: Type '{}' is not a valid async function return type.
async function fn3(): any { } // error
~~~
!!! error TS1055: Type 'any' is not a valid async function return type.
async function fn4(): number { } // error
~~~
!!! error TS1055: Type 'number' is not a valid async function return type.
async function fn5(): PromiseLike<void> { } // error
~~~
!!! error TS1055: Type 'PromiseLike<void>' is not a valid async function return type.
async function fn6(): Thenable { } // error
~~~
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type.
!!! error TS1055: Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
!!! error TS1055: Types of property 'then' are incompatible.
!!! error TS1055: Type '() => void' is not assignable to type '{ <TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>; }'.
!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike<any>'.
async function fn7() { return; } // valid: Promise<void>
async function fn8() { return 1; } // valid: Promise<number>
async function fn9() { return null; } // valid: Promise<any>
async function fn10() { return undefined; } // valid: Promise<any>
async function fn11() { return a; } // valid: Promise<any>
async function fn12() { return obj; } // valid: Promise<{ then: string; }>
async function fn13() { return thenable; } // error
~~~~
!!! error TS1059: Return expression in async function does not have a valid callable 'then' member.
async function fn14() { await 1; } // valid: Promise<void>
async function fn15() { await null; } // valid: Promise<void>
async function fn16() { await undefined; } // valid: Promise<void>
async function fn17() { await a; } // valid: Promise<void>
async function fn18() { await obj; } // valid: Promise<void>
async function fn19() { await thenable; } // error
~~~~~~~~~~~~~~
!!! error TS1058: Operand for 'await' does not have a valid callable 'then' member.
@@ -0,0 +1,84 @@
//// [asyncFunctionDeclaration15_es6.ts]
declare class Thenable { then(): void; }
declare let a: any;
declare let obj: { then: string; };
declare let thenable: Thenable;
async function fn1() { } // valid: Promise<void>
async function fn2(): { } { } // error
async function fn3(): any { } // error
async function fn4(): number { } // error
async function fn5(): PromiseLike<void> { } // error
async function fn6(): Thenable { } // error
async function fn7() { return; } // valid: Promise<void>
async function fn8() { return 1; } // valid: Promise<number>
async function fn9() { return null; } // valid: Promise<any>
async function fn10() { return undefined; } // valid: Promise<any>
async function fn11() { return a; } // valid: Promise<any>
async function fn12() { return obj; } // valid: Promise<{ then: string; }>
async function fn13() { return thenable; } // error
async function fn14() { await 1; } // valid: Promise<void>
async function fn15() { await null; } // valid: Promise<void>
async function fn16() { await undefined; } // valid: Promise<void>
async function fn17() { await a; } // valid: Promise<void>
async function fn18() { await obj; } // valid: Promise<void>
async function fn19() { await thenable; } // error
//// [asyncFunctionDeclaration15_es6.js]
function fn1() {
return __awaiter(this, void 0, Promise, function* () { });
} // valid: Promise<void>
function fn2() {
return __awaiter(this, void 0, Promise, function* () { });
} // error
function fn3() {
return __awaiter(this, void 0, Promise, function* () { });
} // error
function fn4() {
return __awaiter(this, void 0, Promise, function* () { });
} // error
function fn5() {
return __awaiter(this, void 0, PromiseLike, function* () { });
} // error
function fn6() {
return __awaiter(this, void 0, Thenable, function* () { });
} // error
function fn7() {
return __awaiter(this, void 0, Promise, function* () { return; });
} // valid: Promise<void>
function fn8() {
return __awaiter(this, void 0, Promise, function* () { return 1; });
} // valid: Promise<number>
function fn9() {
return __awaiter(this, void 0, Promise, function* () { return null; });
} // valid: Promise<any>
function fn10() {
return __awaiter(this, void 0, Promise, function* () { return undefined; });
} // valid: Promise<any>
function fn11() {
return __awaiter(this, void 0, Promise, function* () { return a; });
} // valid: Promise<any>
function fn12() {
return __awaiter(this, void 0, Promise, function* () { return obj; });
} // valid: Promise<{ then: string; }>
function fn13() {
return __awaiter(this, void 0, Promise, function* () { return thenable; });
} // error
function fn14() {
return __awaiter(this, void 0, Promise, function* () { yield 1; });
} // valid: Promise<void>
function fn15() {
return __awaiter(this, void 0, Promise, function* () { yield null; });
} // valid: Promise<void>
function fn16() {
return __awaiter(this, void 0, Promise, function* () { yield undefined; });
} // valid: Promise<void>
function fn17() {
return __awaiter(this, void 0, Promise, function* () { yield a; });
} // valid: Promise<void>
function fn18() {
return __awaiter(this, void 0, Promise, function* () { yield obj; });
} // valid: Promise<void>
function fn19() {
return __awaiter(this, void 0, Promise, function* () { yield thenable; });
} // error
@@ -1,5 +1,5 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts ===
async function foo(): Promise<void> {
>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}
@@ -1,7 +1,7 @@
=== tests/cases/compiler/augmentArray.ts ===
interface Array<T> {
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(augmentArray.ts, 0, 0))
>T : Symbol(T, Decl(lib.d.ts, 1007, 16), Decl(augmentArray.ts, 0, 16))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(augmentArray.ts, 0, 0))
>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(augmentArray.ts, 0, 16))
(): any[];
}
@@ -8,7 +8,7 @@ interface Bar { b }
>b : Symbol(b, Decl(augmentedTypeBracketAccessIndexSignature.ts, 1, 15))
interface Object {
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11), Decl(augmentedTypeBracketAccessIndexSignature.ts, 1, 19))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(augmentedTypeBracketAccessIndexSignature.ts, 1, 19))
[n: number]: Foo;
>n : Symbol(n, Decl(augmentedTypeBracketAccessIndexSignature.ts, 4, 5))
@@ -16,7 +16,7 @@ interface Object {
}
interface Function {
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(augmentedTypeBracketAccessIndexSignature.ts, 5, 1))
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(augmentedTypeBracketAccessIndexSignature.ts, 5, 1))
[n: number]: Bar;
>n : Symbol(n, Decl(augmentedTypeBracketAccessIndexSignature.ts, 8, 5))
@@ -1,12 +1,12 @@
=== tests/cases/compiler/augmentedTypeBracketNamedPropertyAccess.ts ===
interface Object {
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11), Decl(augmentedTypeBracketNamedPropertyAccess.ts, 0, 0))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(augmentedTypeBracketNamedPropertyAccess.ts, 0, 0))
data: number;
>data : Symbol(data, Decl(augmentedTypeBracketNamedPropertyAccess.ts, 0, 18))
}
interface Function {
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(augmentedTypeBracketNamedPropertyAccess.ts, 2, 1))
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(augmentedTypeBracketNamedPropertyAccess.ts, 2, 1))
functionData: string;
>functionData : Symbol(functionData, Decl(augmentedTypeBracketNamedPropertyAccess.ts, 3, 20))
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = await p || a;
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = await p && a;
@@ -4,11 +4,11 @@ declare var a: number;
declare var p: Promise<number>;
>p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = await p + a;
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = await p, a;
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var o: { a: boolean; };
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = fn(a, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = fn(await p, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = fn(a, await p, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = (await pfn)(a, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = o.fn(a, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = o.fn(await p, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = o.fn(a, await p, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
"before";
var b = (await po).fn(a, a, a);
@@ -4,20 +4,20 @@ declare let a: number | string;
declare let b: PromiseLike<number> | PromiseLike<string>;
>b : Symbol(b, Decl(awaitUnion_es6.ts, 1, 11))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, --, --))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, --, --))
declare let c: PromiseLike<number | string>;
>c : Symbol(c, Decl(awaitUnion_es6.ts, 2, 11))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, --, --))
declare let d: number | PromiseLike<string>;
>d : Symbol(d, Decl(awaitUnion_es6.ts, 3, 11))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, --, --))
declare let e: number | PromiseLike<number | string>;
>e : Symbol(e, Decl(awaitUnion_es6.ts, 4, 11))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, 1187, 163))
>PromiseLike : Symbol(PromiseLike, Decl(lib.d.ts, --, --))
async function f() {
>f : Symbol(f, Decl(awaitUnion_es6.ts, 4, 53))
@@ -58,20 +58,20 @@ var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => vo
>r6 : Symbol(r6, Decl(bestCommonTypeOfConditionalExpressions.ts, 17, 3))
>x : Symbol(x, Decl(bestCommonTypeOfConditionalExpressions.ts, 17, 17))
>x : Symbol(x, Decl(bestCommonTypeOfConditionalExpressions.ts, 17, 38))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { };
>r7 : Symbol(r7, Decl(bestCommonTypeOfConditionalExpressions.ts, 18, 3))
>x : Symbol(x, Decl(bestCommonTypeOfConditionalExpressions.ts, 18, 9))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(bestCommonTypeOfConditionalExpressions.ts, 18, 38))
>x : Symbol(x, Decl(bestCommonTypeOfConditionalExpressions.ts, 18, 59))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void
>r8 : Symbol(r8, Decl(bestCommonTypeOfConditionalExpressions.ts, 19, 3))
>x : Symbol(x, Decl(bestCommonTypeOfConditionalExpressions.ts, 19, 17))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(bestCommonTypeOfConditionalExpressions.ts, 19, 38))
var r10: Base = true ? derived : derived2; // no error since we use the contextual type in BCT
@@ -93,7 +93,7 @@ function foo5<T, U>(t: T, u: U): Object {
>T : Symbol(T, Decl(bestCommonTypeOfConditionalExpressions.ts, 23, 14))
>u : Symbol(u, Decl(bestCommonTypeOfConditionalExpressions.ts, 23, 25))
>U : Symbol(U, Decl(bestCommonTypeOfConditionalExpressions.ts, 23, 16))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
return true ? t : u; // BCT is Object
>t : Symbol(t, Decl(bestCommonTypeOfConditionalExpressions.ts, 23, 20))
@@ -21,12 +21,12 @@ module Test {
>name : Symbol(name, Decl(binopAssignmentShouldHaveType.ts, 8, 6))
if ((name= this.getName()).length > 0) {
>(name= this.getName()).length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>(name= this.getName()).length : Symbol(String.length, Decl(lib.d.ts, --, --))
>name : Symbol(name, Decl(binopAssignmentShouldHaveType.ts, 8, 6))
>this.getName : Symbol(getName, Decl(binopAssignmentShouldHaveType.ts, 3, 19))
>this : Symbol(Bug, Decl(binopAssignmentShouldHaveType.ts, 2, 13))
>getName : Symbol(getName, Decl(binopAssignmentShouldHaveType.ts, 3, 19))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
console.log(name);
>console : Symbol(console, Decl(binopAssignmentShouldHaveType.ts, 0, 11))
@@ -88,9 +88,9 @@ var ResultIsNumber11 = ~(STRING + STRING);
var ResultIsNumber12 = ~STRING.charAt(0);
>ResultIsNumber12 : Symbol(ResultIsNumber12, Decl(bitwiseNotOperatorWithStringType.ts, 32, 3))
>STRING.charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
>STRING.charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --))
>STRING : Symbol(STRING, Decl(bitwiseNotOperatorWithStringType.ts, 1, 3))
>charAt : Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
>charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --))
// multiple ~ operators
var ResultIsNumber13 = ~~STRING;
@@ -0,0 +1,118 @@
tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(2,13): error TS2448: Block-scoped variable 'x' used before its declaration.
tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(58,20): error TS2448: Block-scoped variable 'x' used before its declaration.
tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(65,20): error TS2448: Block-scoped variable 'x' used before its declaration.
tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: Block-scoped variable 'x' used before its declaration.
==== tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts (4 errors) ====
function foo0() {
let a = x;
~
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
let x;
}
function foo1() {
let a = () => x;
let x;
}
function foo2() {
let a = function () { return x; }
let x;
}
function foo3() {
class X {
m() { return x;}
}
let x;
}
function foo4() {
let y = class {
m() { return x; }
};
let x;
}
function foo5() {
let x = () => y;
let y = () => x;
}
function foo6() {
function f() {
return x;
}
let x;
}
function foo7() {
class A {
a = x;
}
let x;
}
function foo8() {
let y = class {
a = x;
}
let x;
}
function foo9() {
let y = class {
static a = x;
~
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
}
let x;
}
function foo10() {
class A {
static a = x;
~
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
}
let x;
}
function foo11() {
function f () {
let y = class {
static a = x;
}
}
let x;
}
function foo12() {
function f () {
let y = class {
a;
constructor() {
this.a = x;
}
}
}
let x;
}
function foo13() {
let a = {
get a() { return x }
}
let x
}
function foo14() {
let a = {
a: x
~
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
}
let x
}
@@ -0,0 +1,216 @@
//// [blockScopedVariablesUseBeforeDef.ts]
function foo0() {
let a = x;
let x;
}
function foo1() {
let a = () => x;
let x;
}
function foo2() {
let a = function () { return x; }
let x;
}
function foo3() {
class X {
m() { return x;}
}
let x;
}
function foo4() {
let y = class {
m() { return x; }
};
let x;
}
function foo5() {
let x = () => y;
let y = () => x;
}
function foo6() {
function f() {
return x;
}
let x;
}
function foo7() {
class A {
a = x;
}
let x;
}
function foo8() {
let y = class {
a = x;
}
let x;
}
function foo9() {
let y = class {
static a = x;
}
let x;
}
function foo10() {
class A {
static a = x;
}
let x;
}
function foo11() {
function f () {
let y = class {
static a = x;
}
}
let x;
}
function foo12() {
function f () {
let y = class {
a;
constructor() {
this.a = x;
}
}
}
let x;
}
function foo13() {
let a = {
get a() { return x }
}
let x
}
function foo14() {
let a = {
a: x
}
let x
}
//// [blockScopedVariablesUseBeforeDef.js]
function foo0() {
var a = x;
var x;
}
function foo1() {
var a = function () { return x; };
var x;
}
function foo2() {
var a = function () { return x; };
var x;
}
function foo3() {
var X = (function () {
function X() {
}
X.prototype.m = function () { return x; };
return X;
})();
var x;
}
function foo4() {
var y = (function () {
function class_1() {
}
class_1.prototype.m = function () { return x; };
return class_1;
})();
var x;
}
function foo5() {
var x = function () { return y; };
var y = function () { return x; };
}
function foo6() {
function f() {
return x;
}
var x;
}
function foo7() {
var A = (function () {
function A() {
this.a = x;
}
return A;
})();
var x;
}
function foo8() {
var y = (function () {
function class_2() {
this.a = x;
}
return class_2;
})();
var x;
}
function foo9() {
var y = (function () {
function class_3() {
}
class_3.a = x;
return class_3;
})();
var x;
}
function foo10() {
var A = (function () {
function A() {
}
A.a = x;
return A;
})();
var x;
}
function foo11() {
function f() {
var y = (function () {
function class_4() {
}
class_4.a = x;
return class_4;
})();
}
var x;
}
function foo12() {
function f() {
var y = (function () {
function class_5() {
this.a = x;
}
return class_5;
})();
}
var x;
}
function foo13() {
var a = {
get a() { return x; }
};
var x;
}
function foo14() {
var a = {
a: x
};
var x;
}
@@ -4,12 +4,12 @@ var x = true;
var a = x.toString();
>a : Symbol(a, Decl(booleanPropertyAccess.ts, 2, 3))
>x.toString : Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
>x.toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(booleanPropertyAccess.ts, 0, 3))
>toString : Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
var b = x['toString']();
>b : Symbol(b, Decl(booleanPropertyAccess.ts, 3, 3))
>x : Symbol(x, Decl(booleanPropertyAccess.ts, 0, 3))
>'toString' : Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
>'toString' : Symbol(Object.toString, Decl(lib.d.ts, --, --))
@@ -110,23 +110,23 @@ interface A { // T
a12: (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
>a12 : Symbol(a12, Decl(callSignatureAssignabilityInInheritance2.ts, 19, 71))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 20, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance2.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance2.ts, 20, 25))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance2.ts, 3, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance2.ts, 2, 27))
a13: (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
>a13 : Symbol(a13, Decl(callSignatureAssignabilityInInheritance2.ts, 20, 64))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 21, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance2.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance2.ts, 21, 25))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance2.ts, 2, 27))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance2.ts, 2, 27))
a14: (x: { a: string; b: number }) => Object;
@@ -134,7 +134,7 @@ interface A { // T
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 22, 10))
>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 22, 14))
>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance2.ts, 22, 25))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
a15: {
>a15 : Symbol(a15, Decl(callSignatureAssignabilityInInheritance2.ts, 22, 49))
@@ -195,8 +195,8 @@ interface A { // T
(a: Date): Date;
>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 42, 13))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}): any[];
};
@@ -332,23 +332,23 @@ interface I extends A {
a12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
>a12 : Symbol(a12, Decl(callSignatureAssignabilityInInheritance2.ts, 60, 43))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 61, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance2.ts, 0, 0))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 61, 33))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance2.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance2.ts, 61, 48))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 61, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance2.ts, 2, 27))
a13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
>a13 : Symbol(a13, Decl(callSignatureAssignabilityInInheritance2.ts, 61, 73))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance2.ts, 2, 27))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 36))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance2.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 51))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10))
@@ -111,23 +111,23 @@ interface A { // T
a12: (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
>a12 : Symbol(a12, Decl(callSignatureAssignabilityInInheritance5.ts, 20, 71))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 21, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance5.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance5.ts, 21, 25))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance5.ts, 4, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance5.ts, 3, 27))
a13: (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
>a13 : Symbol(a13, Decl(callSignatureAssignabilityInInheritance5.ts, 21, 64))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 22, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance5.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance5.ts, 22, 25))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance5.ts, 3, 27))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance5.ts, 3, 27))
a14: (x: { a: string; b: number }) => Object;
@@ -135,7 +135,7 @@ interface A { // T
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 23, 10))
>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance5.ts, 23, 14))
>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance5.ts, 23, 25))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}
interface B extends A {
@@ -280,23 +280,23 @@ interface I extends B {
a12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
>a12 : Symbol(a12, Decl(callSignatureAssignabilityInInheritance5.ts, 43, 43))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 44, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance5.ts, 0, 0))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 44, 33))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance5.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance5.ts, 44, 48))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 44, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance5.ts, 3, 27))
a13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
>a13 : Symbol(a13, Decl(callSignatureAssignabilityInInheritance5.ts, 44, 73))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance5.ts, 3, 27))
>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 36))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance5.ts, 0, 0))
>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 51))
>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10))
@@ -54,7 +54,7 @@ var a: {
(x, y): Object;
>x : Symbol(x, Decl(callSignaturesThatDifferOnlyByReturnType.ts, 20, 5))
>y : Symbol(y, Decl(callSignaturesThatDifferOnlyByReturnType.ts, 20, 7))
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
(x, y): any; // error
>x : Symbol(x, Decl(callSignaturesThatDifferOnlyByReturnType.ts, 21, 5))
@@ -93,7 +93,7 @@ xa[1].foo(1, 2, ...a, "abc");
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
(<Function>xa[1].foo)(...[1, 2, "abc"]);
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
@@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc");
>a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3))
(<Function>xa[1].foo)(...[1, 2, "abc"]);
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 4036, 1))
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13))
>xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3))
>foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13))

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