Type ‘unknown’ is not assignable to type …

TypeScript tries to make sure the variables are always populated with data of the type specified during the variable definition.


When the TypeScript compiler thinks a function can return another data type, or “unknown”, “undefined”, “null”, Visual Studio Code displays a warning:

type ‘unknown’ is not assignable to type …


The solution is to explicitly convert the return type to the expected one:

let soObject: SsoObject = <SsoObject> decodeJWT(ssoCookie);

Leave a comment

Your email address will not be published. Required fields are marked *