Something went wrong. Try again.
fork of hey-api/openapi-ts because I need some additional things
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import type { AnalysisContext } from '@hey-api/codegen-core';
import { py } from '../../py-compiler';import { PyDsl } from '../base';
type ImportName = { alias?: string; name: string };
const Mixed = PyDsl<py.ImportStatement>;
export class ImportPyDsl extends Mixed { readonly '~dsl' = 'ImportPyDsl';
protected isFrom: boolean = true; protected module: string = ''; protected names?: ReadonlyArray<ImportName>;
constructor(module: string); constructor(module: string, isFrom: boolean); constructor(module: string, names: ReadonlyArray<ImportName>, isFrom: boolean); constructor( module: string, namesOrIsFrom?: ReadonlyArray<ImportName> | boolean, isFrom?: boolean, ) { super(); this.module = module; if (typeof namesOrIsFrom === 'boolean') { this.isFrom = namesOrIsFrom; } else if (Array.isArray(namesOrIsFrom)) { this.names = namesOrIsFrom; this.isFrom = isFrom ?? true; } else { this.isFrom = true; } }
static from(module: string, names?: ReadonlyArray<ImportName>): ImportPyDsl { return names ? new ImportPyDsl(module, names, true) : new ImportPyDsl(module, true); }
static direct(module: string): ImportPyDsl { return new ImportPyDsl(module, false); }
override analyze(_ctx: AnalysisContext): void { super.analyze(_ctx); }
override toAst() { return py.factory.createImportStatement(this.module, this.names, this.isFrom); }}