Skip to content

Commit

Permalink
ASTReducer: correctly type scalar values (#3873)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Apr 3, 2023
1 parent 8c749e9 commit ee303a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
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

0 comments on commit ee303a8

Please sign in to comment.