• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RobinTail / express-zod-api / 4410939844

pending completion
4410939844

Pull #880

github

GitHub
Merge 1f79a241a into 1ca06dc0d
Pull Request #880: Bump @typescript-eslint/eslint-plugin from 5.54.1 to 5.55.0

499 of 524 branches covered (95.23%)

1119 of 1119 relevant lines covered (100.0%)

385.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.11
/src/client-helpers.ts
1
import ts from "typescript";
168✔
2

3
export const f = ts.factory;
168✔
4

5
export const exportModifier = [f.createModifier(ts.SyntaxKind.ExportKeyword)];
168✔
6

7
export const publicReadonlyModifier = [
168✔
8
  f.createModifier(ts.SyntaxKind.PublicKeyword),
9
  f.createModifier(ts.SyntaxKind.ReadonlyKeyword),
10
];
11

12
export const protectedReadonlyModifier = [
168✔
13
  f.createModifier(ts.SyntaxKind.ProtectedKeyword),
14
  f.createModifier(ts.SyntaxKind.ReadonlyKeyword),
15
];
16

17
const emptyPrefix = f.createTemplateHead("");
168✔
18

19
const emptyEnding = f.createTemplateTail("");
168✔
20

21
const spacingSuffix = f.createTemplateMiddle(" ");
168✔
22

23
export const makeTemplate = (names: (ts.Identifier | string)[]) =>
168✔
24
  f.createTemplateLiteralType(
184✔
25
    emptyPrefix,
26
    names.map((name, index) =>
27
      f.createTemplateLiteralTypeSpan(
368✔
28
        f.createTypeReferenceNode(name),
29
        index === names.length - 1 ? emptyEnding : spacingSuffix
368✔
30
      )
31
    )
32
  );
33

34
export const parametricIndexNode = makeTemplate(["M", "P"]);
168✔
35

36
export const makeParam = (
168✔
37
  name: string,
38
  type?: ts.TypeNode,
39
  mod?: ts.Modifier[]
40
) => f.createParameterDeclaration(mod, undefined, name, undefined, type);
224✔
41

42
export const makeParams = (
168✔
43
  params: Record<string, ts.TypeNode | undefined>,
44
  mod?: ts.Modifier[]
45
) =>
46
  Object.keys(params).reduce(
64✔
47
    (acc, name) => acc.concat(makeParam(name, params[name], mod)),
160✔
48
    [] as ts.ParameterDeclaration[]
49
  );
50

51
export const makeRecord = (
168✔
52
  key: ts.Identifier | ts.KeywordTypeSyntaxKind,
53
  value: ts.KeywordTypeSyntaxKind
54
) =>
55
  f.createExpressionWithTypeArguments(f.createIdentifier("Record"), [
32✔
56
    typeof key === "number"
32✔
57
      ? f.createKeywordTypeNode(key)
58
      : f.createTypeReferenceNode(key),
59
    f.createKeywordTypeNode(value),
60
  ]);
61

62
export const makeEmptyInitializingConstructor = (
168✔
63
  params: ts.ParameterDeclaration[]
64
) => f.createConstructorDeclaration(undefined, params, f.createBlock([]));
16✔
65

66
export const makeQuotedProp = (name: string, ref: string) =>
168✔
67
  f.createPropertySignature(
96✔
68
    undefined,
69
    `"${name}"`,
70
    undefined,
71
    f.createTypeReferenceNode(ref)
72
  );
73

74
export const makeConst = (name: string, value: ts.Expression) =>
168✔
75
  f.createVariableDeclarationList(
16✔
76
    [f.createVariableDeclaration(name, undefined, undefined, value)],
77
    ts.NodeFlags.Const
78
  );
79

80
export const makePublicLiteralType = (name: string, literals: string[]) =>
168✔
81
  f.createTypeAliasDeclaration(
32✔
82
    exportModifier,
83
    name,
84
    undefined,
85
    f.createUnionTypeNode(
86
      literals.map((option) =>
87
        f.createLiteralTypeNode(f.createStringLiteral(option))
128✔
88
      )
89
    )
90
  );
91

92
export const makePublicType = (name: string, value: ts.TypeNode) =>
168✔
93
  f.createTypeAliasDeclaration(exportModifier, name, undefined, value);
48✔
94

95
export const makePublicReadonlyProp = (
168✔
96
  name: string,
97
  type: ts.TypeNode,
98
  exp: ts.Expression
99
) =>
100
  f.createPropertyDeclaration(
16✔
101
    publicReadonlyModifier,
102
    name,
103
    undefined,
104
    type,
105
    exp
106
  );
107

108
export const makePublicClass = (
168✔
109
  name: string,
110
  constructor: ts.ConstructorDeclaration,
111
  props: ts.PropertyDeclaration[] = []
×
112
) =>
113
  f.createClassDeclaration(exportModifier, name, undefined, undefined, [
16✔
114
    constructor,
115
    ...props,
116
  ]);
117

118
export const makeIndexedPromise = (type: ts.Identifier, index: ts.TypeNode) =>
168✔
119
  f.createTypeReferenceNode("Promise", [
16✔
120
    f.createIndexedAccessTypeNode(f.createTypeReferenceNode(type), index),
121
  ]);
122

123
export const makeAnyPromise = () =>
168✔
124
  f.createTypeReferenceNode("Promise", [
16✔
125
    f.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
126
  ]);
127

128
export const makePublicExtendedInterface = (
168✔
129
  name: string,
130
  extender: ts.HeritageClause[],
131
  props: ts.PropertySignature[]
132
) =>
133
  f.createInterfaceDeclaration(
32✔
134
    exportModifier,
135
    name,
136
    undefined,
137
    extender,
138
    props
139
  );
140

141
export const makeTypeParams = (params: Record<string, ts.Identifier>) =>
168✔
142
  Object.keys(params).reduce(
16✔
143
    (acc, name) =>
144
      acc.concat(
32✔
145
        f.createTypeParameterDeclaration(
146
          [],
147
          name,
148
          f.createTypeReferenceNode(params[name])
149
        )
150
      ),
151
    [] as ts.TypeParameterDeclaration[]
152
  );
153

154
export const makeImplementationCallFn = (
168✔
155
  params: string[],
156
  args: ts.Expression[]
157
) =>
158
  f.createArrowFunction(
16✔
159
    undefined,
160
    undefined,
161
    params.map((key) => makeParam(key)),
48✔
162
    undefined,
163
    undefined,
164
    f.createCallExpression(
165
      f.createPropertyAccessExpression(f.createThis(), "implementation"),
166
      undefined,
167
      args
168
    )
169
  );
170

171
export const makeObjectKeysReducer = (
168✔
172
  obj: string,
173
  exp: ts.Expression,
174
  initial: ts.Expression
175
) =>
176
  f.createCallExpression(
32✔
177
    f.createPropertyAccessExpression(
178
      f.createCallExpression(
179
        f.createPropertyAccessExpression(f.createIdentifier("Object"), "keys"),
180
        undefined,
181
        [f.createIdentifier(obj)]
182
      ),
183
      "reduce"
184
    ),
185
    undefined,
186
    [
187
      f.createArrowFunction(
188
        undefined,
189
        undefined,
190
        makeParams({ acc: undefined, key: undefined }),
191
        undefined,
192
        undefined,
193
        exp
194
      ),
195
      initial,
196
    ]
197
  );
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc