Skip to content

Commit

Permalink
Enable noUncheckedIndexedAccess in tsconfig.json
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Oct 30, 2023
1 parent d0e1f38 commit 1ce88da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 4 additions & 9 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,13 @@ export function fieldsAuto<Mapping extends FieldsMapping>(
return objectResult;
}
const object = objectResult.value;
const keys = Object.keys(mapping);
const knownFields = new Set<string>();
const result: Record<string, unknown> = {};

for (const key of keys) {
for (const [key, fieldOrCodec] of Object.entries(mapping)) {
if (key === "__proto__") {
continue;
}
const fieldOrCodec = mapping[key];
const field_: Field<any, any, FieldMeta> =
"codec" in fieldOrCodec ? fieldOrCodec : { codec: fieldOrCodec };
const {
Expand Down Expand Up @@ -383,11 +381,10 @@ export function fieldsAuto<Mapping extends FieldsMapping>(
},
encoder: (object) => {
const result: Record<string, unknown> = {};
for (const key of Object.keys(mapping)) {
for (const [key, fieldOrCodec] of Object.entries(mapping)) {
if (key === "__proto__") {
continue;
}
const fieldOrCodec = mapping[key];
const field_: Field<any, any, FieldMeta> =
"codec" in fieldOrCodec ? fieldOrCodec : { codec: fieldOrCodec };
const {
Expand Down Expand Up @@ -658,8 +655,7 @@ export function tuple<const Codecs extends ReadonlyArray<Codec<any>>>(
};
}
const result = [];
for (let index = 0; index < arr.length; index++) {
const codec = codecs[index];
for (const [index, codec] of codecs.entries()) {
const decoderResult = codec.decoder(arr[index]);
switch (decoderResult.tag) {
case "DecoderError":
Expand All @@ -679,8 +675,7 @@ export function tuple<const Codecs extends ReadonlyArray<Codec<any>>>(
},
encoder: (value) => {
const result = [];
for (let index = 0; index < codecs.length; index++) {
const codec = codecs[index];
for (const [index, codec] of codecs.entries()) {
result.push(codec.encoder(value[index]));
}
return result as InferEncodedTuple<Codecs>;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"strict": true,
"exactOptionalPropertyTypes": true,
Expand Down

0 comments on commit 1ce88da

Please sign in to comment.