I have a TypeScript project that uses CryptoJS library. The linter shows that I quote Property 'sigBytes' does not exist on type 'DecryptedMessage'. Where I can with no problem log this property into console. The code that yields this message:
let dec = CryptoJS.AES.decrypt(text, this.key, {iv: this.iv});
console.log(dec.sigBytes); // There it logs the property correctly
I got types definition from npm. I tried setting up variable dec as CryptoJS.LibWordArray like this:
let dec: CryptoJS.LibWordArray = CryptoJS.AES.decrypt(text, this.key, {iv: this.iv});
But the linter shows "Type 'DecryptedMessage' is missing the following properties from type 'LibWordArray': sigBytes, words"
The code runs fine, however I wonder about the best practice to fix this or similiar issues. Using any yields no warnings,
let dec: CryptoJS.LibWordArray = CryptoJS.AES.decrypt(text, this.key, {iv: this.iv});
but I'm not sure thats a good practice
Resolved the issue with keyword as (thanks to @Budaa suggestion):
let dec = CryptoJS.AES.decrypt(text, this.key, {iv: this.iv}) as CryptoJS.LibWordArray;