stable

Clone or download

Read-only

Type assertions should not be used in production code

Using type assertions to enforce the correctness of a value is incorrect. Type assertions is basically a way to tell to the Typescript's compiler that you know what's going on there and that it should trust you and move on. However when you force the compiler to assert the type of an expression it will still check for assignement compatibility as the last chance to prevent obvious mistakes [0][1][2]. The short version is that in our day to day production code we should not need to do type assertions. In most scenarios, if the compiler is not capable to infer the type it might be a sign that the code as deeper issues and we should seek to resolve them. In any cases type assertions should not be used to make sure a value if of the expected type since the compiler will only check if the value "looks like" the expected type. Part of story #13641: See solo cards in their column [0] https://github.com/microsoft/TypeScript/blob/v3.6.3/doc/spec.md#4.16 [1] https://github.com/microsoft/TypeScript/blob/v3.6.3/doc/spec.md#3.11.4 [2] https://github.com/Microsoft/TypeScript/issues/20849#issuecomment-353717944 Change-Id: I79355a750d6311ed1bbeed0f5b0b401a6443aa3f

Modified Files

Name
M plugins/taskboard/scripts/taskboard/src/store/error/index.ts +3 −2 Go to diff View file
M plugins/taskboard/scripts/taskboard/src/store/index.ts +4 −2 Go to diff View file
M plugins/taskboard/scripts/taskboard/src/store/swimlane/index.ts +3 −2 Go to diff View file
M plugins/taskboard/scripts/taskboard/src/store/user/index.ts +1 −1 Go to diff View file