-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Harden node builder APIs to no longer return undefined
for a node when NodeBuilderFlags.IgnoreErrors
is provided
#38273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2040,23 +2040,23 @@ declare namespace ts { | |
getNonNullableType(type: Type): Type; | ||
getTypeArguments(type: TypeReference): readonly Type[]; | ||
/** Note that the resulting nodes cannot be checked. */ | ||
typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; | ||
typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be a break if we want it for 3.9. Any way we can avoid it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easily - now that I've used it to audit our internal usages, swapping it back is pretty simple; changing it is just for safety at callsites (so we may still want it for the 4.0 branch, where we may eventually add more). |
||
/** Note that the resulting nodes cannot be checked. */ | ||
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { | ||
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): (SignatureDeclaration & { | ||
typeArguments?: NodeArray<TypeNode>; | ||
}) | undefined; | ||
/** Note that the resulting nodes cannot be checked. */ | ||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined; | ||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined; | ||
/** Note that the resulting nodes cannot be checked. */ | ||
symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): EntityName | undefined; | ||
symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined; | ||
/** Note that the resulting nodes cannot be checked. */ | ||
symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): Expression | undefined; | ||
symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): Expression | undefined; | ||
/** Note that the resulting nodes cannot be checked. */ | ||
symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): NodeArray<TypeParameterDeclaration> | undefined; | ||
symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeArray<TypeParameterDeclaration> | undefined; | ||
/** Note that the resulting nodes cannot be checked. */ | ||
symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): ParameterDeclaration | undefined; | ||
symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined; | ||
/** Note that the resulting nodes cannot be checked. */ | ||
typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeParameterDeclaration | undefined; | ||
typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined; | ||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; | ||
getSymbolAtLocation(node: Node): Symbol | undefined; | ||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed offline, I think this (and below) would be clearer as
IgnoreErrors
, but I can live with this version if it's more idiomatic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I struggled to enumerate it earlier, but if we check for
NodeBuilderFlags.IgnoreErrors
, then if any of theAllowX
flags are set, the error would be suppressed (as that's how binary&
works) - it's much neater to tie it to a specific flag (I'd have been tempted to add new ones, but we're actually entirely our of flag space in this enum).