softvar / secure-ls

:lock: Secure localStorage data with high level of encryption and data compression
http://softvar.github.io/secure-ls
MIT License
646 stars 82 forks source link

ERROR in node_modules/secure-ls/dist/secure-ls.d.ts(17,21): error TS1122: A tuple type element list cannot be empty. #40

Closed SabirHossain closed 4 years ago

SabirHossain commented 4 years ago

I'm trying to use secure-ls with Angular 6 it working fine but I get the error on build log

ERROR in node_modules/secure-ls/dist/secure-ls.d.ts(17,21): error TS1122: A tuple type element list cannot be empty.

import * as SecureLS from 'secure-ls'

Louies89 commented 4 years ago

I am also facing the same problem. If I ams importing it as import SecureLS from 'secure-ls', then it throws error

ReferenceError: localStorage is not defined at new SecureLS (C:\Users\Lui\Desktop\PO\purchase-order\frontend\node_modules\secure-ls\dist\secure-ls.js:130:16)

if importing import * as SecureLS from 'secure-ls' then it throws

cannot import class as function

@softvar can you help ?

softvar commented 4 years ago

Hi,

This package assumes that localStorage is present. In the case of NextJs Server-side Rendering, localStorage is not defined as node has no in-built support.

You should use this to have localStorage in the node. And once it is globally defined, you can use this lib: secure-ls to have additional functionalities like encrypting and compressing the data.

PS:

import * as secureLs from 'secure-ls';

works as intended.

Please let me know if you have any further doubts.