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

satisfactory-dev / ajv-utilities / 30924500860

04 Aug 2026 03:25PM UTC coverage: 99.225% (-0.02%) from 99.24%
30924500860

push

github

SignpostMarv
adjusting indentation

610 of 628 branches covered (97.13%)

Branch coverage included in aggregate %.

31 of 31 new or added lines in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

5409 of 5438 relevant lines covered (99.47%)

16461.61 hits per line

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

98.84
/src/TypeScriptify/modifiers/HoistDeclarationAsUndefined.ts
1
import type {
1 ✔
2
        FunctionDeclaration,
1 ✔
3
        Identifier,
1 ✔
4
        NodeArray,
1 ✔
5
        VariableDeclaration,
1 ✔
6
        VariableDeclarationList,
1 ✔
7
        VariableStatement,
1 ✔
8
} from '@typescript/typescript6';
1 ✔
9

1 ✔
10
import {
1 ✔
11
        ConditionalModification,
1 ✔
12
} from '../abstracts.ts';
1 ✔
13

1 ✔
14
import type {
1 ✔
15
        ts,
1 ✔
16
} from '../../TypeScriptify.ts';
1 ✔
17

1 ✔
18
import type {
1 ✔
19
        prepend_with_imports,
1 ✔
20
} from '../TypeReferences.ts';
1 ✔
21

1 ✔
22
import KnownImports from '../known_imports.ts';
1 ✔
23

1 ✔
24
type Candidate = (
1 ✔
25
        & VariableStatement
1 ✔
26
        & {
1 ✔
27
                declarationList: (
1 ✔
28
                        & VariableDeclarationList
1 ✔
29
                        & {
1 ✔
30
                                declarations: (
1 ✔
31
                                        & NodeArray<VariableDeclaration>
1 ✔
32
                                        & {
1 ✔
33
                                                length: 1,
1 ✔
34
                                                0: (
1 ✔
35
                                                        & VariableDeclaration
1 ✔
36
                                                        & {
1 ✔
37
                                                                name: (
1 ✔
38
                                                                        & Identifier
1 ✔
39
                                                                        & {
1 ✔
40
                                                                                text: `props${number}`,
1 ✔
41
                                                                        }
1 ✔
42
                                                                ),
1 ✔
43
                                                                initializer: Exclude<
1 ✔
44
                                                                        VariableDeclaration['initializer'],
1 ✔
45
                                                                        undefined
1 ✔
46
                                                                >,
1 ✔
47
                                                        }
1 ✔
48
                                                ),
1 ✔
49
                                        }
1 ✔
50
                                ),
1 ✔
51
                        }
1 ✔
52
                ),
1 ✔
53
        }
1 ✔
54
);
1 ✔
55

1 ✔
56
type HoistingToHereCandidate = (
1 ✔
57
        & FunctionDeclaration
1 ✔
58
        & {
1 ✔
59
                name: (
1 ✔
60
                        & Identifier
1 ✔
61
                        & {
1 ✔
62
                                text: `validate${number}`,
1 ✔
63
                        }
1 ✔
64
                ),
1 ✔
65
                body: Exclude<FunctionDeclaration['body'], undefined>,
1 ✔
66
        }
1 ✔
67
);
1 ✔
68

1 ✔
69
export type hoist_candidates = {
1 ✔
70
        [key: string]: Set<string>,
1 ✔
71
};
1 ✔
72

1 ✔
73
export class FindHoistCandidate extends ConditionalModification<
1 ✔
74
        Candidate
1 ✔
75
> {
1 ✔
76
        constructor(
1 ✔
77
                {
26 ✔
78
                        factory,
26 ✔
79
                        isFunctionDeclaration,
26 ✔
80
                        isIdentifier,
26 ✔
81
                        isVariableDeclaration,
26 ✔
82
                        isVariableStatement,
26 ✔
83
                        SyntaxKind,
26 ✔
84
                }: ts,
26 ✔
85
                hoist_candidates: hoist_candidates,
26 ✔
86
        ) {
26 ✔
87
                super(
26 ✔
88
                        (maybe): maybe is Candidate => {
26 ✔
89
                                if (
238,764 ✔
90
                                        !(
238,764 ✔
91
                                                isVariableStatement(maybe)
238,764 ✔
92
                                                && 1 === maybe.declarationList.declarations.length
238,764 ✔
93
                                                && isVariableDeclaration(
238,764 ✔
94
                                                        maybe.declarationList.declarations[0],
4,887 ✔
95
                                                )
4,887 ✔
96
                                                && isIdentifier(
238,764 ✔
97
                                                        maybe.declarationList.declarations[0].name,
4,887 ✔
98
                                                )
4,887 ✔
99
                                                && /^props\d+$/.test(
238,764 ✔
100
                                                        maybe.declarationList.declarations[
4,887 ✔
101
                                                                0
4,887 ✔
102
                                                        ].name.text,
4,887 ✔
103
                                                )
4,887 ✔
104
                                        )
238,764 ✔
105
                                ) {
238,764 ✔
106
                                        return false;
238,754 ✔
107
                                }
238,754 ✔
108

10 ✔
109
                                const variable_name = maybe.declarationList.declarations[
10 ✔
110
                                        0
10 ✔
111
                                ].name.getText();
10 ✔
112

10 ✔
113
                                let checking = maybe.parent;
10 ✔
114

10 ✔
115
                                while (checking) {
238,764 ✔
116
                                        if (
130 ✔
117
                                                isFunctionDeclaration(checking)
130 ✔
118
                                                && !!checking.name
130 ✔
119
                                                && isIdentifier(checking.name)
130 ✔
120
                                                && this.validate_function_name.test(
130 ✔
121
                                                        checking.name.getText(),
10 ✔
122
                                                )
10 ✔
123
                                        ) {
130 ✔
124
                                                const name = checking.name.getText();
10 ✔
125

10 ✔
126
                                                if (!(name in hoist_candidates)) {
10 ✔
127
                                                        hoist_candidates[name] = new Set([variable_name]);
6 ✔
128
                                                } else {
10 ✔
129
                                                        hoist_candidates[name].add(variable_name);
4 ✔
130
                                                }
4 ✔
131

10 ✔
132
                                                return true;
10 ✔
133
                                        }
10 ✔
134

120 ✔
135
                                        checking = checking.parent;
120 ✔
136
                                }
120 !
UNCOV
137

×
UNCOV
138
                                return false;
×
139
                        },
26 ✔
140
                        (node) => {
26 ✔
141
                                const variable_name = node.declarationList.declarations[
10 ✔
142
                                        0
10 ✔
143
                                ].name.getText();
10 ✔
144

10 ✔
145
                                return factory.createExpressionStatement(
10 ✔
146
                                        factory.createBinaryExpression(
10 ✔
147
                                                factory.createIdentifier(variable_name),
10 ✔
148
                                                factory.createToken(SyntaxKind.EqualsToken),
10 ✔
149
                                                node.declarationList.declarations[0].initializer,
10 ✔
150
                                        ),
10 ✔
151
                                );
10 ✔
152
                        },
26 ✔
153
                );
26 ✔
154
        }
26 ✔
155
}
1 ✔
156

1 ✔
157
export class HoistDeclarationsHere extends ConditionalModification<
1 ✔
158
        HoistingToHereCandidate
1 ✔
159
> {
1 ✔
160
        #createHoistedType(
1 ✔
161
                {
10 ✔
162
                        factory,
10 ✔
163
                        SyntaxKind,
10 ✔
164
                }: ts,
10 ✔
165
        ) {
10 ✔
166
                return factory.createParenthesizedType(factory.createUnionTypeNode([
10 ✔
167
                        factory.createTypeReferenceNode('EvaluatedProperties'),
10 ✔
168
                        factory.createKeywordTypeNode(SyntaxKind.UndefinedKeyword),
10 ✔
169
                ]));
10 ✔
170
        }
10 ✔
171

1 ✔
172
        constructor(
1 ✔
173
                ts: ts,
26 ✔
174
                hoist_candidates: Readonly<hoist_candidates>,
26 ✔
175
                prepend_with_imports: prepend_with_imports,
26 ✔
176
        ) {
26 ✔
177
                const {
26 ✔
178
                        factory,
26 ✔
179
                        isFunctionDeclaration,
26 ✔
180
                        isIdentifier,
26 ✔
181
                        NodeFlags,
26 ✔
182
                } = ts;
26 ✔
183

26 ✔
184
                super(
26 ✔
185
                        (maybe): maybe is HoistingToHereCandidate => (
26 ✔
186
                                isFunctionDeclaration(maybe)
239,056 ✔
187
                                && !!maybe.name
239,056 ✔
188
                                && isIdentifier(maybe.name)
239,056 ✔
189
                                && maybe.name.text in hoist_candidates
239,056 ✔
190
                                && undefined !== maybe.body
239,056 ✔
191
                        ),
26 ✔
192
                        (node) => {
26 ✔
193
                                KnownImports.EvaluatedProperties(ts, prepend_with_imports);
6 ✔
194

6 ✔
195
                                return factory.updateFunctionDeclaration(
6 ✔
196
                                        node,
6 ✔
197
                                        node.modifiers,
6 ✔
198
                                        node.asteriskToken,
6 ✔
199
                                        node.name,
6 ✔
200
                                        node.typeParameters,
6 ✔
201
                                        node.parameters,
6 ✔
202
                                        node.type,
6 ✔
203
                                        factory.updateBlock(
6 ✔
204
                                                node.body,
6 ✔
205
                                                [
6 ✔
206
                                                        factory.createVariableStatement(
6 ✔
207
                                                                undefined,
6 ✔
208
                                                                factory.createVariableDeclarationList(
6 ✔
209
                                                                        [...hoist_candidates[node.name.getText()]]
6 ✔
210
                                                                                .map((
6 ✔
211
                                                                                        variable_name,
10 ✔
212
                                                                                ) => factory.createVariableDeclaration(
10 ✔
213
                                                                                        variable_name,
10 ✔
214
                                                                                        undefined,
10 ✔
215
                                                                                        this.#createHoistedType(ts),
10 ✔
216
                                                                                        factory.createIdentifier(
10 ✔
217
                                                                                                'undefined',
10 ✔
218
                                                                                        ),
10 ✔
219
                                                                                )),
6 ✔
220
                                                                        NodeFlags.Let,
6 ✔
221
                                                                ),
6 ✔
222
                                                        ),
6 ✔
223
                                                        ...node.body.statements,
6 ✔
224
                                                ],
6 ✔
225
                                        ),
6 ✔
226
                                );
6 ✔
227
                        },
26 ✔
228
                );
26 ✔
229
        }
26 ✔
230
}
1 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc