···2525 constructor(name: string, fn?: (g: GetterTsDsl) => void) {
2626 super();
2727 this.name = name;
2828- if (fn) fn(this);
2828+ fn?.(this);
2929 }
30303131 /** Adds one or more expressions to the getter body. */
+23-4
packages/openapi-ts/src/ts-dsl/index.ts
···11import { AttrTsDsl } from './attr';
22+import { AwaitTsDsl } from './await';
23import { BinaryTsDsl } from './binary';
34import { CallTsDsl } from './call';
45import { ClassTsDsl } from './class';
55-import { ConstTsDsl } from './const';
66import { DescribeTsDsl } from './describe';
77import { ExprTsDsl } from './expr';
88import { FieldTsDsl } from './field';
99+import { FuncTsDsl } from './func';
910import { GetterTsDsl } from './getter';
1011import { IfTsDsl } from './if';
1112import { InitTsDsl } from './init';
···2122import { TemplateTsDsl } from './template';
2223import { ThrowTsDsl } from './throw';
2324import { TypeTsDsl } from './type';
2525+import { VarTsDsl } from './var';
24262527const base = {
2628 attr: (...args: ConstructorParameters<typeof AttrTsDsl>) =>
2729 new AttrTsDsl(...args),
3030+ await: (...args: ConstructorParameters<typeof AwaitTsDsl>) =>
3131+ new AwaitTsDsl(...args),
2832 binary: (...args: ConstructorParameters<typeof BinaryTsDsl>) =>
2933 new BinaryTsDsl(...args),
3034 call: (...args: ConstructorParameters<typeof CallTsDsl>) =>
3135 new CallTsDsl(...args),
3236 class: (...args: ConstructorParameters<typeof ClassTsDsl>) =>
3337 new ClassTsDsl(...args),
3434- const: (...args: ConstructorParameters<typeof ConstTsDsl>) =>
3535- new ConstTsDsl(...args),
3838+ const: (...args: ConstructorParameters<typeof VarTsDsl>) =>
3939+ new VarTsDsl(...args).const(),
3640 describe: (...args: ConstructorParameters<typeof DescribeTsDsl>) =>
3741 new DescribeTsDsl(...args),
3842 expr: (...args: ConstructorParameters<typeof ExprTsDsl>) =>
3943 new ExprTsDsl(...args),
4044 field: (...args: ConstructorParameters<typeof FieldTsDsl>) =>
4145 new FieldTsDsl(...args),
4646+ func: ((nameOrFn?: any, fn?: any) => {
4747+ if (nameOrFn === undefined) return new FuncTsDsl();
4848+ if (typeof nameOrFn !== 'string') return new FuncTsDsl(nameOrFn);
4949+ if (fn === undefined) return new FuncTsDsl(nameOrFn);
5050+ return new FuncTsDsl(nameOrFn, fn);
5151+ }) as {
5252+ (): FuncTsDsl<'arrow'>;
5353+ (fn: (f: FuncTsDsl<'arrow'>) => void): FuncTsDsl<'arrow'>;
5454+ (name: string): FuncTsDsl<'decl'>;
5555+ (name: string, fn: (f: FuncTsDsl<'decl'>) => void): FuncTsDsl<'decl'>;
5656+ },
4257 getter: (...args: ConstructorParameters<typeof GetterTsDsl>) =>
4358 new GetterTsDsl(...args),
4459 if: (...args: ConstructorParameters<typeof IfTsDsl>) => new IfTsDsl(...args),
4560 init: (...args: ConstructorParameters<typeof InitTsDsl>) =>
4661 new InitTsDsl(...args),
6262+ let: (...args: ConstructorParameters<typeof VarTsDsl>) =>
6363+ new VarTsDsl(...args).let(),
4764 literal: (...args: ConstructorParameters<typeof LiteralTsDsl>) =>
4865 new LiteralTsDsl(...args),
4966 method: (...args: ConstructorParameters<typeof MethodTsDsl>) =>
···6784 throw: (...args: ConstructorParameters<typeof ThrowTsDsl>) =>
6885 new ThrowTsDsl(...args),
6986 type: TypeTsDsl,
8787+ var: (...args: ConstructorParameters<typeof VarTsDsl>) =>
8888+ new VarTsDsl(...args),
7089};
71907291export const $ = Object.assign(
···7493 base,
7594);
76957777-export type { TsDsl } from './base';
9696+export { TsDsl } from './base';
+1-1
packages/openapi-ts/src/ts-dsl/init.ts
···20202121 constructor(fn?: (i: InitTsDsl) => void) {
2222 super();
2323- if (fn) fn(this);
2323+ fn?.(this);
2424 }
25252626 /** Adds one or more statements or expressions to the constructor body. */