fork of hey-api/openapi-ts because I need some additional things
1import type { PyNodeBase } from '../base';
2import type { PyExpression } from '../expression';
3import { PyNodeKind } from '../kinds';
4import type { PyStatement } from '../statement';
5import type { PyBlock } from './block';
6import { createBlock } from './block';
7
8export interface PyWhileStatement extends PyNodeBase {
9 body: PyBlock;
10 condition: PyExpression;
11 elseBlock?: PyBlock;
12 kind: PyNodeKind.WhileStatement;
13}
14
15export function createWhileStatement(
16 condition: PyExpression,
17 body: ReadonlyArray<PyStatement>,
18 elseBlock?: ReadonlyArray<PyStatement>,
19): PyWhileStatement {
20 return {
21 body: createBlock(body),
22 condition,
23 elseBlock: elseBlock ? createBlock(elseBlock) : undefined,
24 kind: PyNodeKind.WhileStatement,
25 };
26}