mojotech / mojotech/json-type-validation
TypeScript compilation error
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 154
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
% tsc
decoder.ts:432:55 - error TS2339: Property 'error' does not exist on type 'Result<A, Partial<DecoderError>>'.
Property 'error' does not exist on type 'Ok<A>'.
432 return Result.err(prependAt(`[${i}]`, nth.error));
~~~~~
Found 1 error.
In this code block:
static tuple<A>(decoders: Decoder<A>[]) {
return new Decoder((json: unknown) => {
if (isJsonArray(json)) {
if (json.length !== decoders.length) {
return Result.err({
message: `expected a tuple of length ${decoders.length}, got one of length ${
json.length
}`
});
}
const result = [];
for (let i: number = 0; i < decoders.length; i++) {
const nth = decoders[i].decode(json[i]);
if (nth.ok) {
result[i] = nth.result;
} else {
return Result.err(prependAt(`[${i}]`, nth.error));
}
}
return Result.ok(result);
} else {
return Result.err({message: expectedGot(`a tuple of length ${decoders.length}`, json)});
}
});
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run tsc and inspect decoder.ts around line 432, focusing on the Result narrowing in Decoder.tuple. Confirm the TypeScript compilation error is resolved and tsc completes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100