Skip to content

Commit

Permalink
Remove unneeded as expression for TQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
seriouslag committed Jan 3, 2024
1 parent 3a08039 commit 7666938
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions src/createUseQuery.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7666938

Please sign in to comment.