Add JSDocFunctionTypeParameter node kind#18213
Conversation
sandersn
left a comment
There was a problem hiding this comment.
The main advantage of this change is that it's impossible to say JSDocFunctionTypeParameter.name now, right? The code bloats more than I expected with this change, so unless this makes using parameters more fool-proof, then I don't think it's worth it.
| type: TypeNode; | ||
| } | ||
|
|
||
| export const enum JSDocFunctionTypeParameterSort { |
There was a problem hiding this comment.
-Kind is a better suffix than -Sort here.
There was a problem hiding this comment.
Even better: name: JSDocParameterSpecialName, with Regular renamed to None.
There was a problem hiding this comment.
or specialName so that it isn't structurally compatible with other named things.
| export interface JSDocFunctionTypeParameterDeclaration extends Declaration { | ||
| kind: SyntaxKind.JSDocFunctionTypeParameter; | ||
| parent: JSDocFunctionType; | ||
| sort: JSDocFunctionTypeParameterSort; |
There was a problem hiding this comment.
jsdocKind or parameterKind or jsdocParameterKind.
There was a problem hiding this comment.
even better, just name or maybe nameKind.
| return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); | ||
| case SyntaxKind.Parameter: | ||
| return bindParameter(<ParameterDeclaration>node); | ||
| case SyntaxKind.JSDocFunctionTypeParameter: |
| case JSDocFunctionTypeParameterSort.New: | ||
| return "new" as __String; | ||
| case JSDocFunctionTypeParameterSort.This: | ||
| return "this" as __String; |
There was a problem hiding this comment.
I don't think these names matter since won't be used later.
| JSDocNonNullableType, | ||
| JSDocOptionalType, | ||
| JSDocFunctionType, | ||
| JSDocFunctionTypeParameter, |
There was a problem hiding this comment.
JSDocParameter is a better name
| getDeclaredTypeOfClassOrInterface(getMergedSymbol((<ClassDeclaration>declaration.parent).symbol)) | ||
| : undefined; | ||
| const typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); | ||
| const typeParameters = classType ? classType.localTypeParameters : declaration.kind === SyntaxKind.JSDocFunctionType ? emptyArray : getTypeParametersFromDeclaration(declaration); |
There was a problem hiding this comment.
seems like getTypeParametersFromDeclaration could handle jsdoc functions too, since it calls getEffectiveTypeParameters to provide precisely that level of abstraction.
| } | ||
|
|
||
| export interface JSDocFunctionType extends JSDocType, SignatureDeclaration { | ||
| export interface JSDocFunctionType extends JSDocType, Declaration { |
There was a problem hiding this comment.
need to remove SyntaxKind.JSDocFunctionType from SignatureDeclaration.kind.
| This, | ||
| New, | ||
| } | ||
| export interface JSDocFunctionTypeParameterDeclaration extends Declaration { |
There was a problem hiding this comment.
similarly, rename to JSDocParameterDeclaration
|
@Andy-MS is this still needed? |
|
Does not seem to be needed. closing for now. please reopen if that is not the case. |
Fixes #17403
In order to keep
ParameterDeclaration.namedefined, we should stop reusing it for nodes that do not have names. A parameter infunction(number, number): string(Ref: #17074, #17326)