Allow default imports in TS

This commit is contained in:
Dan Vanderkam
2020-07-21 17:04:23 -04:00
parent 9a34334b99
commit 4d07aeaa8a
3 changed files with 174 additions and 164 deletions

View File

@@ -2,6 +2,7 @@
"compilerOptions": {
"strictNullChecks": true,
"noImplicitAny": true,
"module": "commonjs"
"module": "commonjs",
"esModuleInterop": true
}
}

View File

@@ -0,0 +1,5 @@
/// <reference path="./xss.d.ts" />
import xss from "xss";
console.log(xss("<script>alert('xss');</script>"));

8
typings/xss.d.ts vendored
View File

@@ -4,7 +4,8 @@
* @author Zongmin Lei<leizongmin@gmail.com>
*/
declare global {
declare module "xss" {
global {
function filterXSS(html: string, options?: IFilterXSSOptions): string;
namespace XSS {
@@ -116,7 +117,6 @@ declare global {
}
}
}
export interface IFilterXSSOptions extends XSS.IFilterXSSOptions {}
export interface IWhiteList extends XSS.IWhiteList {}
@@ -187,3 +187,7 @@ export const stripCommentTag: EscapeHandler;
export const stripBlankChar: EscapeHandler;
export const cssFilter: ICSSFilter;
export function getDefaultCSSWhiteList(): ICSSFilter;
const xss: (html: string, options?: IFilterXSSOptions) => string;
export default xss;
}