Fix check watches after protobuf-es change#71
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| set.forEach((value: string | null) => { | ||
| deduped.push(value!); | ||
| }); | ||
| return deduped; | ||
| return Array.from(set); |
There was a problem hiding this comment.
I simplified this construction and removed the type assertion on line 303 by using a type predicate (the notNull function and its value is string syntax).
| JSON.parse(encodedResponse), | ||
| ); | ||
| const response = fromJsonString(DeveloperResponseSchema, encodedResponse, { | ||
| ignoreUnknownFields: true, |
There was a problem hiding this comment.
ignoreUnknownFields is because the fromJsonString function was complaining that duration was an unknown field (down in the check debug output). It isn't used in this app, so I'm telling the function to ignore it.
| const response = create( | ||
| DeveloperResponseSchema, | ||
| JSON.parse(encodedResponse), | ||
| ); |
There was a problem hiding this comment.
This was the problem - the value that comes back from the WASM service has a string value for one of its enum values, and typescript (and by extension the underlying JS) were treating those enums as ints. Using fromJsonString coerces that value to the correct enum value, which means that you can then compare to a static enum value. This check in particular was the one that was failing, because with the old code the LHS of that comparison was the string "MEMBER" instead of the numeric enum value.
| const developerRequest = JSON.stringify( | ||
| toJson(DeveloperRequestSchema, request), | ||
| ); | ||
| const developerRequest = toJsonString(DeveloperRequestSchema, request); |
There was a problem hiding this comment.
I also found this function while I was doing this work, and it seems like a better expression of what I'm trying to do.
Description
Follow-on to #70. I reached for the wrong helper functions for serialization/deserialization, which meant that the comparisons were wrong. This fixes that.
Changes
Will annotate.
Testing
Review. See that check watches still work as expected locally.