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