MCPcopy
hub / github.com/ComposioHQ/composio / TypeDeclaration

Class TypeDeclaration

ts/packages/ts-builders/src/TypeDeclaration.ts:7–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import { Writer } from './Writer';
6
7export class TypeDeclaration<InnerType extends TypeBuilder = TypeBuilder> implements BasicBuilder {
8 private genericParameters: GenericParameter[] = [];
9 private docComment?: DocComment;
10
11 constructor(
12 public name: string,
13 private type: InnerType | string
14 ) {}
15
16 addGenericParameter(param: GenericParameter): this {
17 this.genericParameters.push(param);
18 return this;
19 }
20
21 setName(name: string) {
22 this.name = name;
23 return this;
24 }
25
26 setValue(typeDecl: string) {
27 this.type = typeDecl;
28 }
29
30 setDocComment(docComment: DocComment): this {
31 this.docComment = docComment;
32 return this;
33 }
34
35 write(writer: Writer): void {
36 if (this.docComment) {
37 writer.write(this.docComment);
38 }
39
40 if (typeof this.type === 'string') {
41 writer.write(this.type);
42 return;
43 }
44
45 writer.write('type ').write(this.name);
46 if (this.genericParameters.length > 0) {
47 writer.write('<').writeJoined(', ', this.genericParameters).write('>');
48 }
49 writer.write(' = ').write(this.type);
50 }
51}
52
53export function typeDeclaration<InnerType extends TypeBuilder = TypeBuilder>(
54 name: string,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…