TypeScript 3.0 introduces a new top type unknown. unknown is the type-safe counterpart of any. Anything is assignable to unknown, but unknown isn’t assignable to anything but itself and any without a type assertion or a control flow based narrowing. Likewise, no operations are permitted on an unknown without first asserting or narrowing to a more specific type.
- https://mariusschulz.com/blog/the-unknown-type-in-typescript#:~:text=The%20main%20difference%20between%20unknown,on%20values%20of%20type%20any%20.
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#new-unknown-top-type
- DO use type gurads when you need to distinguish between type. You can use
typeof
andinstaceof
type guards if writing a type guard function is overkill.