I'm using btoa
method for hashing username, password which seems to work fine but this error shows up in my TypeScript errors - WebStorm. How to resolve this?
js code
let base64hash = btoa(user.username+ ':' + user.key);
tsconfig.json
/* tsconfig.json */
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016"
]
}
}
The reason that the compiler can't find the definition for btoa()
is that you're not including all the necessary libs.
When you use the --lib
compiler option you need to include all the libs that are included by default when you're not using this option.
In your case what's missing is the DOM
lib, so it should be:
/* tsconfig.json */
{
...
"compilerOptions": {
...
"lib": [
"es2016", "DOM"
]
}
}
As the definition for btoa is in the lib.dom.d.ts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With