Primarily in playlists.ts, I'm using type annotations like
{
action: 'comment',
message,
timestamp: new Date(),
userId: res.locals.userId,
} as SituatedChatEvent
For auto-completion convenience, however this is very unsafe as a property could be missing and typescript would not give me an error (similar to the problems in microsoft/TypeScript#7481 (comment) and that issue in general). It seems the best way to fix this is either to move expressions like this into a temporary variable with a variable: Type annotation, or wrap the expressions in a util function like
function asType<T>(value: T) {
return value;
};
As suggested in the linked issue.
Primarily in
playlists.ts, I'm using type annotations likeFor auto-completion convenience, however this is very unsafe as a property could be missing and typescript would not give me an error (similar to the problems in microsoft/TypeScript#7481 (comment) and that issue in general). It seems the best way to fix this is either to move expressions like this into a temporary variable with a
variable: Typeannotation, or wrap the expressions in a util function likeAs suggested in the linked issue.