Skip to content
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

ASTReducer: correctly type scalar values #3873

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/language/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ const printDocASTReducer: ASTReducer<string> = {
FloatValue: { leave: ({ value }) => value },
StringValue: {
leave: ({ value, block: isBlockString }) =>
// @ts-expect-error FIXME: it's a problem with ASTReducer, will be fixed in separate PR
isBlockString === true ? printBlockString(value) : printString(value),
},
BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },
Expand Down
8 changes: 4 additions & 4 deletions src/language/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ type ASTReducerFn<TReducedNode extends ASTNode, R> = (
ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>,
) => R;

type ReducedField<T, R> = T extends null | undefined
? T
: T extends ReadonlyArray<any>
type ReducedField<T, R> = T extends ASTNode
? R
: T extends ReadonlyArray<ASTNode>
? ReadonlyArray<R>
: R;
: T;

/**
* A KeyMap describes each the traversable properties of each kind of node.
Expand Down