Skip to content

Commit 40f3068

Browse files
committed
Improve types of isRoutine() util
1 parent fec6f68 commit 40f3068

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/embedSql.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const embedSql: NonNullable<Printer<Node>["embed"]> = (
2929
return null;
3030
}
3131

32-
if (isRoutine(parent, grandParent)) {
32+
if (isAsClause(parent) && isRoutine(grandParent)) {
3333
if (grandParent.clauses.some(isSqlLanguageClause)) {
3434
return sqlFormatter(node, pluginOptions);
3535
}
@@ -96,9 +96,10 @@ const plpgsqlFormatter = (
9696
};
9797
};
9898

99-
const isRoutine = (parent: any, grandParent: any): boolean =>
100-
isAsClause(parent) &&
101-
(isCreateFunctionStmt(grandParent) || isCreateProcedureStmt(grandParent));
99+
const isRoutine = (
100+
node: any,
101+
): node is CreateFunctionStmt | CreateProcedureStmt =>
102+
isCreateFunctionStmt(node) || isCreateProcedureStmt(node);
102103

103104
const isSqlLanguageClause = (
104105
clause: CreateFunctionStmt["clauses"][0] | CreateProcedureStmt["clauses"][0],

0 commit comments

Comments
 (0)