From 7666938b0a8c69dbf52018134a2cdb6e58d1c9cc Mon Sep 17 00:00:00 2001 From: Landon Gavin Date: Wed, 3 Jan 2024 00:11:39 -0500 Subject: [PATCH] Remove unneeded as expression for TQuery --- src/createUseQuery.ts | 55 ++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/createUseQuery.ts b/src/createUseQuery.ts index d7d137e..3c06227 100644 --- a/src/createUseQuery.ts +++ b/src/createUseQuery.ts @@ -1,6 +1,6 @@ import ts from "typescript"; import { capitalizeFirstLetter } from "./common"; -import { addJSDocToNode } from './util'; +import { addJSDocToNode } from "./util"; export const createUseQuery = ( node: ts.SourceFile, @@ -221,37 +221,34 @@ export const createUseQuery = ( ts.factory.createObjectLiteralExpression([ ts.factory.createPropertyAssignment( ts.factory.createIdentifier("queryKey"), - ts.factory.createAsExpression( - ts.factory.createArrayLiteralExpression( - [ - ts.factory.createIdentifier(queryKey), - ts.factory.createSpreadElement( - ts.factory.createParenthesizedExpression( - ts.factory.createBinaryExpression( - ts.factory.createIdentifier("queryKey"), - ts.factory.createToken( - ts.SyntaxKind.QuestionQuestionToken - ), - method.parameters.length - ? ts.factory.createArrayLiteralExpression([ - ts.factory.createObjectLiteralExpression( - method.parameters.map((param) => - ts.factory.createShorthandPropertyAssignment( - ts.factory.createIdentifier( - param.name.getText(node) - ) + ts.factory.createArrayLiteralExpression( + [ + ts.factory.createIdentifier(queryKey), + ts.factory.createSpreadElement( + ts.factory.createParenthesizedExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("queryKey"), + ts.factory.createToken( + ts.SyntaxKind.QuestionQuestionToken + ), + method.parameters.length + ? ts.factory.createArrayLiteralExpression([ + ts.factory.createObjectLiteralExpression( + method.parameters.map((param) => + ts.factory.createShorthandPropertyAssignment( + ts.factory.createIdentifier( + param.name.getText(node) ) ) - ), - ]) - : ts.factory.createArrayLiteralExpression([]) - ) + ) + ), + ]) + : ts.factory.createArrayLiteralExpression([]) ) - ), - ], - false - ), - queryKeyGenericType + ) + ), + ], + false ) ), ts.factory.createPropertyAssignment(