Skip to content

Commit 00b67cc

Browse files
authored
chore: set no unchecked indexed access to true (#62)
1 parent cb1e3d4 commit 00b67cc

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/implementation/c/code/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@ import { Update } from './update';
1212

1313
export * from './base';
1414

15+
class Match extends External<frontend.code.External> {}
16+
class Span extends External<frontend.code.Span> {}
17+
class Value extends External<frontend.code.Value> {}
18+
1519
export default {
1620
And,
1721
IsEqual,
1822
Load,
19-
Match: class Match extends External<frontend.code.External> {},
23+
Match,
2024
MulAdd,
2125
Or,
22-
Span: class Span extends External<frontend.code.Span> {},
26+
Span,
2327
Store,
2428
Test,
2529
Update,
26-
Value: class Value extends External<frontend.code.Value> {},
30+
Value,
2731
};

src/implementation/c/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class CCompiler {
171171
const posField = ctx.spanPosField(span.index);
172172
let callback: string;
173173
if (span.callbacks.length === 1) {
174-
callback = ctx.buildCode(ctx.unwrapCode(span.callbacks[0]));
174+
callback = ctx.buildCode(ctx.unwrapCode(span.callbacks[0]!));
175175
} else {
176176
callback = `(${info.prefix}__span_cb) ` + ctx.spanCbField(span.index);
177177
callback = `(${callback})`;

src/implementation/c/node/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import { TableLookup } from './table-lookup';
1313

1414
export { Node } from './base';
1515

16+
class Error extends ErrorNode<frontend.node.Error> {}
17+
1618
export default {
1719
Consume,
1820
Empty,
19-
Error: class Error extends ErrorNode<frontend.node.Error> {},
21+
Error,
2022
Invoke,
2123
Pause,
2224
Sequence,

src/implementation/c/node/table-lookup.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ export class TableLookup extends Node<frontend.node.TableLookup> {
3939
const current = transform.build(ctx, `*${ctx.posArg()}`);
4040
out.push(`switch (${table.name}[(uint8_t) ${current}]) {`);
4141

42-
for (const [ index ] of this.ref.edges.entries()) {
42+
for (const [ index, edge ] of this.ref.edges.entries()) {
4343
out.push(` case ${index + 1}: {`);
4444

4545
const tmp: string[] = [];
46-
const edge = this.ref.edges[index];
4746
this.tailTo(tmp, {
4847
noAdvance: edge.noAdvance,
4948
node: edge.node,
@@ -77,7 +76,10 @@ export class TableLookup extends Node<frontend.node.TableLookup> {
7776
}
7877

7978
const edge = this.ref.edges[0];
80-
if (edge.node.ref !== this.ref) {
79+
if (
80+
!edge ||
81+
edge.node.ref !== this.ref
82+
) {
8183
return false;
8284
}
8385

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"declaration": true,
99
"pretty": true,
1010
"sourceMap": true,
11+
"noUncheckedIndexedAccess": true,
1112
"noUnusedLocals": true
1213
},
1314
"include": [

0 commit comments

Comments
 (0)