mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 22:15:18 -05:00
Checking is 1/3 done or so.
Now I'm going to go rename some members to be more uniform. I hate unnnecessary conditionals.
This commit is contained in:
@@ -5355,9 +5355,9 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
const declaration = <JSDocTypedefTag | TypeAliasDeclaration>find(symbol.declarations, d =>
|
||||
d.kind === SyntaxKind.JSDocTypedefTag || d.kind === SyntaxKind.TypeAliasDeclaration);
|
||||
const typeNode = declaration.kind === SyntaxKind.JSDocTypedefTag ? declaration.typeExpression : declaration.type;
|
||||
const declaration = <JSDocTypedefTag | JSDocCallbackTag | TypeAliasDeclaration>find(symbol.declarations, d =>
|
||||
isJSDocTypeAlias(d) || d.kind === SyntaxKind.TypeAliasDeclaration);
|
||||
const typeNode = isJSDocTypedefTag(declaration) ? declaration.typeExpression : isJSDocCallbackTag(declaration) ? declaration.signature : declaration.type;
|
||||
// If typeNode is missing, we will error in checkJSDocTypedefTag.
|
||||
let type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType;
|
||||
|
||||
@@ -7575,24 +7575,25 @@ namespace ts {
|
||||
*/
|
||||
function getTypeFromTypeAliasReference(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[]): Type {
|
||||
const type = getDeclaredTypeOfSymbol(symbol);
|
||||
// TODO: call getEffectiveTypeParameterDeclarations here and upgrade it to understand in-comment template tags as type parameters
|
||||
const typeParameters = getSymbolLinks(symbol).typeParameters;
|
||||
if (typeParameters) {
|
||||
const numTypeArguments = length(node.typeArguments);
|
||||
const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
|
||||
if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
|
||||
error(node,
|
||||
minTypeArgumentCount === typeParameters.length
|
||||
? Diagnostics.Generic_type_0_requires_1_type_argument_s
|
||||
: Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments,
|
||||
symbolToString(symbol),
|
||||
minTypeArgumentCount,
|
||||
typeParameters.length);
|
||||
minTypeArgumentCount === typeParameters.length
|
||||
? Diagnostics.Generic_type_0_requires_1_type_argument_s
|
||||
: Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments,
|
||||
symbolToString(symbol),
|
||||
minTypeArgumentCount,
|
||||
typeParameters.length);
|
||||
return unknownType;
|
||||
}
|
||||
return getTypeAliasInstantiation(symbol, typeArguments);
|
||||
}
|
||||
return checkNoTypeArguments(node, symbol) ? type : unknownType;
|
||||
}
|
||||
}
|
||||
|
||||
function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined {
|
||||
switch (node.kind) {
|
||||
|
||||
@@ -1772,6 +1772,10 @@ namespace ts {
|
||||
((node as JSDocFunctionType).parameters[0].name as Identifier).escapedText === "new";
|
||||
}
|
||||
|
||||
export function isJSDocTypeAlias(node: Node): node is JSDocTypedefTag | JSDocCallbackTag {
|
||||
return node.kind === SyntaxKind.JSDocTypedefTag || node.kind === SyntaxKind.JSDocCallbackTag;
|
||||
}
|
||||
|
||||
function getSourceOfAssignment(node: Node): Node {
|
||||
return isExpressionStatement(node) &&
|
||||
node.expression && isBinaryExpression(node.expression) &&
|
||||
@@ -5435,6 +5439,14 @@ namespace ts {
|
||||
export function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral {
|
||||
return node.kind === SyntaxKind.JSDocTypeLiteral;
|
||||
}
|
||||
|
||||
export function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag {
|
||||
return node.kind === SyntaxKind.JSDocCallbackTag;
|
||||
}
|
||||
|
||||
export function isJSDocSignature(node: Node): node is JSDocSignature {
|
||||
return node.kind === SyntaxKind.JSDocSignature;
|
||||
}
|
||||
}
|
||||
|
||||
// Node tests
|
||||
|
||||
Reference in New Issue
Block a user