fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 29 lines 907 B view raw
1import type { PyNodeBase } from '../base'; 2import type { PyExpression } from '../expression'; 3import { PyNodeKind } from '../kinds'; 4import type { PyStatement } from '../statement'; 5import { createBlock, type PyBlock } from './block'; 6 7export interface PyIfStatement extends PyNodeBase { 8 condition: PyExpression; 9 elseBlock?: PyBlock | PyIfStatement; 10 kind: PyNodeKind.IfStatement; 11 thenBlock: PyBlock; 12} 13 14export function createIfStatement( 15 condition: PyExpression, 16 thenBlock: ReadonlyArray<PyStatement>, 17 elseBlock?: ReadonlyArray<PyStatement> | PyIfStatement, 18 leadingComments?: ReadonlyArray<string>, 19 trailingComments?: ReadonlyArray<string>, 20): PyIfStatement { 21 return { 22 condition, 23 elseBlock: elseBlock instanceof Array ? createBlock(elseBlock) : elseBlock, 24 kind: PyNodeKind.IfStatement, 25 leadingComments, 26 thenBlock: createBlock(thenBlock), 27 trailingComments, 28 }; 29}