mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'origin/master' into portLibFiles731
This commit is contained in:
+194
-167
@@ -4993,86 +4993,87 @@ namespace ts {
|
||||
|
||||
function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
// Handle prototype property
|
||||
if (symbol.flags & SymbolFlags.Prototype) {
|
||||
return links.type = getTypeOfPrototypeProperty(symbol);
|
||||
}
|
||||
// CommonsJS require and module both have type any.
|
||||
if (symbol === requireSymbol) {
|
||||
return links.type = anyType;
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.ModuleExports) {
|
||||
const fileSymbol = getSymbolOfNode(getSourceFileOfNode(symbol.valueDeclaration));
|
||||
const members = createSymbolTable();
|
||||
members.set("exports" as __String, fileSymbol);
|
||||
return links.type = createAnonymousType(symbol, members, emptyArray, emptyArray, undefined, undefined);
|
||||
}
|
||||
// Handle catch clause variables
|
||||
const declaration = symbol.valueDeclaration;
|
||||
if (isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
|
||||
return links.type = anyType;
|
||||
}
|
||||
// Handle export default expressions
|
||||
if (isSourceFile(declaration)) {
|
||||
const jsonSourceFile = cast(declaration, isJsonSourceFile);
|
||||
return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType;
|
||||
}
|
||||
if (declaration.kind === SyntaxKind.ExportAssignment) {
|
||||
return links.type = checkExpression((<ExportAssignment>declaration).expression);
|
||||
}
|
||||
// Handle variable, parameter or property
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return errorType;
|
||||
}
|
||||
|
||||
let type = getJSSpecialType(symbol, declaration);
|
||||
if (!type) {
|
||||
if (isJSDocPropertyLikeTag(declaration)
|
||||
|| isPropertyAccessExpression(declaration)
|
||||
|| isIdentifier(declaration)
|
||||
|| isClassDeclaration(declaration)
|
||||
|| isFunctionDeclaration(declaration)
|
||||
|| (isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration))
|
||||
|| isMethodSignature(declaration)) {
|
||||
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
}
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
|
||||
}
|
||||
else if (isPropertyAssignment(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
|
||||
}
|
||||
else if (isJsxAttribute(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
|
||||
}
|
||||
else if (isShorthandPropertyAssignment(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, CheckMode.Normal);
|
||||
}
|
||||
else if (isObjectLiteralMethod(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, CheckMode.Normal);
|
||||
}
|
||||
else if (isParameter(declaration)
|
||||
|| isPropertyDeclaration(declaration)
|
||||
|| isPropertySignature(declaration)
|
||||
|| isVariableDeclaration(declaration)
|
||||
|| isBindingElement(declaration)) {
|
||||
type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
|
||||
}
|
||||
else {
|
||||
return Debug.fail("Unhandled declaration kind! " + Debug.showSyntaxKind(declaration) + " for " + Debug.showSymbol(symbol));
|
||||
}
|
||||
}
|
||||
|
||||
if (!popTypeResolution()) {
|
||||
type = reportCircularityError(symbol);
|
||||
}
|
||||
links.type = type;
|
||||
}
|
||||
return links.type;
|
||||
return links.type || (links.type = getTypeOfVariableOrParameterOrPropertyWorker(symbol));
|
||||
}
|
||||
|
||||
function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol) {
|
||||
// Handle prototype property
|
||||
if (symbol.flags & SymbolFlags.Prototype) {
|
||||
return getTypeOfPrototypeProperty(symbol);
|
||||
}
|
||||
// CommonsJS require and module both have type any.
|
||||
if (symbol === requireSymbol) {
|
||||
return anyType;
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.ModuleExports) {
|
||||
const fileSymbol = getSymbolOfNode(getSourceFileOfNode(symbol.valueDeclaration));
|
||||
const members = createSymbolTable();
|
||||
members.set("exports" as __String, fileSymbol);
|
||||
return createAnonymousType(symbol, members, emptyArray, emptyArray, undefined, undefined);
|
||||
}
|
||||
// Handle catch clause variables
|
||||
const declaration = symbol.valueDeclaration;
|
||||
if (isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
|
||||
return anyType;
|
||||
}
|
||||
// Handle export default expressions
|
||||
if (isSourceFile(declaration)) {
|
||||
const jsonSourceFile = cast(declaration, isJsonSourceFile);
|
||||
return jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType;
|
||||
}
|
||||
if (declaration.kind === SyntaxKind.ExportAssignment) {
|
||||
return checkExpression((<ExportAssignment>declaration).expression);
|
||||
}
|
||||
|
||||
// Handle variable, parameter or property
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return errorType;
|
||||
}
|
||||
let type = getJSSpecialType(symbol, declaration);
|
||||
if (!type) {
|
||||
if (isJSDocPropertyLikeTag(declaration)
|
||||
|| isPropertyAccessExpression(declaration)
|
||||
|| isIdentifier(declaration)
|
||||
|| isClassDeclaration(declaration)
|
||||
|| isFunctionDeclaration(declaration)
|
||||
|| (isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration))
|
||||
|| isMethodSignature(declaration)) {
|
||||
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
}
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
|
||||
}
|
||||
else if (isPropertyAssignment(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
|
||||
}
|
||||
else if (isJsxAttribute(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
|
||||
}
|
||||
else if (isShorthandPropertyAssignment(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, CheckMode.Normal);
|
||||
}
|
||||
else if (isObjectLiteralMethod(declaration)) {
|
||||
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, CheckMode.Normal);
|
||||
}
|
||||
else if (isParameter(declaration)
|
||||
|| isPropertyDeclaration(declaration)
|
||||
|| isPropertySignature(declaration)
|
||||
|| isVariableDeclaration(declaration)
|
||||
|| isBindingElement(declaration)) {
|
||||
type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
|
||||
}
|
||||
else {
|
||||
return Debug.fail("Unhandled declaration kind! " + Debug.showSyntaxKind(declaration) + " for " + Debug.showSymbol(symbol));
|
||||
}
|
||||
}
|
||||
|
||||
if (!popTypeResolution()) {
|
||||
type = reportCircularityError(symbol);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function getJSSpecialType(symbol: Symbol, decl: Declaration): Type | undefined {
|
||||
if (!isInJavaScriptFile(decl)) {
|
||||
return undefined;
|
||||
@@ -5123,20 +5124,25 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getAnnotatedAccessorType(accessor: AccessorDeclaration | undefined): Type | undefined {
|
||||
function getAnnotatedAccessorTypeNode(accessor: AccessorDeclaration | undefined): TypeNode | undefined {
|
||||
if (accessor) {
|
||||
if (accessor.kind === SyntaxKind.GetAccessor) {
|
||||
const getterTypeAnnotation = getEffectiveReturnTypeNode(accessor);
|
||||
return getterTypeAnnotation && getTypeFromTypeNode(getterTypeAnnotation);
|
||||
return getterTypeAnnotation;
|
||||
}
|
||||
else {
|
||||
const setterTypeAnnotation = getEffectiveSetAccessorTypeAnnotationNode(accessor);
|
||||
return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation);
|
||||
return setterTypeAnnotation;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getAnnotatedAccessorType(accessor: AccessorDeclaration | undefined): Type | undefined {
|
||||
const node = getAnnotatedAccessorTypeNode(accessor);
|
||||
return node && getTypeFromTypeNode(node);
|
||||
}
|
||||
|
||||
function getAnnotatedAccessorThisParameter(accessor: AccessorDeclaration): Symbol | undefined {
|
||||
const parameter = getAccessorThisParameter(accessor);
|
||||
return parameter && parameter.symbol;
|
||||
@@ -5148,64 +5154,65 @@ namespace ts {
|
||||
|
||||
function getTypeOfAccessors(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
const getter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.GetAccessor);
|
||||
const setter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.SetAccessor);
|
||||
return links.type || (links.type = getTypeOfAccessorsWorker(symbol));
|
||||
}
|
||||
|
||||
if (getter && isInJavaScriptFile(getter)) {
|
||||
const jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
||||
if (jsDocType) {
|
||||
return links.type = jsDocType;
|
||||
}
|
||||
function getTypeOfAccessorsWorker(symbol: Symbol): Type {
|
||||
const getter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.GetAccessor);
|
||||
const setter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.SetAccessor);
|
||||
|
||||
if (getter && isInJavaScriptFile(getter)) {
|
||||
const jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
||||
if (jsDocType) {
|
||||
return jsDocType;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return errorType;
|
||||
}
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return errorType;
|
||||
}
|
||||
|
||||
let type: Type;
|
||||
let type: Type;
|
||||
|
||||
// First try to see if the user specified a return type on the get-accessor.
|
||||
const getterReturnType = getAnnotatedAccessorType(getter);
|
||||
if (getterReturnType) {
|
||||
type = getterReturnType;
|
||||
// First try to see if the user specified a return type on the get-accessor.
|
||||
const getterReturnType = getAnnotatedAccessorType(getter);
|
||||
if (getterReturnType) {
|
||||
type = getterReturnType;
|
||||
}
|
||||
else {
|
||||
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
||||
const setterParameterType = getAnnotatedAccessorType(setter);
|
||||
if (setterParameterType) {
|
||||
type = setterParameterType;
|
||||
}
|
||||
else {
|
||||
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
||||
const setterParameterType = getAnnotatedAccessorType(setter);
|
||||
if (setterParameterType) {
|
||||
type = setterParameterType;
|
||||
// If there are no specified types, try to infer it from the body of the get accessor if it exists.
|
||||
if (getter && getter.body) {
|
||||
type = getReturnTypeFromBody(getter);
|
||||
}
|
||||
// Otherwise, fall back to 'any'.
|
||||
else {
|
||||
// If there are no specified types, try to infer it from the body of the get accessor if it exists.
|
||||
if (getter && getter.body) {
|
||||
type = getReturnTypeFromBody(getter);
|
||||
}
|
||||
// Otherwise, fall back to 'any'.
|
||||
else {
|
||||
if (noImplicitAny) {
|
||||
if (setter) {
|
||||
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
||||
}
|
||||
else {
|
||||
Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function");
|
||||
error(getter, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
||||
}
|
||||
if (noImplicitAny) {
|
||||
if (setter) {
|
||||
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
||||
}
|
||||
else {
|
||||
Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function");
|
||||
error(getter, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
||||
}
|
||||
type = anyType;
|
||||
}
|
||||
type = anyType;
|
||||
}
|
||||
}
|
||||
if (!popTypeResolution()) {
|
||||
type = anyType;
|
||||
if (noImplicitAny) {
|
||||
const getter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.GetAccessor);
|
||||
error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
|
||||
}
|
||||
}
|
||||
links.type = type;
|
||||
}
|
||||
return links.type;
|
||||
if (!popTypeResolution()) {
|
||||
type = anyType;
|
||||
if (noImplicitAny) {
|
||||
const getter = getDeclarationOfKind<AccessorDeclaration>(symbol, SyntaxKind.GetAccessor);
|
||||
error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function getBaseTypeVariableOfClass(symbol: Symbol) {
|
||||
@@ -5215,6 +5222,7 @@ namespace ts {
|
||||
|
||||
function getTypeOfFuncClassEnumModule(symbol: Symbol): Type {
|
||||
let links = getSymbolLinks(symbol);
|
||||
const originalLinks = links;
|
||||
if (!links.type) {
|
||||
const jsDeclaration = getDeclarationOfJSInitializer(symbol.valueDeclaration);
|
||||
if (jsDeclaration) {
|
||||
@@ -5233,48 +5241,47 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.Module && isShorthandAmbientModuleSymbol(symbol)) {
|
||||
links.type = anyType;
|
||||
}
|
||||
else if (symbol.valueDeclaration.kind === SyntaxKind.BinaryExpression ||
|
||||
symbol.valueDeclaration.kind === SyntaxKind.PropertyAccessExpression && symbol.valueDeclaration.parent.kind === SyntaxKind.BinaryExpression) {
|
||||
links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol);
|
||||
}
|
||||
else {
|
||||
if (symbol.flags & SymbolFlags.ValueModule && symbol.valueDeclaration && isSourceFile(symbol.valueDeclaration) && symbol.valueDeclaration.commonJsModuleIndicator) {
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return errorType;
|
||||
}
|
||||
const resolvedModule = resolveExternalModuleSymbol(symbol);
|
||||
if (resolvedModule !== symbol) {
|
||||
const exportEquals = getMergedSymbol(symbol.exports!.get(InternalSymbolName.ExportEquals)!);
|
||||
links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
||||
}
|
||||
if (!popTypeResolution()) {
|
||||
links.type = reportCircularityError(symbol);
|
||||
}
|
||||
}
|
||||
if (!links.type) {
|
||||
const type = createObjectType(ObjectFlags.Anonymous, symbol);
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
||||
links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
||||
}
|
||||
else {
|
||||
links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? getOptionalType(type) : type;
|
||||
}
|
||||
}
|
||||
}
|
||||
originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol);
|
||||
}
|
||||
return links.type;
|
||||
}
|
||||
|
||||
function getTypeOfFuncClassEnumModuleWorker(symbol: Symbol): Type {
|
||||
const declaration = symbol.valueDeclaration;
|
||||
if (symbol.flags & SymbolFlags.Module && isShorthandAmbientModuleSymbol(symbol)) {
|
||||
return anyType;
|
||||
}
|
||||
else if (declaration.kind === SyntaxKind.BinaryExpression ||
|
||||
declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) {
|
||||
return getWidenedTypeFromJSSpecialPropertyDeclarations(symbol);
|
||||
}
|
||||
else if (symbol.flags & SymbolFlags.ValueModule && declaration && isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
|
||||
const resolvedModule = resolveExternalModuleSymbol(symbol);
|
||||
if (resolvedModule !== symbol) {
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return errorType;
|
||||
}
|
||||
const exportEquals = getMergedSymbol(symbol.exports!.get(InternalSymbolName.ExportEquals)!);
|
||||
const type = getWidenedTypeFromJSSpecialPropertyDeclarations(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
||||
if (!popTypeResolution()) {
|
||||
return reportCircularityError(symbol);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
const type = createObjectType(ObjectFlags.Anonymous, symbol);
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
||||
return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
||||
}
|
||||
else {
|
||||
return strictNullChecks && symbol.flags & SymbolFlags.Optional ? getOptionalType(type) : type;
|
||||
}
|
||||
}
|
||||
|
||||
function getTypeOfEnumMember(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
links.type = getDeclaredTypeOfEnumMember(symbol);
|
||||
}
|
||||
return links.type;
|
||||
return links.type || (links.type = getDeclaredTypeOfEnumMember(symbol));
|
||||
}
|
||||
|
||||
function getTypeOfAlias(symbol: Symbol): Type {
|
||||
@@ -5303,7 +5310,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return errorType;
|
||||
return links.type = errorType;
|
||||
}
|
||||
symbolInstantiationDepth++;
|
||||
let type = instantiateType(getTypeOfSymbol(links.target!), links.mapper!);
|
||||
@@ -15402,8 +15409,8 @@ namespace ts {
|
||||
(!isInParameterInitializerBeforeContainingFunction(node) || getThisParameter(container))) {
|
||||
// Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated.
|
||||
|
||||
// If this is a function in a JS file, it might be a class method. Check if it's the RHS
|
||||
// of a x.prototype.y = function [name]() { .... }
|
||||
// If this is a function in a JS file, it might be a class method.
|
||||
// Check if it's the RHS of a x.prototype.y = function [name]() { .... }
|
||||
if (container.kind === SyntaxKind.FunctionExpression &&
|
||||
container.parent.kind === SyntaxKind.BinaryExpression &&
|
||||
getSpecialPropertyAssignmentKind(container.parent as BinaryExpression) === SpecialPropertyAssignmentKind.PrototypeProperty) {
|
||||
@@ -15417,6 +15424,17 @@ namespace ts {
|
||||
return getFlowTypeOfReference(node, getInferredClassType(classSymbol));
|
||||
}
|
||||
}
|
||||
// Check if it's a constructor definition, can be either a variable decl or function decl
|
||||
// i.e.
|
||||
// * /** @constructor */ function [name]() { ... }
|
||||
// * /** @constructor */ var x = function() { ... }
|
||||
else if ((container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) &&
|
||||
getJSDocClassTag(container)) {
|
||||
const classType = getJavaScriptClassType(container.symbol);
|
||||
if (classType) {
|
||||
return getFlowTypeOfReference(node, classType);
|
||||
}
|
||||
}
|
||||
|
||||
const thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container);
|
||||
if (thisType) {
|
||||
@@ -19495,6 +19513,11 @@ namespace ts {
|
||||
}
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
// If the function is explicitly marked with `@class`, then it must be constructed.
|
||||
if (callSignatures.some(sig => isInJavaScriptFile(sig.declaration) && !!getJSDocClassTag(sig.declaration!))) {
|
||||
error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp);
|
||||
}
|
||||
|
||||
@@ -23501,9 +23524,13 @@ namespace ts {
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
|
||||
const otherAccessor = getDeclarationOfKind<AccessorDeclaration>(getSymbolOfNode(node as AccessorDeclaration), otherKind);
|
||||
markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node as AccessorDeclaration) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
|
||||
break;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
for (const parameter of (<FunctionLikeDeclaration>node).parameters) {
|
||||
markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
|
||||
}
|
||||
@@ -28056,8 +28083,8 @@ namespace ts {
|
||||
const otherAccessor = getDeclarationOfKind<AccessorDeclaration>(getSymbolOfNode(accessor), otherKind);
|
||||
const firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
|
||||
const secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
|
||||
const setAccessor = accessor.kind === SyntaxKind.SetAccessor ? accessor : otherAccessor;
|
||||
const getAccessor = accessor.kind === SyntaxKind.GetAccessor ? accessor : otherAccessor;
|
||||
const setAccessor = accessor.kind === SyntaxKind.SetAccessor ? accessor : otherAccessor as SetAccessorDeclaration;
|
||||
const getAccessor = accessor.kind === SyntaxKind.GetAccessor ? accessor : otherAccessor as GetAccessorDeclaration;
|
||||
return {
|
||||
firstAccessor,
|
||||
secondAccessor,
|
||||
|
||||
@@ -1752,6 +1752,12 @@ namespace ts {
|
||||
type SerializedEntityNameAsExpression = Identifier | BinaryExpression | PropertyAccessExpression;
|
||||
type SerializedTypeNode = SerializedEntityNameAsExpression | VoidExpression | ConditionalExpression;
|
||||
|
||||
function getAccessorTypeNode(node: AccessorDeclaration) {
|
||||
const accessors = resolver.getAllAccessorDeclarations(node);
|
||||
return accessors.setAccessor && getSetAccessorTypeAnnotationNode(accessors.setAccessor)
|
||||
|| accessors.getAccessor && getEffectiveReturnTypeNode(accessors.getAccessor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the type of a node for use with decorator type metadata.
|
||||
*
|
||||
@@ -1761,10 +1767,10 @@ namespace ts {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.GetAccessor:
|
||||
return serializeTypeNode((<PropertyDeclaration | ParameterDeclaration | GetAccessorDeclaration>node).type);
|
||||
case SyntaxKind.SetAccessor:
|
||||
return serializeTypeNode(getSetAccessorTypeAnnotationNode(<SetAccessorDeclaration>node));
|
||||
case SyntaxKind.GetAccessor:
|
||||
return serializeTypeNode(getAccessorTypeNode(node as AccessorDeclaration));
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
|
||||
@@ -3315,8 +3315,8 @@ namespace ts {
|
||||
export interface AllAccessorDeclarations {
|
||||
firstAccessor: AccessorDeclaration;
|
||||
secondAccessor: AccessorDeclaration | undefined;
|
||||
getAccessor: AccessorDeclaration | undefined;
|
||||
setAccessor: AccessorDeclaration | undefined;
|
||||
getAccessor: GetAccessorDeclaration | undefined;
|
||||
setAccessor: SetAccessorDeclaration | undefined;
|
||||
}
|
||||
|
||||
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */
|
||||
|
||||
@@ -3310,8 +3310,8 @@ namespace ts {
|
||||
// TODO: GH#18217
|
||||
let firstAccessor!: AccessorDeclaration;
|
||||
let secondAccessor!: AccessorDeclaration;
|
||||
let getAccessor!: AccessorDeclaration;
|
||||
let setAccessor!: AccessorDeclaration;
|
||||
let getAccessor!: GetAccessorDeclaration;
|
||||
let setAccessor!: SetAccessorDeclaration;
|
||||
if (hasDynamicName(accessor)) {
|
||||
firstAccessor = accessor;
|
||||
if (accessor.kind === SyntaxKind.GetAccessor) {
|
||||
@@ -3339,11 +3339,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (member.kind === SyntaxKind.GetAccessor && !getAccessor) {
|
||||
getAccessor = <AccessorDeclaration>member;
|
||||
getAccessor = <GetAccessorDeclaration>member;
|
||||
}
|
||||
|
||||
if (member.kind === SyntaxKind.SetAccessor && !setAccessor) {
|
||||
setAccessor = <AccessorDeclaration>member;
|
||||
setAccessor = <SetAccessorDeclaration>member;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1214
-1214
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user