简体   繁体   中英

How to find type definition file for xss-clean npm library

I just started to learn typescript and just started converting my nodejs/express application to typescript.
I have successfully got all types for the library using npm i @types/some-lib
only library, I can't find was npm i @types/xss-clean where to find this library

import xss from 'xss-clean' //getting type definition error
app.use(xss())

If the library does not have many TypeScript users, chances are that no published types exist. In that case you can add your own to whatever degree of detail you wish.

You can create a type definition file, eg xss-clean.d.ts :

declare module 'xss-clean'
{
  const value: Function;

  export default value;
}

[More on declaration files]

You can use this page to look up if a package has types or not. xss-clean does not seem to have any types yet, so you would have to declare them by yourself.

More info on that here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM