mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-21 04:17:02 -06:00
Merge branch 'master' into map4
This commit is contained in:
commit
7217274746
@ -18,8 +18,13 @@ class TypeOperatorSpacingWalker extends Lint.RuleWalker {
|
||||
for (let i = 1; i < types.length; i++) {
|
||||
const currentType = types[i];
|
||||
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
|
||||
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
|
||||
this.addFailure(failure);
|
||||
const sourceFile = currentType.getSourceFile();
|
||||
const previousTypeEndPos = sourceFile.getLineAndCharacterOfPosition(types[i - 1].end);
|
||||
const currentTypeStartPos = sourceFile.getLineAndCharacterOfPosition(currentType.pos);
|
||||
if (previousTypeEndPos.line === currentTypeStartPos.line) {
|
||||
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
|
||||
this.addFailure(failure);
|
||||
}
|
||||
}
|
||||
expectedStart = currentType.end + 2;
|
||||
}
|
||||
|
||||
@ -355,11 +355,24 @@ namespace ts {
|
||||
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
||||
: Diagnostics.Duplicate_identifier_0;
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
if (hasModifier(declaration, ModifierFlags.Default)) {
|
||||
if (symbol.declarations && symbol.declarations.length) {
|
||||
// If the current node is a default export of some sort, then check if
|
||||
// there are any other default exports that we need to error on.
|
||||
// We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
|
||||
if (isDefaultExport) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
});
|
||||
else {
|
||||
// This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration.
|
||||
// Error on multiple export default in the following case:
|
||||
// 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
|
||||
// 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
|
||||
if (symbol.declarations && symbol.declarations.length &&
|
||||
(isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals))) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
|
||||
@ -1111,7 +1124,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
forEachChild(node, bind);
|
||||
if (node.operator === SyntaxKind.PlusEqualsToken || node.operator === SyntaxKind.MinusMinusToken) {
|
||||
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
|
||||
bindAssignmentTargetFlow(node.operand);
|
||||
}
|
||||
}
|
||||
@ -1360,7 +1373,7 @@ namespace ts {
|
||||
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
|
||||
const body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
|
||||
if (body && (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock)) {
|
||||
for (const stat of (<Block>body).statements) {
|
||||
for (const stat of (<BlockLike>body).statements) {
|
||||
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
|
||||
return true;
|
||||
}
|
||||
@ -1943,12 +1956,15 @@ namespace ts {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));
|
||||
}
|
||||
else {
|
||||
// An export default clause with an expression exports a value
|
||||
// We want to exclude both class and function here, this is necessary to issue an error when there are both
|
||||
// default export-assignment and default export function and class declaration.
|
||||
const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node)
|
||||
// An export default clause with an EntityNameExpression exports all meanings of that identifier
|
||||
? SymbolFlags.Alias
|
||||
// An export default clause with any other expression exports a value
|
||||
: SymbolFlags.Property;
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.Property | SymbolFlags.AliasExcludes | SymbolFlags.Class | SymbolFlags.Function);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -120,6 +120,7 @@ namespace ts {
|
||||
const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__");
|
||||
|
||||
const anyType = createIntrinsicType(TypeFlags.Any, "any");
|
||||
const autoType = createIntrinsicType(TypeFlags.Any, "any");
|
||||
const unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
|
||||
const undefinedType = createIntrinsicType(TypeFlags.Undefined, "undefined");
|
||||
const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsWideningType, "undefined");
|
||||
@ -3064,6 +3065,11 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isAutoVariableInitializer(initializer: Expression) {
|
||||
const expr = initializer && skipParentheses(initializer);
|
||||
return !expr || expr.kind === SyntaxKind.NullKeyword || expr.kind === SyntaxKind.Identifier && getResolvedSymbol(<Identifier>expr) === undefinedSymbol;
|
||||
}
|
||||
|
||||
function addOptionality(type: Type, optional: boolean): Type {
|
||||
return strictNullChecks && optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type;
|
||||
}
|
||||
@ -3102,6 +3108,14 @@ namespace ts {
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality);
|
||||
}
|
||||
|
||||
// Use control flow type inference for non-ambient, non-exported var or let variables with no initializer
|
||||
// or a 'null' or 'undefined' initializer.
|
||||
if (declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) &&
|
||||
!(getCombinedNodeFlags(declaration) & NodeFlags.Const) && !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) &&
|
||||
!isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) {
|
||||
return autoType;
|
||||
}
|
||||
|
||||
if (declaration.kind === SyntaxKind.Parameter) {
|
||||
const func = <FunctionLikeDeclaration>declaration.parent;
|
||||
// For a parameter of a set accessor, use the type of the get accessor if one is present
|
||||
@ -3897,7 +3911,7 @@ namespace ts {
|
||||
if (!links.declaredType) {
|
||||
const enumType = <EnumType>getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
|
||||
links.declaredType = enumType.flags & TypeFlags.Union ?
|
||||
enumType.memberTypes[getEnumMemberValue(<EnumDeclaration>symbol.valueDeclaration)] :
|
||||
enumType.memberTypes[getEnumMemberValue(<EnumMember>symbol.valueDeclaration)] :
|
||||
enumType;
|
||||
}
|
||||
return links.declaredType;
|
||||
@ -6070,7 +6084,7 @@ namespace ts {
|
||||
return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow;
|
||||
}
|
||||
|
||||
function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | MethodDeclaration {
|
||||
function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration {
|
||||
return (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func);
|
||||
}
|
||||
|
||||
@ -8470,7 +8484,9 @@ namespace ts {
|
||||
if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) {
|
||||
return declaredType;
|
||||
}
|
||||
const initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, TypeFlags.Undefined);
|
||||
const initialType = assumeInitialized ? declaredType :
|
||||
declaredType === autoType ? undefinedType :
|
||||
includeFalsyTypes(declaredType, TypeFlags.Undefined);
|
||||
const visitedFlowStart = visitedFlowCount;
|
||||
const result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
|
||||
visitedFlowCount = visitedFlowStart;
|
||||
@ -8544,9 +8560,12 @@ namespace ts {
|
||||
// Assignments only narrow the computed type if the declared type is a union type. Thus, we
|
||||
// only need to evaluate the assigned type if the declared type is a union type.
|
||||
if (isMatchingReference(reference, node)) {
|
||||
const isIncrementOrDecrement = node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.PostfixUnaryExpression;
|
||||
return declaredType.flags & TypeFlags.Union && !isIncrementOrDecrement ?
|
||||
getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(node)) :
|
||||
if (node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.PostfixUnaryExpression) {
|
||||
const flowType = getTypeAtFlowNode(flow.antecedent);
|
||||
return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
|
||||
}
|
||||
return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) :
|
||||
declaredType.flags & TypeFlags.Union ? getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(node)) :
|
||||
declaredType;
|
||||
}
|
||||
// We didn't have a direct match. However, if the reference is a dotted name, this
|
||||
@ -8992,7 +9011,7 @@ namespace ts {
|
||||
if (isRightSideOfQualifiedNameOrPropertyAccess(location)) {
|
||||
location = location.parent;
|
||||
}
|
||||
if (isExpression(location) && !isAssignmentTarget(location)) {
|
||||
if (isPartOfExpression(location) && !isAssignmentTarget(location)) {
|
||||
const type = checkExpression(<Expression>location);
|
||||
if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
|
||||
return type;
|
||||
@ -9163,13 +9182,23 @@ namespace ts {
|
||||
// We only look for uninitialized variables in strict null checking mode, and only when we can analyze
|
||||
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
|
||||
// declaration container are the same).
|
||||
const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isParameter ||
|
||||
isOuterVariable || isInAmbientContext(declaration);
|
||||
const assumeInitialized = isParameter || isOuterVariable ||
|
||||
type !== autoType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0) ||
|
||||
isInAmbientContext(declaration);
|
||||
const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer);
|
||||
// A variable is considered uninitialized when it is possible to analyze the entire control flow graph
|
||||
// from declaration to use, and when the variable's declared type doesn't include undefined but the
|
||||
// control flow based type does include undefined.
|
||||
if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) {
|
||||
if (type === autoType) {
|
||||
if (flowType === autoType) {
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol));
|
||||
error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType));
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
}
|
||||
else if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) {
|
||||
error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
|
||||
// Return the declared type to reduce follow-on errors
|
||||
return type;
|
||||
@ -9283,7 +9312,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function findFirstSuperCall(n: Node): Node {
|
||||
if (isSuperCallExpression(n)) {
|
||||
if (isSuperCall(n)) {
|
||||
return n;
|
||||
}
|
||||
else if (isFunctionLike(n)) {
|
||||
@ -9792,7 +9821,7 @@ namespace ts {
|
||||
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
||||
if (functionDecl.type ||
|
||||
functionDecl.kind === SyntaxKind.Constructor ||
|
||||
functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration>getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) {
|
||||
functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<SetAccessorDeclaration>getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) {
|
||||
return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl));
|
||||
}
|
||||
|
||||
@ -10061,7 +10090,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression {
|
||||
function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression | ArrowFunction {
|
||||
return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
@ -10072,7 +10101,7 @@ namespace ts {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | MethodDeclaration) {
|
||||
function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | ArrowFunction | MethodDeclaration) {
|
||||
return isObjectLiteralMethod(node) ?
|
||||
getContextualTypeForObjectLiteralMethod(node) :
|
||||
getApparentTypeOfContextualType(node);
|
||||
@ -10083,7 +10112,7 @@ namespace ts {
|
||||
// If the contextual type is a union type, get the signature from each type possible and if they are
|
||||
// all identical ignoring their return type, the result is same signature but with return type as
|
||||
// union type of return types from these signatures
|
||||
function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature {
|
||||
function getContextualSignature(node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature {
|
||||
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
|
||||
const type = getContextualTypeForFunctionLikeDeclaration(node);
|
||||
if (!type) {
|
||||
@ -11436,7 +11465,7 @@ namespace ts {
|
||||
argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature);
|
||||
}
|
||||
else {
|
||||
const callExpression = <CallExpression>node;
|
||||
const callExpression = <CallExpression | NewExpression>node;
|
||||
if (!callExpression.arguments) {
|
||||
// This only happens when we have something of the form: 'new C'
|
||||
Debug.assert(callExpression.kind === SyntaxKind.NewExpression);
|
||||
@ -11447,7 +11476,7 @@ namespace ts {
|
||||
argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
|
||||
|
||||
// If we are missing the close paren, the call is incomplete.
|
||||
callIsIncomplete = (<CallExpression>callExpression).arguments.end === callExpression.end;
|
||||
callIsIncomplete = callExpression.arguments.end === callExpression.end;
|
||||
|
||||
typeArguments = callExpression.typeArguments;
|
||||
spreadArgIndex = getSpreadArgumentIndex(args);
|
||||
@ -12534,7 +12563,7 @@ namespace ts {
|
||||
* @param node The call/new expression to be checked.
|
||||
* @returns On success, the expression's signature's return type. On failure, anyType.
|
||||
*/
|
||||
function checkCallExpression(node: CallExpression): Type {
|
||||
function checkCallExpression(node: CallExpression | NewExpression): Type {
|
||||
// Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true
|
||||
checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments);
|
||||
|
||||
@ -12992,7 +13021,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) {
|
||||
if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration) {
|
||||
checkCollisionWithCapturedSuperVariable(node, (<FunctionExpression>node).name);
|
||||
checkCollisionWithCapturedThisVariable(node, (<FunctionExpression>node).name);
|
||||
}
|
||||
@ -14454,7 +14483,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function containsSuperCall(n: Node): boolean {
|
||||
if (isSuperCallExpression(n)) {
|
||||
if (isSuperCall(n)) {
|
||||
return true;
|
||||
}
|
||||
else if (isFunctionLike(n)) {
|
||||
@ -14510,7 +14539,7 @@ namespace ts {
|
||||
let superCallStatement: ExpressionStatement;
|
||||
|
||||
for (const statement of statements) {
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((<ExpressionStatement>statement).expression)) {
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCall((<ExpressionStatement>statement).expression)) {
|
||||
superCallStatement = <ExpressionStatement>statement;
|
||||
break;
|
||||
}
|
||||
@ -15917,6 +15946,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function convertAutoToAny(type: Type) {
|
||||
return type === autoType ? anyType : type;
|
||||
}
|
||||
|
||||
// Check variable, parameter, or property declaration
|
||||
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
|
||||
checkDecorators(node);
|
||||
@ -15967,7 +16000,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
const symbol = getSymbolOfNode(node);
|
||||
const type = getTypeOfVariableOrParameterOrProperty(symbol);
|
||||
const type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol));
|
||||
if (node === symbol.valueDeclaration) {
|
||||
// Node is the primary declaration of the symbol, just validate the initializer
|
||||
// Don't validate for-in initializer as it is already an error
|
||||
@ -15979,7 +16012,7 @@ namespace ts {
|
||||
else {
|
||||
// Node is a secondary declaration, check that type is identical to primary declaration and check that
|
||||
// initializer is consistent with type associated with the node
|
||||
const declarationType = getWidenedTypeForVariableLikeDeclaration(node);
|
||||
const declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
|
||||
if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) {
|
||||
error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType));
|
||||
}
|
||||
@ -16468,7 +16501,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isGetAccessorWithAnnotatedSetAccessor(node: FunctionLikeDeclaration) {
|
||||
return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration>getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor)));
|
||||
return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<SetAccessorDeclaration>getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor)));
|
||||
}
|
||||
|
||||
function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean {
|
||||
@ -17459,9 +17492,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
checkCollisionWithCapturedThisVariable(node, node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
if (isIdentifier(node.name)) {
|
||||
checkCollisionWithCapturedThisVariable(node, node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
}
|
||||
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
const symbol = getSymbolOfNode(node);
|
||||
|
||||
@ -19076,7 +19112,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isLiteralConstDeclaration(node: VariableDeclaration): boolean {
|
||||
function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean {
|
||||
if (isConst(node)) {
|
||||
const type = getTypeOfSymbol(getSymbolOfNode(node));
|
||||
return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral);
|
||||
@ -19084,7 +19120,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function writeLiteralConstValue(node: VariableDeclaration, writer: SymbolWriter) {
|
||||
function writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter) {
|
||||
const type = getTypeOfSymbol(getSymbolOfNode(node));
|
||||
writer.writeStringLiteral(literalTypeToString(<LiteralType>type));
|
||||
}
|
||||
@ -19822,7 +19858,7 @@ namespace ts {
|
||||
checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
|
||||
}
|
||||
|
||||
function checkGrammarForOmittedArgument(node: CallExpression, args: NodeArray<Expression>): boolean {
|
||||
function checkGrammarForOmittedArgument(node: CallExpression | NewExpression, args: NodeArray<Expression>): boolean {
|
||||
if (args) {
|
||||
const sourceFile = getSourceFileOfNode(node);
|
||||
for (const arg of args) {
|
||||
@ -19833,7 +19869,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarArguments(node: CallExpression, args: NodeArray<Expression>): boolean {
|
||||
function checkGrammarArguments(node: CallExpression | NewExpression, args: NodeArray<Expression>): boolean {
|
||||
return checkGrammarForOmittedArgument(node, args);
|
||||
}
|
||||
|
||||
@ -19955,8 +19991,7 @@ namespace ts {
|
||||
|
||||
for (const prop of node.properties) {
|
||||
const name = prop.name;
|
||||
if (prop.kind === SyntaxKind.OmittedExpression ||
|
||||
name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
if (name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
// If the name is not a ComputedPropertyName, the grammar checking will skip it
|
||||
checkGrammarComputedPropertyName(<ComputedPropertyName>name);
|
||||
}
|
||||
@ -20003,7 +20038,7 @@ namespace ts {
|
||||
currentKind = SetAccessor;
|
||||
}
|
||||
else {
|
||||
Debug.fail("Unexpected syntax kind:" + prop.kind);
|
||||
Debug.fail("Unexpected syntax kind:" + (<Node>prop).kind);
|
||||
}
|
||||
|
||||
const effectiveName = getPropertyNameForPropertyNameNode(name);
|
||||
|
||||
@ -836,7 +836,9 @@ namespace ts {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
|
||||
/**
|
||||
* Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
|
||||
*/
|
||||
export function getRootLength(path: string): number {
|
||||
if (path.charCodeAt(0) === CharacterCodes.slash) {
|
||||
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
|
||||
@ -865,9 +867,14 @@ namespace ts {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internally, we represent paths as strings with '/' as the directory separator.
|
||||
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
||||
* we expect the host to correctly handle paths in our specified format.
|
||||
*/
|
||||
export const directorySeparator = "/";
|
||||
const directorySeparatorCharCode = CharacterCodes.slash;
|
||||
function getNormalizedParts(normalizedSlashedPath: string, rootLength: number) {
|
||||
function getNormalizedParts(normalizedSlashedPath: string, rootLength: number): string[] {
|
||||
const parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
|
||||
const normalized: string[] = [];
|
||||
for (const part of parts) {
|
||||
@ -907,6 +914,11 @@ namespace ts {
|
||||
return path.charCodeAt(path.length - 1) === directorySeparatorCharCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path except for its basename. Eg:
|
||||
*
|
||||
* /path/to/file.ext -> /path/to
|
||||
*/
|
||||
export function getDirectoryPath(path: Path): Path;
|
||||
export function getDirectoryPath(path: string): string;
|
||||
export function getDirectoryPath(path: string): any {
|
||||
@ -1552,9 +1564,9 @@ namespace ts {
|
||||
|
||||
export interface ObjectAllocator {
|
||||
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
getTokenConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
|
||||
getIdentifierConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
|
||||
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
|
||||
getTokenConstructor(): new <TKind extends SyntaxKind>(kind: TKind, pos?: number, end?: number) => Token<TKind>;
|
||||
getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier;
|
||||
getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile;
|
||||
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
|
||||
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
|
||||
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
|
||||
|
||||
@ -1121,7 +1121,7 @@ namespace ts {
|
||||
writeLine();
|
||||
}
|
||||
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
function emitVariableDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration) {
|
||||
// If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted
|
||||
// so there is no check needed to see if declaration is visible
|
||||
if (node.kind !== SyntaxKind.VariableDeclaration || resolver.isDeclarationVisible(node)) {
|
||||
@ -1136,7 +1136,7 @@ namespace ts {
|
||||
// If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
|
||||
// we don't want to emit property declaration with "?"
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
|
||||
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(node))) && hasQuestionToken(node)) {
|
||||
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(<ParameterDeclaration>node))) && hasQuestionToken(node)) {
|
||||
write("?");
|
||||
}
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
@ -1626,8 +1626,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitBindingElement(bindingElement: BindingElement) {
|
||||
|
||||
function emitBindingElement(bindingElement: BindingElement | OmittedExpression) {
|
||||
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
|
||||
// If bindingElement is an omittedExpression (i.e. containing elision),
|
||||
// we will emit blank space (although this may differ from users' original code,
|
||||
|
||||
@ -2957,6 +2957,10 @@
|
||||
"category": "Error",
|
||||
"code": 7033
|
||||
},
|
||||
"Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined.": {
|
||||
"category": "Error",
|
||||
"code": 7034
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
|
||||
@ -68,7 +68,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
@ -655,7 +655,7 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return emitModuleDeclaration(<ModuleDeclaration>node);
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return emitModuleBlock(<Block>node);
|
||||
return emitModuleBlock(<ModuleBlock>node);
|
||||
case SyntaxKind.CaseBlock:
|
||||
return emitCaseBlock(<CaseBlock>node);
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
@ -1394,7 +1394,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitBlockStatements(node: Block) {
|
||||
function emitBlockStatements(node: BlockLike) {
|
||||
if (getEmitFlags(node) & EmitFlags.SingleLine) {
|
||||
emitList(node, node.statements, ListFormat.SingleLineBlockStatements);
|
||||
}
|
||||
@ -1795,7 +1795,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function emitModuleBlock(node: ModuleBlock) {
|
||||
if (isSingleLineEmptyBlock(node)) {
|
||||
if (isEmptyBlock(node)) {
|
||||
write("{ }");
|
||||
}
|
||||
else {
|
||||
@ -2615,7 +2615,11 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function isSingleLineEmptyBlock(block: Block) {
|
||||
return !block.multiLine
|
||||
&& block.statements.length === 0
|
||||
&& isEmptyBlock(block);
|
||||
}
|
||||
|
||||
function isEmptyBlock(block: BlockLike) {
|
||||
return block.statements.length === 0
|
||||
&& rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
|
||||
}
|
||||
|
||||
|
||||
@ -105,6 +105,7 @@ namespace ts {
|
||||
export function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral;
|
||||
export function createLiteral(value: string, location?: TextRange): StringLiteral;
|
||||
export function createLiteral(value: number, location?: TextRange): NumericLiteral;
|
||||
export function createLiteral(value: boolean, location?: TextRange): BooleanLiteral;
|
||||
export function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression;
|
||||
export function createLiteral(value: string | number | boolean | StringLiteral | Identifier, location?: TextRange): PrimaryExpression {
|
||||
if (typeof value === "number") {
|
||||
@ -120,7 +121,7 @@ namespace ts {
|
||||
node.text = value;
|
||||
return node;
|
||||
}
|
||||
else {
|
||||
else if (value) {
|
||||
const node = <StringLiteral>createNode(SyntaxKind.StringLiteral, location, /*flags*/ undefined);
|
||||
node.textSourceNode = value;
|
||||
node.text = value.text;
|
||||
@ -187,8 +188,8 @@ namespace ts {
|
||||
|
||||
// Punctuation
|
||||
|
||||
export function createToken(token: SyntaxKind) {
|
||||
return createNode(token);
|
||||
export function createToken<TKind extends SyntaxKind>(token: TKind) {
|
||||
return <Token<TKind>>createNode(token);
|
||||
}
|
||||
|
||||
// Reserved words
|
||||
@ -238,7 +239,7 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
export function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: Node, name: string | Identifier | BindingPattern, questionToken: Node, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <ParameterDeclaration>createNode(SyntaxKind.Parameter, location, flags);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@ -260,7 +261,7 @@ namespace ts {
|
||||
|
||||
// Type members
|
||||
|
||||
export function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: Node, type: TypeNode, initializer: Expression, location?: TextRange) {
|
||||
export function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange) {
|
||||
const node = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, location);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@ -278,7 +279,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: Node, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, location, flags);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@ -381,7 +382,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: Node, name: string | BindingName, initializer?: Expression, location?: TextRange) {
|
||||
export function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange) {
|
||||
const node = <BindingElement>createNode(SyntaxKind.BindingElement, location);
|
||||
node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName;
|
||||
node.dotDotDotToken = dotDotDotToken;
|
||||
@ -497,14 +498,14 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createTaggedTemplate(tag: Expression, template: Template, location?: TextRange) {
|
||||
export function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange) {
|
||||
const node = <TaggedTemplateExpression>createNode(SyntaxKind.TaggedTemplateExpression, location);
|
||||
node.tag = parenthesizeForAccess(tag);
|
||||
node.template = template;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: Template) {
|
||||
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral) {
|
||||
if (node.tag !== tag || node.template !== template) {
|
||||
return updateNode(createTaggedTemplate(tag, template, node), node);
|
||||
}
|
||||
@ -524,7 +525,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createFunctionExpression(asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createFunctionExpression(asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression, location, flags);
|
||||
node.modifiers = undefined;
|
||||
node.asteriskToken = asteriskToken;
|
||||
@ -543,13 +544,13 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: Node, body: ConciseBody, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction, location, flags);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined;
|
||||
node.parameters = createNodeArray(parameters);
|
||||
node.type = type;
|
||||
node.equalsGreaterThanToken = equalsGreaterThanToken || createNode(SyntaxKind.EqualsGreaterThanToken);
|
||||
node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(SyntaxKind.EqualsGreaterThanToken);
|
||||
node.body = parenthesizeConciseBody(body);
|
||||
return node;
|
||||
}
|
||||
@ -613,7 +614,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createPrefix(operator: SyntaxKind, operand: Expression, location?: TextRange) {
|
||||
export function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange) {
|
||||
const node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression, location);
|
||||
node.operator = operator;
|
||||
node.operand = parenthesizePrefixOperand(operand);
|
||||
@ -627,7 +628,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createPostfix(operand: Expression, operator: SyntaxKind, location?: TextRange) {
|
||||
export function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange) {
|
||||
const node = <PostfixUnaryExpression>createNode(SyntaxKind.PostfixUnaryExpression, location);
|
||||
node.operand = parenthesizePostfixOperand(operand);
|
||||
node.operator = operator;
|
||||
@ -641,8 +642,8 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createBinary(left: Expression, operator: SyntaxKind | Node, right: Expression, location?: TextRange) {
|
||||
const operatorToken = typeof operator === "number" ? createSynthesizedNode(operator) : operator;
|
||||
export function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange) {
|
||||
const operatorToken = typeof operator === "number" ? createToken(operator) : operator;
|
||||
const operatorKind = operatorToken.kind;
|
||||
const node = <BinaryExpression>createNode(SyntaxKind.BinaryExpression, location);
|
||||
node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined);
|
||||
@ -658,7 +659,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createConditional(condition: Expression, questionToken: Node, whenTrue: Expression, colonToken: Node, whenFalse: Expression, location?: TextRange) {
|
||||
export function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange) {
|
||||
const node = <ConditionalExpression>createNode(SyntaxKind.ConditionalExpression, location);
|
||||
node.condition = condition;
|
||||
node.questionToken = questionToken;
|
||||
@ -675,21 +676,21 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createTemplateExpression(head: TemplateLiteralFragment, templateSpans: TemplateSpan[], location?: TextRange) {
|
||||
export function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange) {
|
||||
const node = <TemplateExpression>createNode(SyntaxKind.TemplateExpression, location);
|
||||
node.head = head;
|
||||
node.templateSpans = createNodeArray(templateSpans);
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTemplateExpression(node: TemplateExpression, head: TemplateLiteralFragment, templateSpans: TemplateSpan[]) {
|
||||
export function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]) {
|
||||
if (node.head !== head || node.templateSpans !== templateSpans) {
|
||||
return updateNode(createTemplateExpression(head, templateSpans, node), node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createYield(asteriskToken: Node, expression: Expression, location?: TextRange) {
|
||||
export function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange) {
|
||||
const node = <YieldExpression>createNode(SyntaxKind.YieldExpression, location);
|
||||
node.asteriskToken = asteriskToken;
|
||||
node.expression = expression;
|
||||
@ -756,14 +757,14 @@ namespace ts {
|
||||
|
||||
// Misc
|
||||
|
||||
export function createTemplateSpan(expression: Expression, literal: TemplateLiteralFragment, location?: TextRange) {
|
||||
export function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange) {
|
||||
const node = <TemplateSpan>createNode(SyntaxKind.TemplateSpan, location);
|
||||
node.expression = expression;
|
||||
node.literal = literal;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateLiteralFragment) {
|
||||
export function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail) {
|
||||
if (node.expression !== expression || node.literal !== literal) {
|
||||
return updateNode(createTemplateSpan(expression, literal, node), node);
|
||||
}
|
||||
@ -932,14 +933,14 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateForOf(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement) {
|
||||
export function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement) {
|
||||
if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) {
|
||||
return updateNode(createForOf(initializer, expression, statement, node), node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createContinue(label?: Identifier, location?: TextRange): BreakStatement {
|
||||
export function createContinue(label?: Identifier, location?: TextRange): ContinueStatement {
|
||||
const node = <ContinueStatement>createNode(SyntaxKind.ContinueStatement, location);
|
||||
if (label) {
|
||||
node.label = label;
|
||||
@ -1065,7 +1066,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <FunctionDeclaration>createNode(SyntaxKind.FunctionDeclaration, location, flags);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@ -1560,7 +1561,7 @@ namespace ts {
|
||||
return createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
createSynthesizedNode(SyntaxKind.DotDotDotToken),
|
||||
createToken(SyntaxKind.DotDotDotToken),
|
||||
name,
|
||||
/*questionToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
@ -1735,7 +1736,7 @@ namespace ts {
|
||||
|
||||
export function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) {
|
||||
const generatorFunc = createFunctionExpression(
|
||||
createNode(SyntaxKind.AsteriskToken),
|
||||
createToken(SyntaxKind.AsteriskToken),
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ [],
|
||||
|
||||
@ -637,7 +637,7 @@ namespace ts {
|
||||
|
||||
sourceFile.statements = parseList(ParsingContext.SourceElements, parseStatement);
|
||||
Debug.assert(token() === SyntaxKind.EndOfFileToken);
|
||||
sourceFile.endOfFileToken = parseTokenNode();
|
||||
sourceFile.endOfFileToken = <EndOfFileToken>parseTokenNode();
|
||||
|
||||
setExternalModuleIndicator(sourceFile);
|
||||
|
||||
@ -1004,6 +1004,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseOptionalToken<TKind extends SyntaxKind>(t: TKind): Token<TKind>;
|
||||
function parseOptionalToken(t: SyntaxKind): Node {
|
||||
if (token() === t) {
|
||||
return parseTokenNode();
|
||||
@ -1011,6 +1012,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseExpectedToken<TKind extends SyntaxKind>(t: TKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Token<TKind>;
|
||||
function parseExpectedToken(t: SyntaxKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Node {
|
||||
return parseOptionalToken(t) ||
|
||||
createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0);
|
||||
@ -1047,7 +1049,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// note: this function creates only node
|
||||
function createNode(kind: SyntaxKind, pos?: number): Node | Token | Identifier {
|
||||
function createNode<TKind extends SyntaxKind>(kind: TKind, pos?: number): Node | Token<TKind> | Identifier {
|
||||
nodeCount++;
|
||||
if (!(pos >= 0)) {
|
||||
pos = scanner.getStartPos();
|
||||
@ -1920,7 +1922,7 @@ namespace ts {
|
||||
function parseTemplateExpression(): TemplateExpression {
|
||||
const template = <TemplateExpression>createNode(SyntaxKind.TemplateExpression);
|
||||
|
||||
template.head = parseTemplateLiteralFragment();
|
||||
template.head = parseTemplateHead();
|
||||
Debug.assert(template.head.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind");
|
||||
|
||||
const templateSpans = createNodeArray<TemplateSpan>();
|
||||
@ -1940,14 +1942,13 @@ namespace ts {
|
||||
const span = <TemplateSpan>createNode(SyntaxKind.TemplateSpan);
|
||||
span.expression = allowInAnd(parseExpression);
|
||||
|
||||
let literal: TemplateLiteralFragment;
|
||||
|
||||
let literal: TemplateMiddle | TemplateTail;
|
||||
if (token() === SyntaxKind.CloseBraceToken) {
|
||||
reScanTemplateToken();
|
||||
literal = parseTemplateLiteralFragment();
|
||||
literal = parseTemplateMiddleOrTemplateTail();
|
||||
}
|
||||
else {
|
||||
literal = <TemplateLiteralFragment>parseExpectedToken(SyntaxKind.TemplateTail, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBraceToken));
|
||||
literal = <TemplateTail>parseExpectedToken(SyntaxKind.TemplateTail, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBraceToken));
|
||||
}
|
||||
|
||||
span.literal = literal;
|
||||
@ -1958,8 +1959,16 @@ namespace ts {
|
||||
return <LiteralExpression>parseLiteralLikeNode(token(), internName);
|
||||
}
|
||||
|
||||
function parseTemplateLiteralFragment(): TemplateLiteralFragment {
|
||||
return <TemplateLiteralFragment>parseLiteralLikeNode(token(), /*internName*/ false);
|
||||
function parseTemplateHead(): TemplateHead {
|
||||
const fragment = parseLiteralLikeNode(token(), /*internName*/ false);
|
||||
Debug.assert(fragment.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind");
|
||||
return <TemplateHead>fragment;
|
||||
}
|
||||
|
||||
function parseTemplateMiddleOrTemplateTail(): TemplateMiddle | TemplateTail {
|
||||
const fragment = parseLiteralLikeNode(token(), /*internName*/ false);
|
||||
Debug.assert(fragment.kind === SyntaxKind.TemplateMiddle || fragment.kind === SyntaxKind.TemplateTail, "Template fragment has wrong token kind");
|
||||
return <TemplateMiddle | TemplateTail>fragment;
|
||||
}
|
||||
|
||||
function parseLiteralLikeNode(kind: SyntaxKind, internName: boolean): LiteralLikeNode {
|
||||
@ -2719,7 +2728,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let expr = parseAssignmentExpressionOrHigher();
|
||||
let operatorToken: Node;
|
||||
let operatorToken: BinaryOperatorToken;
|
||||
while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) {
|
||||
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
|
||||
}
|
||||
@ -2812,7 +2821,7 @@ namespace ts {
|
||||
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
||||
// for cases like > > = becoming >>=
|
||||
if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) {
|
||||
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
|
||||
return makeBinaryExpression(expr, <BinaryOperatorToken>parseTokenNode(), parseAssignmentExpressionOrHigher());
|
||||
}
|
||||
|
||||
// It wasn't an assignment or a lambda. This is a conditional expression:
|
||||
@ -3247,7 +3256,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
|
||||
leftOperand = makeBinaryExpression(leftOperand, <BinaryOperatorToken>parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3307,7 +3316,7 @@ namespace ts {
|
||||
return -1;
|
||||
}
|
||||
|
||||
function makeBinaryExpression(left: Expression, operatorToken: Node, right: Expression): BinaryExpression {
|
||||
function makeBinaryExpression(left: Expression, operatorToken: BinaryOperatorToken, right: Expression): BinaryExpression {
|
||||
const node = <BinaryExpression>createNode(SyntaxKind.BinaryExpression, left.pos);
|
||||
node.left = left;
|
||||
node.operatorToken = operatorToken;
|
||||
@ -3324,7 +3333,7 @@ namespace ts {
|
||||
|
||||
function parsePrefixUnaryExpression() {
|
||||
const node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression);
|
||||
node.operator = token();
|
||||
node.operator = <PrefixUnaryOperator>token();
|
||||
nextToken();
|
||||
node.operand = parseSimpleUnaryExpression();
|
||||
|
||||
@ -3511,7 +3520,7 @@ namespace ts {
|
||||
function parseIncrementExpression(): IncrementExpression {
|
||||
if (token() === SyntaxKind.PlusPlusToken || token() === SyntaxKind.MinusMinusToken) {
|
||||
const node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression);
|
||||
node.operator = token();
|
||||
node.operator = <PrefixUnaryOperator>token();
|
||||
nextToken();
|
||||
node.operand = parseLeftHandSideExpressionOrHigher();
|
||||
return finishNode(node);
|
||||
@ -3527,7 +3536,7 @@ namespace ts {
|
||||
if ((token() === SyntaxKind.PlusPlusToken || token() === SyntaxKind.MinusMinusToken) && !scanner.hasPrecedingLineBreak()) {
|
||||
const node = <PostfixUnaryExpression>createNode(SyntaxKind.PostfixUnaryExpression, expression.pos);
|
||||
node.operand = expression;
|
||||
node.operator = token();
|
||||
node.operator = <PostfixUnaryOperator>token();
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
@ -3700,7 +3709,7 @@ namespace ts {
|
||||
badNode.end = invalidElement.end;
|
||||
badNode.left = result;
|
||||
badNode.right = invalidElement;
|
||||
badNode.operatorToken = createMissingNode(SyntaxKind.CommaToken, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined);
|
||||
badNode.operatorToken = <BinaryOperatorToken>createMissingNode(SyntaxKind.CommaToken, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined);
|
||||
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
|
||||
return <JsxElement><Node>badNode;
|
||||
}
|
||||
@ -3836,7 +3845,7 @@ namespace ts {
|
||||
if (token() === SyntaxKind.EqualsToken) {
|
||||
switch (scanJsxAttributeValue()) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
node.initializer = parseLiteralNode();
|
||||
node.initializer = <StringLiteral>parseLiteralNode();
|
||||
break;
|
||||
default:
|
||||
node.initializer = parseJsxExpression(/*inExpressionContext*/ true);
|
||||
@ -3921,7 +3930,7 @@ namespace ts {
|
||||
const tagExpression = <TaggedTemplateExpression>createNode(SyntaxKind.TaggedTemplateExpression, expression.pos);
|
||||
tagExpression.tag = expression;
|
||||
tagExpression.template = token() === SyntaxKind.NoSubstitutionTemplateLiteral
|
||||
? parseLiteralNode()
|
||||
? <NoSubstitutionTemplateLiteral>parseLiteralNode()
|
||||
: parseTemplateExpression();
|
||||
expression = finishNode(tagExpression);
|
||||
continue;
|
||||
@ -4959,7 +4968,7 @@ namespace ts {
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
|
||||
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
|
||||
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, asteriskToken: AsteriskToken, name: PropertyName, questionToken: QuestionToken, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
|
||||
const method = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, fullStart);
|
||||
method.decorators = decorators;
|
||||
method.modifiers = modifiers;
|
||||
@ -4973,7 +4982,7 @@ namespace ts {
|
||||
return addJSDocComment(finishNode(method));
|
||||
}
|
||||
|
||||
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, name: PropertyName, questionToken: Node): ClassElement {
|
||||
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, name: PropertyName, questionToken: QuestionToken): ClassElement {
|
||||
const property = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, fullStart);
|
||||
property.decorators = decorators;
|
||||
property.modifiers = modifiers;
|
||||
@ -5395,7 +5404,7 @@ namespace ts {
|
||||
node.flags |= flags;
|
||||
node.name = parseIdentifier();
|
||||
node.body = parseOptional(SyntaxKind.DotToken)
|
||||
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag)
|
||||
? <NamespaceDeclaration>parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag)
|
||||
: parseModuleBlock();
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
@ -5574,8 +5583,10 @@ namespace ts {
|
||||
return finishNode(namespaceImport);
|
||||
}
|
||||
|
||||
function parseNamedImportsOrExports(kind: SyntaxKind.NamedImports): NamedImports;
|
||||
function parseNamedImportsOrExports(kind: SyntaxKind.NamedExports): NamedExports;
|
||||
function parseNamedImportsOrExports(kind: SyntaxKind): NamedImportsOrExports {
|
||||
const node = <NamedImports>createNode(kind);
|
||||
const node = <NamedImports | NamedExports>createNode(kind);
|
||||
|
||||
// NamedImports:
|
||||
// { }
|
||||
@ -5585,7 +5596,7 @@ namespace ts {
|
||||
// ImportsList:
|
||||
// ImportSpecifier
|
||||
// ImportsList, ImportSpecifier
|
||||
node.elements = parseBracketedList(ParsingContext.ImportOrExportSpecifiers,
|
||||
node.elements = <NodeArray<ImportSpecifier> | NodeArray<ExportSpecifier>>parseBracketedList(ParsingContext.ImportOrExportSpecifiers,
|
||||
kind === SyntaxKind.NamedImports ? parseImportSpecifier : parseExportSpecifier,
|
||||
SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken);
|
||||
return finishNode(node);
|
||||
@ -5969,14 +5980,15 @@ namespace ts {
|
||||
const parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
|
||||
parameter.type = parseJSDocType();
|
||||
if (parseOptional(SyntaxKind.EqualsToken)) {
|
||||
parameter.questionToken = createNode(SyntaxKind.EqualsToken);
|
||||
// TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken?
|
||||
parameter.questionToken = <QuestionToken>createNode(SyntaxKind.EqualsToken);
|
||||
}
|
||||
return finishNode(parameter);
|
||||
}
|
||||
|
||||
function parseJSDocTypeReference(): JSDocTypeReference {
|
||||
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
|
||||
result.name = parseSimplePropertyName();
|
||||
result.name = <Identifier>parseSimplePropertyName();
|
||||
|
||||
if (token() === SyntaxKind.LessThanToken) {
|
||||
result.typeArguments = parseTypeArguments();
|
||||
@ -6304,7 +6316,7 @@ namespace ts {
|
||||
|
||||
function parseTag(indent: number) {
|
||||
Debug.assert(token() === SyntaxKind.AtToken);
|
||||
const atToken = createNode(SyntaxKind.AtToken, scanner.getTokenPos());
|
||||
const atToken = <AtToken>createNode(SyntaxKind.AtToken, scanner.getTokenPos());
|
||||
atToken.end = scanner.getTextPos();
|
||||
nextJSDocToken();
|
||||
|
||||
@ -6410,7 +6422,7 @@ namespace ts {
|
||||
return comments;
|
||||
}
|
||||
|
||||
function parseUnknownTag(atToken: Node, tagName: Identifier) {
|
||||
function parseUnknownTag(atToken: AtToken, tagName: Identifier) {
|
||||
const result = <JSDocTag>createNode(SyntaxKind.JSDocTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
@ -6440,7 +6452,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function parseParamTag(atToken: Node, tagName: Identifier) {
|
||||
function parseParamTag(atToken: AtToken, tagName: Identifier) {
|
||||
let typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
|
||||
@ -6491,7 +6503,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag {
|
||||
function parseReturnTag(atToken: AtToken, tagName: Identifier): JSDocReturnTag {
|
||||
if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) {
|
||||
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
|
||||
}
|
||||
@ -6503,7 +6515,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag {
|
||||
function parseTypeTag(atToken: AtToken, tagName: Identifier): JSDocTypeTag {
|
||||
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) {
|
||||
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
|
||||
}
|
||||
@ -6515,7 +6527,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parsePropertyTag(atToken: Node, tagName: Identifier): JSDocPropertyTag {
|
||||
function parsePropertyTag(atToken: AtToken, tagName: Identifier): JSDocPropertyTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
const name = parseJSDocIdentifierName();
|
||||
@ -6533,7 +6545,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseTypedefTag(atToken: Node, tagName: Identifier): JSDocTypedefTag {
|
||||
function parseTypedefTag(atToken: AtToken, tagName: Identifier): JSDocTypedefTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
|
||||
@ -6555,7 +6567,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (!typedefTag.jsDocTypeLiteral) {
|
||||
typedefTag.jsDocTypeLiteral = typeExpression.type;
|
||||
typedefTag.jsDocTypeLiteral = <JSDocTypeLiteral>typeExpression.type;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -6607,7 +6619,7 @@ namespace ts {
|
||||
|
||||
function tryParseChildTag(parentTag: JSDocTypeLiteral): boolean {
|
||||
Debug.assert(token() === SyntaxKind.AtToken);
|
||||
const atToken = createNode(SyntaxKind.AtToken, scanner.getStartPos());
|
||||
const atToken = <AtToken>createNode(SyntaxKind.AtToken, scanner.getStartPos());
|
||||
atToken.end = scanner.getTextPos();
|
||||
nextJSDocToken();
|
||||
|
||||
@ -6637,7 +6649,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag {
|
||||
function parseTemplateTag(atToken: AtToken, tagName: Identifier): JSDocTemplateTag {
|
||||
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTemplateTag)) {
|
||||
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ namespace ts {
|
||||
|
||||
function flattenDestructuring(
|
||||
context: TransformationContext,
|
||||
root: BindingElement | BinaryExpression,
|
||||
root: VariableDeclaration | ParameterDeclaration | BindingElement | BinaryExpression,
|
||||
value: Expression,
|
||||
location: TextRange,
|
||||
emitAssignment: (name: Identifier, value: Expression, location: TextRange, original: Node) => void,
|
||||
@ -320,7 +320,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitBindingElement(target: BindingElement, value: Expression) {
|
||||
function emitBindingElement(target: VariableDeclaration | ParameterDeclaration | BindingElement, value: Expression) {
|
||||
// Any temporary assignments needed to emit target = value should point to target
|
||||
const initializer = visitor ? visitNode(target.initializer, visitor, isExpression) : target.initializer;
|
||||
if (initializer) {
|
||||
|
||||
@ -982,7 +982,7 @@ namespace ts {
|
||||
if (statementOffset < ctorStatements.length) {
|
||||
firstStatement = ctorStatements[statementOffset];
|
||||
|
||||
if (firstStatement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((firstStatement as ExpressionStatement).expression)) {
|
||||
if (firstStatement.kind === SyntaxKind.ExpressionStatement && isSuperCall((firstStatement as ExpressionStatement).expression)) {
|
||||
const superCall = (firstStatement as ExpressionStatement).expression as CallExpression;
|
||||
superCallExpression = setOriginalNode(
|
||||
saveStateAndInvoke(superCall, visitImmediateSuperCallInBody),
|
||||
@ -3197,7 +3197,7 @@ namespace ts {
|
||||
* @param node The declaration.
|
||||
* @param allowComments Allow comments for the name.
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
function getDeclarationName(node: ClassDeclaration | ClassExpression | FunctionDeclaration, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
if (node.name && !isGeneratedIdentifier(node.name)) {
|
||||
const name = getMutableClone(node.name);
|
||||
emitFlags |= getEmitFlags(node.name);
|
||||
|
||||
@ -528,7 +528,7 @@ namespace ts {
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitAccessorDeclaration(node: GetAccessorDeclaration) {
|
||||
function visitAccessorDeclaration(node: AccessorDeclaration) {
|
||||
const savedInGeneratorFunctionBody = inGeneratorFunctionBody;
|
||||
const savedInStatementContainingYield = inStatementContainingYield;
|
||||
inGeneratorFunctionBody = false;
|
||||
@ -660,12 +660,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isCompoundAssignment(kind: SyntaxKind) {
|
||||
function isCompoundAssignment(kind: BinaryOperator): kind is CompoundAssignmentOperator {
|
||||
return kind >= SyntaxKind.FirstCompoundAssignment
|
||||
&& kind <= SyntaxKind.LastCompoundAssignment;
|
||||
}
|
||||
|
||||
function getOperatorForCompoundAssignment(kind: SyntaxKind) {
|
||||
function getOperatorForCompoundAssignment(kind: CompoundAssignmentOperator): BitwiseOperatorOrHigher {
|
||||
switch (kind) {
|
||||
case SyntaxKind.PlusEqualsToken: return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.MinusEqualsToken: return SyntaxKind.MinusToken;
|
||||
|
||||
@ -600,7 +600,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
statements.push(
|
||||
createExportStatement(node.name, setEmitFlags(getSynthesizedClone(node.name), EmitFlags.LocalName), /*location*/ node)
|
||||
createExportStatement(<Identifier>node.name, setEmitFlags(getSynthesizedClone(node.name), EmitFlags.LocalName), /*location*/ node)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -796,7 +796,7 @@ namespace ts {
|
||||
addVarForExportedEnumOrNamespaceDeclaration(statements, original);
|
||||
}
|
||||
|
||||
addExportMemberAssignments(statements, original.name);
|
||||
addExportMemberAssignments(statements, <Identifier>original.name);
|
||||
|
||||
return statements;
|
||||
}
|
||||
@ -819,7 +819,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDeclarationName(node: DeclarationStatement) {
|
||||
return node.name ? getSynthesizedClone(node.name) : getGeneratedNameForNode(node);
|
||||
return node.name ? getSynthesizedClone(<Identifier>node.name) : getGeneratedNameForNode(node);
|
||||
}
|
||||
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void {
|
||||
@ -918,7 +918,7 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.PostfixUnaryExpression) {
|
||||
transformedUnaryExpression = createBinary(
|
||||
operand,
|
||||
createNode(operator === SyntaxKind.PlusPlusToken ? SyntaxKind.PlusEqualsToken : SyntaxKind.MinusEqualsToken),
|
||||
createToken(operator === SyntaxKind.PlusPlusToken ? SyntaxKind.PlusEqualsToken : SyntaxKind.MinusEqualsToken),
|
||||
createLiteral(1),
|
||||
/*location*/ node
|
||||
);
|
||||
|
||||
@ -1201,7 +1201,7 @@ namespace ts {
|
||||
* @param node The declaration statement.
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement) {
|
||||
return node.name ? getSynthesizedClone(node.name) : getGeneratedNameForNode(node);
|
||||
return node.name ? getSynthesizedClone(<Identifier>node.name) : getGeneratedNameForNode(node);
|
||||
}
|
||||
|
||||
function addExportStarFunction(statements: Statement[], localNames: Identifier) {
|
||||
|
||||
@ -989,7 +989,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const statement = statements[index];
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((<ExpressionStatement>statement).expression)) {
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCall((<ExpressionStatement>statement).expression)) {
|
||||
result.push(visitNode(statement, visitor, isStatement));
|
||||
return index + 1;
|
||||
}
|
||||
@ -3098,7 +3098,7 @@ namespace ts {
|
||||
return createStatement(expression, /*location*/ undefined);
|
||||
}
|
||||
|
||||
function addExportMemberAssignment(statements: Statement[], node: DeclarationStatement) {
|
||||
function addExportMemberAssignment(statements: Statement[], node: ClassDeclaration | FunctionDeclaration) {
|
||||
const expression = createAssignment(
|
||||
getExportName(node),
|
||||
getLocalName(node, /*noSourceMaps*/ true)
|
||||
@ -3176,7 +3176,7 @@ namespace ts {
|
||||
* @param noSourceMaps A value indicating whether source maps may not be emitted for the name.
|
||||
* @param allowComments A value indicating whether comments may be emitted for the name.
|
||||
*/
|
||||
function getLocalName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
function getLocalName(node: FunctionDeclaration | ClassDeclaration | ClassExpression | ModuleDeclaration | EnumDeclaration, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
return getDeclarationName(node, allowComments, !noSourceMaps, EmitFlags.LocalName);
|
||||
}
|
||||
|
||||
@ -3190,7 +3190,7 @@ namespace ts {
|
||||
* @param noSourceMaps A value indicating whether source maps may not be emitted for the name.
|
||||
* @param allowComments A value indicating whether comments may be emitted for the name.
|
||||
*/
|
||||
function getExportName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
function getExportName(node: FunctionDeclaration | ClassDeclaration | ClassExpression | ModuleDeclaration | EnumDeclaration, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
if (isNamespaceExport(node)) {
|
||||
return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps);
|
||||
}
|
||||
@ -3206,9 +3206,9 @@ namespace ts {
|
||||
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
||||
* @param emitFlags Additional NodeEmitFlags to specify for the name.
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
function getDeclarationName(node: FunctionDeclaration | ClassDeclaration | ClassExpression | ModuleDeclaration | EnumDeclaration, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
if (node.name) {
|
||||
const name = getMutableClone(node.name);
|
||||
const name = getMutableClone(<Identifier>node.name);
|
||||
emitFlags |= getEmitFlags(node.name);
|
||||
if (!allowSourceMaps) {
|
||||
emitFlags |= EmitFlags.NoSourceMap;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -609,7 +609,7 @@ namespace ts {
|
||||
return !!(getCombinedNodeFlags(node) & NodeFlags.Let);
|
||||
}
|
||||
|
||||
export function isSuperCallExpression(n: Node): boolean {
|
||||
export function isSuperCall(n: Node): n is SuperCall {
|
||||
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).expression.kind === SyntaxKind.SuperKeyword;
|
||||
}
|
||||
|
||||
@ -1047,7 +1047,7 @@ namespace ts {
|
||||
/**
|
||||
* Determines whether a node is a property or element access expression for super.
|
||||
*/
|
||||
export function isSuperProperty(node: Node): node is (PropertyAccessExpression | ElementAccessExpression) {
|
||||
export function isSuperProperty(node: Node): node is SuperProperty {
|
||||
const kind = node.kind;
|
||||
return (kind === SyntaxKind.PropertyAccessExpression || kind === SyntaxKind.ElementAccessExpression)
|
||||
&& (<PropertyAccessExpression | ElementAccessExpression>node).expression.kind === SyntaxKind.SuperKeyword;
|
||||
@ -1375,7 +1375,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) {
|
||||
export function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport {
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
return <ImportEqualsDeclaration>node;
|
||||
}
|
||||
@ -2458,7 +2458,7 @@ namespace ts {
|
||||
return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
|
||||
}
|
||||
|
||||
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): string {
|
||||
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string {
|
||||
const file = resolver.getExternalModuleFileFromDeclaration(declaration);
|
||||
if (!file || isDeclarationFile(file)) {
|
||||
return undefined;
|
||||
@ -3625,14 +3625,14 @@ namespace ts {
|
||||
return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken;
|
||||
}
|
||||
|
||||
function isTemplateLiteralFragmentKind(kind: SyntaxKind) {
|
||||
return kind === SyntaxKind.TemplateHead
|
||||
|| kind === SyntaxKind.TemplateMiddle
|
||||
|| kind === SyntaxKind.TemplateTail;
|
||||
export function isTemplateHead(node: Node): node is TemplateHead {
|
||||
return node.kind === SyntaxKind.TemplateHead;
|
||||
}
|
||||
|
||||
export function isTemplateLiteralFragment(node: Node): node is TemplateLiteralFragment {
|
||||
return isTemplateLiteralFragmentKind(node.kind);
|
||||
export function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.TemplateMiddle
|
||||
|| kind === SyntaxKind.TemplateTail;
|
||||
}
|
||||
|
||||
// Identifiers
|
||||
@ -3797,7 +3797,7 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.CallExpression;
|
||||
}
|
||||
|
||||
export function isTemplate(node: Node): node is Template {
|
||||
export function isTemplateLiteral(node: Node): node is TemplateLiteral {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.TemplateExpression
|
||||
|| kind === SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
|
||||
@ -799,7 +799,7 @@ namespace ts {
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
return updateTaggedTemplate(<TaggedTemplateExpression>node,
|
||||
visitNode((<TaggedTemplateExpression>node).tag, visitor, isExpression),
|
||||
visitNode((<TaggedTemplateExpression>node).template, visitor, isTemplate));
|
||||
visitNode((<TaggedTemplateExpression>node).template, visitor, isTemplateLiteral));
|
||||
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return updateParen(<ParenthesizedExpression>node,
|
||||
@ -862,7 +862,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.TemplateExpression:
|
||||
return updateTemplateExpression(<TemplateExpression>node,
|
||||
visitNode((<TemplateExpression>node).head, visitor, isTemplateLiteralFragment),
|
||||
visitNode((<TemplateExpression>node).head, visitor, isTemplateHead),
|
||||
visitNodes((<TemplateExpression>node).templateSpans, visitor, isTemplateSpan));
|
||||
|
||||
case SyntaxKind.YieldExpression:
|
||||
@ -890,7 +890,7 @@ namespace ts {
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return updateTemplateSpan(<TemplateSpan>node,
|
||||
visitNode((<TemplateSpan>node).expression, visitor, isExpression),
|
||||
visitNode((<TemplateSpan>node).literal, visitor, isTemplateLiteralFragment));
|
||||
visitNode((<TemplateSpan>node).literal, visitor, isTemplateMiddleOrTemplateTail));
|
||||
|
||||
// Element
|
||||
case SyntaxKind.Block:
|
||||
|
||||
@ -171,12 +171,16 @@ namespace ts.server {
|
||||
return this.host.fileExists(path);
|
||||
}
|
||||
|
||||
readFile(fileName: string): string {
|
||||
return this.host.readFile(fileName);
|
||||
}
|
||||
|
||||
directoryExists(path: string): boolean {
|
||||
return this.host.directoryExists(path);
|
||||
}
|
||||
|
||||
readFile(fileName: string): string {
|
||||
return this.host.readFile(fileName);
|
||||
readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] {
|
||||
return this.host.readDirectory(path, extensions, exclude, include);
|
||||
}
|
||||
|
||||
getDirectories(path: string): string[] {
|
||||
|
||||
@ -324,15 +324,28 @@ namespace ts.Completions {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
|
||||
*/
|
||||
function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] {
|
||||
if (fragment === undefined) {
|
||||
fragment = "";
|
||||
}
|
||||
|
||||
fragment = normalizeSlashes(fragment);
|
||||
|
||||
/**
|
||||
* Remove the basename from the path. Note that we don't use the basename to filter completions;
|
||||
* the client is responsible for refining completions.
|
||||
*/
|
||||
fragment = getDirectoryPath(fragment);
|
||||
if (!fragment) {
|
||||
fragment = "./";
|
||||
}
|
||||
else {
|
||||
fragment = ensureTrailingDirectorySeparator(fragment);
|
||||
|
||||
if (fragment === "") {
|
||||
fragment = "." + directorySeparator;
|
||||
}
|
||||
|
||||
fragment = ensureTrailingDirectorySeparator(fragment);
|
||||
|
||||
const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment));
|
||||
const baseDirectory = getDirectoryPath(absolutePath);
|
||||
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
||||
@ -342,6 +355,12 @@ namespace ts.Completions {
|
||||
const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]);
|
||||
|
||||
if (files) {
|
||||
/**
|
||||
* Multiple file entries might map to the same truncated name once we remove extensions
|
||||
* (happens iff includeExtensions === false)so we use a set-like data structure. Eg:
|
||||
*
|
||||
* both foo.ts and foo.tsx become foo
|
||||
*/
|
||||
const foundFiles = new StringSet();
|
||||
for (let filePath of files) {
|
||||
filePath = normalizePath(filePath);
|
||||
@ -538,36 +557,44 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const completionInfo: CompletionInfo = {
|
||||
/**
|
||||
* We don't want the editor to offer any other completions, such as snippets, inside a comment.
|
||||
*/
|
||||
isGlobalCompletion: false,
|
||||
isMemberCompletion: false,
|
||||
/**
|
||||
* The user may type in a path that doesn't yet exist, creating a "new identifier"
|
||||
* with respect to the collection of identifiers the server is aware of.
|
||||
*/
|
||||
isNewIdentifierLocation: true,
|
||||
|
||||
entries: []
|
||||
};
|
||||
|
||||
const text = sourceFile.text.substr(range.pos, position - range.pos);
|
||||
|
||||
const match = tripleSlashDirectiveFragmentRegex.exec(text);
|
||||
|
||||
if (match) {
|
||||
const prefix = match[1];
|
||||
const kind = match[2];
|
||||
const toComplete = match[3];
|
||||
|
||||
const scriptPath = getDirectoryPath(sourceFile.path);
|
||||
let entries: CompletionEntry[];
|
||||
if (kind === "path") {
|
||||
// Give completions for a relative path
|
||||
const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length);
|
||||
entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, sourceFile.path);
|
||||
completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, sourceFile.path);
|
||||
}
|
||||
else {
|
||||
// Give completions based on the typings available
|
||||
const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length };
|
||||
entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span);
|
||||
completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span);
|
||||
}
|
||||
|
||||
return {
|
||||
isGlobalCompletion: false,
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: true,
|
||||
entries
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return completionInfo;
|
||||
}
|
||||
|
||||
function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] {
|
||||
@ -1673,9 +1700,15 @@ namespace ts.Completions {
|
||||
* Matches a triple slash reference directive with an incomplete string literal for its path. Used
|
||||
* to determine if the caret is currently within the string literal and capture the literal fragment
|
||||
* for completions.
|
||||
* For example, this matches /// <reference path="fragment
|
||||
* For example, this matches
|
||||
*
|
||||
* /// <reference path="fragment
|
||||
*
|
||||
* but not
|
||||
*
|
||||
* /// <reference path="fragment"
|
||||
*/
|
||||
const tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*<reference\s+(path|types)\s*=\s*(?:'|"))([^\3]*)$/;
|
||||
const tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*<reference\s+(path|types)\s*=\s*(?:'|"))([^\3"]*)$/;
|
||||
|
||||
interface VisibleModuleInfo {
|
||||
moduleName: string;
|
||||
|
||||
@ -175,7 +175,7 @@ namespace ts.formatting {
|
||||
return rangeContainsRange((<InterfaceDeclaration>parent).members, node);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
const body = (<ModuleDeclaration>parent).body;
|
||||
return body && body.kind === SyntaxKind.Block && rangeContainsRange((<Block>body).statements, node);
|
||||
return body && body.kind === SyntaxKind.ModuleBlock && rangeContainsRange((<ModuleBlock>body).statements, node);
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
|
||||
@ -332,7 +332,7 @@ namespace ts.formatting {
|
||||
(<CallExpression>node.parent).expression !== node) {
|
||||
|
||||
const fullCallOrNewExpression = (<CallExpression | NewExpression>node.parent).expression;
|
||||
const startingExpression = getStartingExpression(<PropertyAccessExpression | CallExpression | ElementAccessExpression>fullCallOrNewExpression);
|
||||
const startingExpression = getStartingExpression(fullCallOrNewExpression);
|
||||
|
||||
if (fullCallOrNewExpression === startingExpression) {
|
||||
return Value.Unknown;
|
||||
@ -350,15 +350,14 @@ namespace ts.formatting {
|
||||
|
||||
return Value.Unknown;
|
||||
|
||||
function getStartingExpression(node: PropertyAccessExpression | CallExpression | ElementAccessExpression) {
|
||||
function getStartingExpression(node: Expression) {
|
||||
while (true) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
|
||||
node = <PropertyAccessExpression | CallExpression | ElementAccessExpression | PropertyAccessExpression>node.expression;
|
||||
node = (<PropertyAccessExpression | CallExpression | NewExpression | ElementAccessExpression | PropertyAccessExpression>node).expression;
|
||||
break;
|
||||
default:
|
||||
return node;
|
||||
|
||||
@ -29,9 +29,9 @@ namespace ts {
|
||||
/** The version of the language service API */
|
||||
export const servicesVersion = "0.5";
|
||||
|
||||
function createNode(kind: SyntaxKind, pos: number, end: number, parent?: Node): NodeObject | TokenObject | IdentifierObject {
|
||||
function createNode<TKind extends SyntaxKind>(kind: TKind, pos: number, end: number, parent?: Node): NodeObject | TokenObject<TKind> | IdentifierObject {
|
||||
const node = kind >= SyntaxKind.FirstNode ? new NodeObject(kind, pos, end) :
|
||||
kind === SyntaxKind.Identifier ? new IdentifierObject(kind, pos, end) :
|
||||
kind === SyntaxKind.Identifier ? new IdentifierObject(SyntaxKind.Identifier, pos, end) :
|
||||
new TokenObject(kind, pos, end);
|
||||
node.parent = parent;
|
||||
return node;
|
||||
@ -210,14 +210,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
class TokenOrIdentifierObject implements Token {
|
||||
class TokenOrIdentifierObject implements Node {
|
||||
public kind: SyntaxKind;
|
||||
public pos: number;
|
||||
public end: number;
|
||||
public flags: NodeFlags;
|
||||
public parent: Node;
|
||||
public jsDocComments: JSDoc[];
|
||||
public __tokenTag: any;
|
||||
|
||||
constructor(pos: number, end: number) {
|
||||
// Set properties in same order as NodeObject
|
||||
@ -319,16 +318,25 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
class TokenObject extends TokenOrIdentifierObject {
|
||||
public kind: SyntaxKind;
|
||||
constructor(kind: SyntaxKind, pos: number, end: number) {
|
||||
class TokenObject<TKind extends SyntaxKind> extends TokenOrIdentifierObject implements Token<TKind> {
|
||||
public kind: TKind;
|
||||
|
||||
constructor(kind: TKind, pos: number, end: number) {
|
||||
super(pos, end);
|
||||
this.kind = kind;
|
||||
}
|
||||
}
|
||||
|
||||
class IdentifierObject extends TokenOrIdentifierObject {
|
||||
constructor(kind: SyntaxKind, pos: number, end: number) {
|
||||
class IdentifierObject extends TokenOrIdentifierObject implements Identifier {
|
||||
public kind: SyntaxKind.Identifier;
|
||||
public text: string;
|
||||
_primaryExpressionBrand: any;
|
||||
_memberExpressionBrand: any;
|
||||
_leftHandSideExpressionBrand: any;
|
||||
_incrementExpressionBrand: any;
|
||||
_unaryExpressionBrand: any;
|
||||
_expressionBrand: any;
|
||||
constructor(kind: SyntaxKind.Identifier, pos: number, end: number) {
|
||||
super(pos, end);
|
||||
}
|
||||
}
|
||||
@ -424,6 +432,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public kind: SyntaxKind.SourceFile;
|
||||
public _declarationBrand: any;
|
||||
public fileName: string;
|
||||
public path: Path;
|
||||
@ -432,7 +441,7 @@ namespace ts {
|
||||
public lineMap: number[];
|
||||
|
||||
public statements: NodeArray<Statement>;
|
||||
public endOfFileToken: Node;
|
||||
public endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
|
||||
public amdDependencies: { name: string; path: string }[];
|
||||
public moduleName: string;
|
||||
|
||||
@ -114,12 +114,12 @@ namespace ts.SymbolDisplay {
|
||||
}
|
||||
|
||||
// try get the call/construct signature from the type if it matches
|
||||
let callExpression: CallExpression;
|
||||
let callExpression: CallExpression | NewExpression;
|
||||
if (location.kind === SyntaxKind.CallExpression || location.kind === SyntaxKind.NewExpression) {
|
||||
callExpression = <CallExpression>location;
|
||||
callExpression = <CallExpression | NewExpression>location;
|
||||
}
|
||||
else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) {
|
||||
callExpression = <CallExpression>location.parent;
|
||||
callExpression = <CallExpression | NewExpression>location.parent;
|
||||
}
|
||||
|
||||
if (callExpression) {
|
||||
|
||||
@ -505,7 +505,11 @@ namespace ts {
|
||||
export interface CompletionInfo {
|
||||
isGlobalCompletion: boolean;
|
||||
isMemberCompletion: boolean;
|
||||
isNewIdentifierLocation: boolean; // true when the current location also allows for a new identifier
|
||||
|
||||
/**
|
||||
* true when the current location also allows for a new identifier
|
||||
*/
|
||||
isNewIdentifierLocation: boolean;
|
||||
entries: CompletionEntry[];
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(10,11): error TS2304: Cann
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts (2 errors) ====
|
||||
module M {
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
export class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//// [ES5SymbolProperty2.ts]
|
||||
module M {
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
export class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@ -2,7 +2,7 @@ tests/cases/conformance/Symbols/ES5SymbolProperty3.ts(4,6): error TS2471: A comp
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts (1 errors) ====
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//// [ES5SymbolProperty3.ts]
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//// [anyPlusAny1.ts]
|
||||
var x;
|
||||
var x: any;
|
||||
x.name = "hello";
|
||||
var z = x + x;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/anyPlusAny1.ts ===
|
||||
var x;
|
||||
var x: any;
|
||||
>x : Symbol(x, Decl(anyPlusAny1.ts, 0, 3))
|
||||
|
||||
x.name = "hello";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/anyPlusAny1.ts ===
|
||||
var x;
|
||||
var x: any;
|
||||
>x : any
|
||||
|
||||
x.name = "hello";
|
||||
|
||||
@ -10,10 +10,10 @@ var Foo;
|
||||
>Foo : any
|
||||
|
||||
type
|
||||
>type : any
|
||||
>type : undefined
|
||||
|
||||
Foo = string;
|
||||
>Foo = string : any
|
||||
>Foo = string : undefined
|
||||
>Foo : any
|
||||
>string : any
|
||||
>string : undefined
|
||||
|
||||
|
||||
@ -59,9 +59,9 @@ var e = undefined;
|
||||
>undefined : undefined
|
||||
|
||||
x = e;
|
||||
>x = e : any
|
||||
>x = e : undefined
|
||||
>x : any
|
||||
>e : any
|
||||
>e : undefined
|
||||
|
||||
var e2: typeof undefined;
|
||||
>e2 : any
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//// [assignmentLHSIsReference.ts]
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// identifiers: variable and parameter
|
||||
var x1: number;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : Symbol(value, Decl(assignmentLHSIsReference.ts, 0, 3))
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : any
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@ -41,7 +41,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
|
||||
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//// [assignmentLHSIsValue.ts]
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@ -44,7 +44,7 @@ module M {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ module M {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ module M {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ module M {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -9,7 +9,7 @@ async () => {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -14,7 +14,7 @@ async function fAsyncExplicit(): Promise<[number, boolean]> {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -19,7 +19,7 @@ export const b = {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
@ -34,7 +34,7 @@ export const b = {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -30,7 +30,7 @@ async function sample2(x?: number) {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -29,7 +29,7 @@ exports.Task = Task;
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -19,7 +19,7 @@ exports.Task = Task;
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -9,7 +9,7 @@ function g() { }
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -9,7 +9,7 @@ function g() { }
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -20,7 +20,7 @@ async function bar4() {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -24,7 +24,7 @@ async function bar4() {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -16,7 +16,7 @@ async function bar3() {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -22,7 +22,7 @@ async function bar4() {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -39,7 +39,7 @@ for (let x = 0; x < 1; ++x) {
|
||||
}
|
||||
|
||||
switch (x) {
|
||||
>x : any
|
||||
>x : undefined
|
||||
|
||||
case 1:
|
||||
>1 : 1
|
||||
|
||||
@ -40,7 +40,7 @@ for (let x = 0; x < 1; ++x) {
|
||||
}
|
||||
|
||||
switch (x) {
|
||||
>x : any
|
||||
>x : undefined
|
||||
|
||||
case 1:
|
||||
>1 : 1
|
||||
|
||||
@ -12,7 +12,7 @@ async function f() {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -17,7 +17,7 @@ foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b);
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>a + b : any
|
||||
>a : any
|
||||
>a : undefined
|
||||
>b : any
|
||||
|
||||
foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b);
|
||||
@ -26,7 +26,7 @@ foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b);
|
||||
>function () { } : () => void
|
||||
>() => { } : () => void
|
||||
>a + /*e3*/ b : any
|
||||
>a : any
|
||||
>a : undefined
|
||||
>b : any
|
||||
|
||||
foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b));
|
||||
@ -36,7 +36,7 @@ foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b));
|
||||
>() => { } : () => void
|
||||
>(a + b) : any
|
||||
>a + b : any
|
||||
>a : any
|
||||
>a : undefined
|
||||
>b : any
|
||||
|
||||
foo(
|
||||
|
||||
@ -9,12 +9,12 @@ var x1: number;
|
||||
x1 *= value;
|
||||
>x1 *= value : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x1 += value;
|
||||
>x1 += value : any
|
||||
>x1 += value : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
function fn1(x2: number) {
|
||||
>fn1 : (x2: number) => void
|
||||
@ -41,41 +41,41 @@ x3.a *= value;
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x3.a += value;
|
||||
>x3.a += value : any
|
||||
>x3.a += value : number
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x3['a'] *= value;
|
||||
>x3['a'] *= value : number
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x3['a'] += value;
|
||||
>x3['a'] += value : any
|
||||
>x3['a'] += value : number
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
// parentheses, the contained expression is reference
|
||||
(x1) *= value;
|
||||
>(x1) *= value : number
|
||||
>(x1) : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x1) += value;
|
||||
>(x1) += value : any
|
||||
>(x1) += value : number
|
||||
>(x1) : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
function fn2(x4: number) {
|
||||
>fn2 : (x4: number) => void
|
||||
@ -100,15 +100,15 @@ function fn2(x4: number) {
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x3.a) += value;
|
||||
>(x3.a) += value : any
|
||||
>(x3.a) += value : number
|
||||
>(x3.a) : number
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x3['a']) *= value;
|
||||
>(x3['a']) *= value : number
|
||||
@ -116,13 +116,13 @@ function fn2(x4: number) {
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x3['a']) += value;
|
||||
>(x3['a']) += value : any
|
||||
>(x3['a']) += value : number
|
||||
>(x3['a']) : number
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ====
|
||||
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//// [compoundAssignmentLHSIsValue.ts]
|
||||
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//// [compoundExponentiationAssignmentLHSIsReference.ts]
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// identifiers: variable and parameter
|
||||
var x1: number;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsReference.ts, 0, 3))
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : any
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@ -40,7 +40,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
|
||||
|
||||
==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (38 errors) ====
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//// [compoundExponentiationAssignmentLHSIsValue.ts]
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@ -35,20 +35,20 @@ var a;
|
||||
>a : any
|
||||
|
||||
foo(a);
|
||||
>foo(a) : any
|
||||
>foo(a) : undefined
|
||||
>foo : <T extends String>(x: T) => T
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
foo2(a);
|
||||
>foo2(a) : any
|
||||
>foo2(a) : undefined
|
||||
>foo2 : <T extends { x: number; }>(x: T) => T
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
//foo3(a);
|
||||
foo4(a);
|
||||
>foo4(a) : any
|
||||
>foo4(a) : undefined
|
||||
>foo4 : <T extends <T>(x: T) => void>(x: T) => T
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var b: number;
|
||||
>b : number
|
||||
@ -84,10 +84,10 @@ class C<T extends String> {
|
||||
}
|
||||
|
||||
var c1 = new C(a);
|
||||
>c1 : C<any>
|
||||
>new C(a) : C<any>
|
||||
>c1 : C<undefined>
|
||||
>new C(a) : C<undefined>
|
||||
>C : typeof C
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var c2 = new C<any>(b);
|
||||
>c2 : C<any>
|
||||
@ -106,10 +106,10 @@ class C2<T extends { x: number }> {
|
||||
}
|
||||
|
||||
var c3 = new C2(a);
|
||||
>c3 : C2<any>
|
||||
>new C2(a) : C2<any>
|
||||
>c3 : C2<undefined>
|
||||
>new C2(a) : C2<undefined>
|
||||
>C2 : typeof C2
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var c4 = new C2<any>(b);
|
||||
>c4 : C2<any>
|
||||
@ -138,10 +138,10 @@ class C4<T extends <T>(x:T) => T> {
|
||||
}
|
||||
|
||||
var c7 = new C4(a);
|
||||
>c7 : C4<any>
|
||||
>new C4(a) : C4<any>
|
||||
>c7 : C4<undefined>
|
||||
>new C4(a) : C4<undefined>
|
||||
>C4 : typeof C4
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var c8 = new C4<any>(b);
|
||||
>c8 : C4<any>
|
||||
|
||||
128
tests/baselines/reference/controlFlowCaching.errors.txt
Normal file
128
tests/baselines/reference/controlFlowCaching.errors.txt
Normal file
@ -0,0 +1,128 @@
|
||||
tests/cases/compiler/controlFlowCaching.ts(38,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(38,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(40,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(40,29): error TS2339: Property 'x' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(42,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(42,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(44,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(44,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(46,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(46,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(48,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(48,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(53,5): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(53,14): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(55,14): error TS2678: Type '"start"' is not comparable to type 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(58,14): error TS2678: Type '"end"' is not comparable to type 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(61,14): error TS2678: Type '"middle"' is not comparable to type 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(62,13): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(62,25): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/controlFlowCaching.ts (19 errors) ====
|
||||
|
||||
// Repro for #8401
|
||||
|
||||
function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) {
|
||||
var isRtl = this._isRtl(); // chart mirroring
|
||||
// prepare variable
|
||||
var o = this.opt, ta = this.chart.theme.axis, position = o.position,
|
||||
leftBottom = position !== "rightOrTop", rotation = o.rotation % 360,
|
||||
start, stop, titlePos, titleRotation = 0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign,
|
||||
labelGap = this.chart.theme.axis.tick.labelGap,
|
||||
taFont = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font),
|
||||
taTitleFont = o.titleFont || (ta.title && ta.title.font),
|
||||
taFontColor = o.fontColor || (ta.majorTick && ta.majorTick.fontColor) || (ta.tick && ta.tick.fontColor) || "black",
|
||||
taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black",
|
||||
taTitleGap = (o.titleGap == 0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15,
|
||||
taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis",
|
||||
taMajorTick = this.chart.theme.getTick("major", o),
|
||||
taMinorTick = this.chart.theme.getTick("minor", o),
|
||||
taMicroTick = this.chart.theme.getTick("micro", o),
|
||||
|
||||
taStroke = "stroke" in o ? o.stroke : ta.stroke,
|
||||
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0,
|
||||
cosr = Math.abs(Math.cos(rotation * Math.PI / 180)),
|
||||
sinr = Math.abs(Math.sin(rotation * Math.PI / 180)),
|
||||
tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0;
|
||||
if (rotation < 0) {
|
||||
rotation += 360;
|
||||
}
|
||||
var cachedLabelW = this._getMaxLabelSize();
|
||||
cachedLabelW = cachedLabelW && cachedLabelW.majLabelW;
|
||||
titleOffset = size * cosr + (cachedLabelW || 0) * sinr + labelGap + Math.max(taMajorTick.length > 0 ? taMajorTick.length : 0,
|
||||
taMinorTick.length > 0 ? taMinorTick.length : 0) +
|
||||
tsize + taTitleGap;
|
||||
axisVector = { x: isRtl ? -1 : 1, y: 0 }; // chart mirroring
|
||||
switch (rotation) {
|
||||
default:
|
||||
if (rotation < (90 - centerAnchorLimit)) {
|
||||
labelOffset.y = leftBottom ? size : 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else if (rotation < (90 + centerAnchorLimit)) {
|
||||
labelOffset.x = -size * 0.4;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'never'.
|
||||
} else if (rotation < 180) {
|
||||
labelOffset.y = leftBottom ? 0 : -size;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else if (rotation < (270 - centerAnchorLimit)) {
|
||||
labelOffset.y = leftBottom ? 0 : -size;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else if (rotation < (270 + centerAnchorLimit)) {
|
||||
labelOffset.y = leftBottom ? size * 0.4 : 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else {
|
||||
labelOffset.y = leftBottom ? size : 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
}
|
||||
}
|
||||
|
||||
titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0;
|
||||
titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize);
|
||||
~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
switch (labelAlign) {
|
||||
case "start":
|
||||
~~~~~~~
|
||||
!!! error TS2678: Type '"start"' is not comparable to type 'undefined'.
|
||||
labelAlign = "end";
|
||||
break;
|
||||
case "end":
|
||||
~~~~~
|
||||
!!! error TS2678: Type '"end"' is not comparable to type 'undefined'.
|
||||
labelAlign = "start";
|
||||
break;
|
||||
case "middle":
|
||||
~~~~~~~~
|
||||
!!! error TS2678: Type '"middle"' is not comparable to type 'undefined'.
|
||||
labelOffset.y -= size;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
break;
|
||||
}
|
||||
|
||||
let _ = rotation;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ maybeNumber++;
|
||||
|
||||
if (maybeNumber !== undefined) {
|
||||
>maybeNumber !== undefined : boolean
|
||||
>maybeNumber : number | undefined
|
||||
>maybeNumber : number
|
||||
>undefined : undefined
|
||||
|
||||
maybeNumber++;
|
||||
|
||||
247
tests/baselines/reference/controlFlowLetVar.js
Normal file
247
tests/baselines/reference/controlFlowLetVar.js
Normal file
@ -0,0 +1,247 @@
|
||||
//// [controlFlowLetVar.ts]
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
function f() {
|
||||
const z = x; // any
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
const f = () => {
|
||||
const z = x; // any
|
||||
};
|
||||
}
|
||||
|
||||
//// [controlFlowLetVar.js]
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
function f() {
|
||||
var z = x; // any
|
||||
}
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
var f = function () {
|
||||
var z = x; // any
|
||||
};
|
||||
}
|
||||
263
tests/baselines/reference/controlFlowLetVar.symbols
Normal file
263
tests/baselines/reference/controlFlowLetVar.symbols
Normal file
@ -0,0 +1,263 @@
|
||||
=== tests/cases/compiler/controlFlowLetVar.ts ===
|
||||
|
||||
declare let cond: boolean;
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(controlFlowLetVar.ts, 1, 26))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 12, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(controlFlowLetVar.ts, 13, 1))
|
||||
|
||||
let x = undefined;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 24, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
>f3 : Symbol(f3, Decl(controlFlowLetVar.ts, 25, 1))
|
||||
|
||||
let x = null;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 36, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
>f4 : Symbol(f4, Decl(controlFlowLetVar.ts, 37, 1))
|
||||
|
||||
let x: any;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
}
|
||||
const y = x; // any
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 48, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
>f5 : Symbol(f5, Decl(controlFlowLetVar.ts, 49, 1))
|
||||
|
||||
var x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 60, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
>f6 : Symbol(f6, Decl(controlFlowLetVar.ts, 61, 1))
|
||||
|
||||
var x = undefined;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 72, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
>f7 : Symbol(f7, Decl(controlFlowLetVar.ts, 73, 1))
|
||||
|
||||
var x = null;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 84, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
>f8 : Symbol(f8, Decl(controlFlowLetVar.ts, 85, 1))
|
||||
|
||||
var x: any;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
}
|
||||
const y = x; // any
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 96, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
>f9 : Symbol(f9, Decl(controlFlowLetVar.ts, 97, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 108, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
|
||||
function f() {
|
||||
>f : Symbol(f, Decl(controlFlowLetVar.ts, 108, 16))
|
||||
|
||||
const z = x; // any
|
||||
>z : Symbol(z, Decl(controlFlowLetVar.ts, 110, 13))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
>f10 : Symbol(f10, Decl(controlFlowLetVar.ts, 112, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 123, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
|
||||
const f = () => {
|
||||
>f : Symbol(f, Decl(controlFlowLetVar.ts, 124, 9))
|
||||
|
||||
const z = x; // any
|
||||
>z : Symbol(z, Decl(controlFlowLetVar.ts, 125, 13))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
|
||||
};
|
||||
}
|
||||
306
tests/baselines/reference/controlFlowLetVar.types
Normal file
306
tests/baselines/reference/controlFlowLetVar.types
Normal file
@ -0,0 +1,306 @@
|
||||
=== tests/cases/compiler/controlFlowLetVar.ts ===
|
||||
|
||||
declare let cond: boolean;
|
||||
>cond : boolean
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
let x = undefined;
|
||||
>x : any
|
||||
>undefined : undefined
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
>f3 : () => void
|
||||
|
||||
let x = null;
|
||||
>x : any
|
||||
>null : null
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : string | number | null
|
||||
>x : string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
>f4 : () => void
|
||||
|
||||
let x: any;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // any
|
||||
>y : any
|
||||
>x : any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
>f5 : () => void
|
||||
|
||||
var x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
>f6 : () => void
|
||||
|
||||
var x = undefined;
|
||||
>x : any
|
||||
>undefined : undefined
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
>f7 : () => void
|
||||
|
||||
var x = null;
|
||||
>x : any
|
||||
>null : null
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : string | number | null
|
||||
>x : string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
>f8 : () => void
|
||||
|
||||
var x: any;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // any
|
||||
>y : any
|
||||
>x : any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
>f9 : () => void
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
|
||||
function f() {
|
||||
>f : () => void
|
||||
|
||||
const z = x; // any
|
||||
>z : any
|
||||
>x : any
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
>f10 : () => void
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
|
||||
const f = () => {
|
||||
>f : () => void
|
||||
>() => { const z = x; // any } : () => void
|
||||
|
||||
const z = x; // any
|
||||
>z : any
|
||||
>x : any
|
||||
|
||||
};
|
||||
}
|
||||
143
tests/baselines/reference/controlFlowNoImplicitAny.errors.txt
Normal file
143
tests/baselines/reference/controlFlowNoImplicitAny.errors.txt
Normal file
@ -0,0 +1,143 @@
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(102,9): error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(111,19): error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(117,9): error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(126,19): error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/controlFlowNoImplicitAny.ts (4 errors) ====
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
let x;
|
||||
~
|
||||
!!! error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
function f() {
|
||||
const z = x; // any
|
||||
~
|
||||
!!! error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
let x;
|
||||
~
|
||||
!!! error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
const f = () => {
|
||||
const z = x; // any
|
||||
~
|
||||
!!! error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
};
|
||||
}
|
||||
247
tests/baselines/reference/controlFlowNoImplicitAny.js
Normal file
247
tests/baselines/reference/controlFlowNoImplicitAny.js
Normal file
@ -0,0 +1,247 @@
|
||||
//// [controlFlowNoImplicitAny.ts]
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
function f() {
|
||||
const z = x; // any
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
const f = () => {
|
||||
const z = x; // any
|
||||
};
|
||||
}
|
||||
|
||||
//// [controlFlowNoImplicitAny.js]
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
function f() {
|
||||
var z = x; // any
|
||||
}
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
var f = function () {
|
||||
var z = x; // any
|
||||
};
|
||||
}
|
||||
@ -27,7 +27,7 @@ export async function runSampleBreaks<A, B, C, D, E>(
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -25,7 +25,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// -- operator on any type
|
||||
|
||||
var ANY: any;
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
var ANY2: any[] = ["", ""];
|
||||
var obj = {x:1,y:null};
|
||||
class A {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
var ANY: any;
|
||||
>ANY : Symbol(ANY, Decl(decrementOperatorWithAnyOtherType.ts, 2, 3))
|
||||
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
>ANY1 : Symbol(ANY1, Decl(decrementOperatorWithAnyOtherType.ts, 3, 3))
|
||||
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
var ANY: any;
|
||||
>ANY : any
|
||||
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
>ANY1 : any
|
||||
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
@ -52,7 +52,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (50 errors) ====
|
||||
// -- operator on any type
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
var obj: () => {}
|
||||
@ -63,7 +63,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
}
|
||||
class A {
|
||||
public a: any;
|
||||
static foo() {
|
||||
static foo(): any {
|
||||
var a;
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//// [decrementOperatorWithAnyOtherTypeInvalidOperations.ts]
|
||||
// -- operator on any type
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
var obj: () => {}
|
||||
@ -11,7 +11,7 @@ function foo(): any {
|
||||
}
|
||||
class A {
|
||||
public a: any;
|
||||
static foo() {
|
||||
static foo(): any {
|
||||
var a;
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ import x from './a';
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -22,7 +22,7 @@ exports.default = x;
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -77,22 +77,22 @@ use(x);
|
||||
use(z0);
|
||||
>use(z0) : any
|
||||
>use : (a: any) => any
|
||||
>z0 : any
|
||||
>z0 : undefined
|
||||
|
||||
use(z1);
|
||||
>use(z1) : any
|
||||
>use : (a: any) => any
|
||||
>z1 : any
|
||||
>z1 : undefined
|
||||
|
||||
use(z2);
|
||||
>use(z2) : any
|
||||
>use : (a: any) => any
|
||||
>z2 : any
|
||||
>z2 : undefined
|
||||
|
||||
use(z3);
|
||||
>use(z3) : any
|
||||
>use : (a: any) => any
|
||||
>z3 : any
|
||||
>z3 : undefined
|
||||
|
||||
var z6;
|
||||
>z6 : any
|
||||
@ -149,7 +149,7 @@ use(y);
|
||||
use(z6);
|
||||
>use(z6) : any
|
||||
>use : (a: any) => any
|
||||
>z6 : any
|
||||
>z6 : undefined
|
||||
|
||||
var z = false;
|
||||
>z : boolean
|
||||
|
||||
@ -83,22 +83,22 @@ use(x);
|
||||
use(z0);
|
||||
>use(z0) : any
|
||||
>use : (a: any) => any
|
||||
>z0 : any
|
||||
>z0 : undefined
|
||||
|
||||
use(z1);
|
||||
>use(z1) : any
|
||||
>use : (a: any) => any
|
||||
>z1 : any
|
||||
>z1 : undefined
|
||||
|
||||
use(z2);
|
||||
>use(z2) : any
|
||||
>use : (a: any) => any
|
||||
>z2 : any
|
||||
>z2 : undefined
|
||||
|
||||
use(z3);
|
||||
>use(z3) : any
|
||||
>use : (a: any) => any
|
||||
>z3 : any
|
||||
>z3 : undefined
|
||||
|
||||
var z6;
|
||||
>z6 : any
|
||||
@ -155,7 +155,7 @@ use(y);
|
||||
use(z6);
|
||||
>use(z6) : any
|
||||
>use : (a: any) => any
|
||||
>z6 : any
|
||||
>z6 : undefined
|
||||
|
||||
var z = false;
|
||||
>z : boolean
|
||||
|
||||
@ -12,7 +12,7 @@ async function singleAwait() {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
//// [es5-asyncFunctionTryStatements.ts]
|
||||
declare var x, y, z, a, b, c;
|
||||
declare var x: any, y: any, z: any, a: any, b: any, c: any;
|
||||
|
||||
async function tryCatch0() {
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
try {
|
||||
x;
|
||||
}
|
||||
@ -12,7 +12,7 @@ async function tryCatch0() {
|
||||
}
|
||||
|
||||
async function tryCatch1() {
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
try {
|
||||
await x;
|
||||
}
|
||||
@ -22,7 +22,7 @@ async function tryCatch1() {
|
||||
}
|
||||
|
||||
async function tryCatch2() {
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
try {
|
||||
x;
|
||||
}
|
||||
@ -32,7 +32,7 @@ async function tryCatch2() {
|
||||
}
|
||||
|
||||
async function tryCatch3(): Promise<Function> {
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
try {
|
||||
await x;
|
||||
}
|
||||
@ -41,7 +41,7 @@ async function tryCatch3(): Promise<Function> {
|
||||
}
|
||||
}
|
||||
async function tryFinally0() {
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
try {
|
||||
x;
|
||||
}
|
||||
@ -51,7 +51,7 @@ async function tryFinally0() {
|
||||
}
|
||||
|
||||
async function tryFinally1() {
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
try {
|
||||
await x;
|
||||
}
|
||||
@ -61,7 +61,7 @@ async function tryFinally1() {
|
||||
}
|
||||
|
||||
async function tryFinally2() {
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
try {
|
||||
x;
|
||||
}
|
||||
@ -71,7 +71,7 @@ async function tryFinally2() {
|
||||
}
|
||||
|
||||
async function tryCatchFinally0() {
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
try {
|
||||
x;
|
||||
}
|
||||
@ -84,7 +84,7 @@ async function tryCatchFinally0() {
|
||||
}
|
||||
|
||||
async function tryCatchFinally1() {
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
try {
|
||||
await x;
|
||||
}
|
||||
@ -97,7 +97,7 @@ async function tryCatchFinally1() {
|
||||
}
|
||||
|
||||
async function tryCatchFinally2() {
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
try {
|
||||
x;
|
||||
}
|
||||
@ -110,7 +110,7 @@ async function tryCatchFinally2() {
|
||||
}
|
||||
|
||||
async function tryCatchFinally3() {
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
try {
|
||||
x;
|
||||
}
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
=== tests/cases/compiler/es5-asyncFunctionTryStatements.ts ===
|
||||
declare var x, y, z, a, b, c;
|
||||
declare var x: any, y: any, z: any, a: any, b: any, c: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 0, 11))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 0, 14))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 0, 17))
|
||||
>a : Symbol(a, Decl(es5-asyncFunctionTryStatements.ts, 0, 20))
|
||||
>b : Symbol(b, Decl(es5-asyncFunctionTryStatements.ts, 0, 23))
|
||||
>c : Symbol(c, Decl(es5-asyncFunctionTryStatements.ts, 0, 26))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 0, 19))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 0, 27))
|
||||
>a : Symbol(a, Decl(es5-asyncFunctionTryStatements.ts, 0, 35))
|
||||
>b : Symbol(b, Decl(es5-asyncFunctionTryStatements.ts, 0, 43))
|
||||
>c : Symbol(c, Decl(es5-asyncFunctionTryStatements.ts, 0, 51))
|
||||
|
||||
async function tryCatch0() {
|
||||
>tryCatch0 : Symbol(tryCatch0, Decl(es5-asyncFunctionTryStatements.ts, 0, 29))
|
||||
>tryCatch0 : Symbol(tryCatch0, Decl(es5-asyncFunctionTryStatements.ts, 0, 59))
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 3, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 3, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 3, 15))
|
||||
|
||||
try {
|
||||
x;
|
||||
@ -22,16 +22,16 @@ async function tryCatch0() {
|
||||
>e : Symbol(e, Decl(es5-asyncFunctionTryStatements.ts, 7, 11))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 3, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 3, 15))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryCatch1() {
|
||||
>tryCatch1 : Symbol(tryCatch1, Decl(es5-asyncFunctionTryStatements.ts, 10, 1))
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 13, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 13, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 13, 15))
|
||||
|
||||
try {
|
||||
await x;
|
||||
@ -41,16 +41,16 @@ async function tryCatch1() {
|
||||
>e : Symbol(e, Decl(es5-asyncFunctionTryStatements.ts, 17, 11))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 13, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 13, 15))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryCatch2() {
|
||||
>tryCatch2 : Symbol(tryCatch2, Decl(es5-asyncFunctionTryStatements.ts, 20, 1))
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 23, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 23, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 23, 15))
|
||||
|
||||
try {
|
||||
x;
|
||||
@ -60,7 +60,7 @@ async function tryCatch2() {
|
||||
>e : Symbol(e, Decl(es5-asyncFunctionTryStatements.ts, 27, 11))
|
||||
|
||||
await y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 23, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 23, 15))
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,9 +69,9 @@ async function tryCatch3(): Promise<Function> {
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 33, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 33, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 33, 15))
|
||||
|
||||
try {
|
||||
await x;
|
||||
@ -87,9 +87,9 @@ async function tryCatch3(): Promise<Function> {
|
||||
async function tryFinally0() {
|
||||
>tryFinally0 : Symbol(tryFinally0, Decl(es5-asyncFunctionTryStatements.ts, 40, 1))
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 42, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 42, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 42, 15))
|
||||
|
||||
try {
|
||||
x;
|
||||
@ -97,16 +97,16 @@ async function tryFinally0() {
|
||||
}
|
||||
finally {
|
||||
y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 42, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 42, 15))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryFinally1() {
|
||||
>tryFinally1 : Symbol(tryFinally1, Decl(es5-asyncFunctionTryStatements.ts, 49, 1))
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 52, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 52, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 52, 15))
|
||||
|
||||
try {
|
||||
await x;
|
||||
@ -114,16 +114,16 @@ async function tryFinally1() {
|
||||
}
|
||||
finally {
|
||||
y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 52, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 52, 15))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryFinally2() {
|
||||
>tryFinally2 : Symbol(tryFinally2, Decl(es5-asyncFunctionTryStatements.ts, 59, 1))
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 62, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 62, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 62, 15))
|
||||
|
||||
try {
|
||||
x;
|
||||
@ -131,17 +131,17 @@ async function tryFinally2() {
|
||||
}
|
||||
finally {
|
||||
await y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 62, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 62, 15))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryCatchFinally0() {
|
||||
>tryCatchFinally0 : Symbol(tryCatchFinally0, Decl(es5-asyncFunctionTryStatements.ts, 69, 1))
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 72, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 72, 10))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 72, 13))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 72, 15))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 72, 23))
|
||||
|
||||
try {
|
||||
x;
|
||||
@ -151,21 +151,21 @@ async function tryCatchFinally0() {
|
||||
>e : Symbol(e, Decl(es5-asyncFunctionTryStatements.ts, 76, 11))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 72, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 72, 15))
|
||||
}
|
||||
finally {
|
||||
z;
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 72, 13))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 72, 23))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryCatchFinally1() {
|
||||
>tryCatchFinally1 : Symbol(tryCatchFinally1, Decl(es5-asyncFunctionTryStatements.ts, 82, 1))
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 85, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 85, 10))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 85, 13))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 85, 15))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 85, 23))
|
||||
|
||||
try {
|
||||
await x;
|
||||
@ -175,21 +175,21 @@ async function tryCatchFinally1() {
|
||||
>e : Symbol(e, Decl(es5-asyncFunctionTryStatements.ts, 89, 11))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 85, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 85, 15))
|
||||
}
|
||||
finally {
|
||||
z;
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 85, 13))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 85, 23))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryCatchFinally2() {
|
||||
>tryCatchFinally2 : Symbol(tryCatchFinally2, Decl(es5-asyncFunctionTryStatements.ts, 95, 1))
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 98, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 98, 10))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 98, 13))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 98, 15))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 98, 23))
|
||||
|
||||
try {
|
||||
x;
|
||||
@ -199,21 +199,21 @@ async function tryCatchFinally2() {
|
||||
>e : Symbol(e, Decl(es5-asyncFunctionTryStatements.ts, 102, 11))
|
||||
|
||||
await y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 98, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 98, 15))
|
||||
}
|
||||
finally {
|
||||
z;
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 98, 13))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 98, 23))
|
||||
}
|
||||
}
|
||||
|
||||
async function tryCatchFinally3() {
|
||||
>tryCatchFinally3 : Symbol(tryCatchFinally3, Decl(es5-asyncFunctionTryStatements.ts, 108, 1))
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : Symbol(x, Decl(es5-asyncFunctionTryStatements.ts, 111, 7))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 111, 10))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 111, 13))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 111, 15))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 111, 23))
|
||||
|
||||
try {
|
||||
x;
|
||||
@ -223,10 +223,10 @@ async function tryCatchFinally3() {
|
||||
>e : Symbol(e, Decl(es5-asyncFunctionTryStatements.ts, 115, 11))
|
||||
|
||||
y;
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 111, 10))
|
||||
>y : Symbol(y, Decl(es5-asyncFunctionTryStatements.ts, 111, 15))
|
||||
}
|
||||
finally {
|
||||
await z;
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 111, 13))
|
||||
>z : Symbol(z, Decl(es5-asyncFunctionTryStatements.ts, 111, 23))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/es5-asyncFunctionTryStatements.ts ===
|
||||
declare var x, y, z, a, b, c;
|
||||
declare var x: any, y: any, z: any, a: any, b: any, c: any;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
@ -10,7 +10,7 @@ declare var x, y, z, a, b, c;
|
||||
async function tryCatch0() {
|
||||
>tryCatch0 : () => Promise<void>
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@ -29,7 +29,7 @@ async function tryCatch0() {
|
||||
async function tryCatch1() {
|
||||
>tryCatch1 : () => Promise<void>
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@ -49,7 +49,7 @@ async function tryCatch1() {
|
||||
async function tryCatch2() {
|
||||
>tryCatch2 : () => Promise<void>
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@ -71,7 +71,7 @@ async function tryCatch3(): Promise<Function> {
|
||||
>Promise : Promise<T>
|
||||
>Function : Function
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@ -91,7 +91,7 @@ async function tryCatch3(): Promise<Function> {
|
||||
async function tryFinally0() {
|
||||
>tryFinally0 : () => Promise<void>
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@ -108,7 +108,7 @@ async function tryFinally0() {
|
||||
async function tryFinally1() {
|
||||
>tryFinally1 : () => Promise<void>
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@ -126,7 +126,7 @@ async function tryFinally1() {
|
||||
async function tryFinally2() {
|
||||
>tryFinally2 : () => Promise<void>
|
||||
|
||||
var x, y;
|
||||
var x: any, y: any;
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@ -144,7 +144,7 @@ async function tryFinally2() {
|
||||
async function tryCatchFinally0() {
|
||||
>tryCatchFinally0 : () => Promise<void>
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
@ -168,7 +168,7 @@ async function tryCatchFinally0() {
|
||||
async function tryCatchFinally1() {
|
||||
>tryCatchFinally1 : () => Promise<void>
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
@ -193,7 +193,7 @@ async function tryCatchFinally1() {
|
||||
async function tryCatchFinally2() {
|
||||
>tryCatchFinally2 : () => Promise<void>
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
@ -218,7 +218,7 @@ async function tryCatchFinally2() {
|
||||
async function tryCatchFinally3() {
|
||||
>tryCatchFinally3 : () => Promise<void>
|
||||
|
||||
var x, y, z;
|
||||
var x: any, y: any, z: any;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
|
||||
@ -32,7 +32,7 @@ exports.foo = foo;
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -84,7 +84,7 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE
|
||||
==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (81 errors) ====
|
||||
|
||||
// Error: early syntax error using ES7 SimpleUnaryExpression on left-hand side without ()
|
||||
var temp;
|
||||
var temp: any;
|
||||
|
||||
delete --temp ** 3;
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//// [exponentiationOperatorSyntaxError2.ts]
|
||||
|
||||
// Error: early syntax error using ES7 SimpleUnaryExpression on left-hand side without ()
|
||||
var temp;
|
||||
var temp: any;
|
||||
|
||||
delete --temp ** 3;
|
||||
delete ++temp ** 3;
|
||||
|
||||
@ -7,7 +7,7 @@ foo();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -38,7 +38,7 @@ export default async(() => await(Promise.resolve(1)));
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
|
||||
@ -78,7 +78,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari
|
||||
}
|
||||
|
||||
function f() {
|
||||
var a;
|
||||
var a: any;
|
||||
var n=3;
|
||||
var s="";
|
||||
var b=false;
|
||||
|
||||
@ -7,7 +7,7 @@ enum E {
|
||||
}
|
||||
|
||||
function f() {
|
||||
var a;
|
||||
var a: any;
|
||||
var n=3;
|
||||
var s="";
|
||||
var b=false;
|
||||
|
||||
@ -18,7 +18,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15):
|
||||
for (var x in /[a-z]/) { }
|
||||
for (var x in new Date()) { }
|
||||
|
||||
var c, d, e;
|
||||
var c: any, d: any, e: any;
|
||||
|
||||
for (var x in c || d) { }
|
||||
for (var x in e ? c : d) { }
|
||||
|
||||
@ -15,7 +15,7 @@ for (var x in fn()) { }
|
||||
for (var x in /[a-z]/) { }
|
||||
for (var x in new Date()) { }
|
||||
|
||||
var c, d, e;
|
||||
var c: any, d: any, e: any;
|
||||
|
||||
for (var x in c || d) { }
|
||||
for (var x in e ? c : d) { }
|
||||
|
||||
@ -2,7 +2,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2487: Inva
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/for-ofStatements/for-of3.ts (1 errors) ====
|
||||
var v;
|
||||
var v: any;
|
||||
for (v++ of []) { }
|
||||
~~~
|
||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user