简体   繁体   English

如何找到 xss-clean npm 库的类型定义文件

[英]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.我刚开始学习typescript,刚开始将我的nodejs/express应用程序转换为typescript。
I have successfully got all types for the library using npm i @types/some-lib我已经使用 npm i @types/some-lib 成功获得了库的所有类型
only library, I can't find was npm i @types/xss-clean where to find this library只有图书馆,我找不到是 npm i @types/xss-clean 在哪里可以找到这个图书馆

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.如果库没有很多 TypeScript 用户,则很可能不存在已发布的类型。 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 :您可以创建一个类型定义文件,例如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.您可以使用此页面来查找 package 是否具有类型。 xss-clean does not seem to have any types yet, so you would have to declare them by yourself. xss-clean似乎还没有任何类型,所以你必须自己声明它们。

More info on that here .更多信息请点击此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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