ts-blank-space
Advanced tools
Comparing version
@@ -152,4 +152,4 @@ // Copyright 2024 Bloomberg Finance L.P. | ||
case SK.SetAccessor: return visitFunctionLikeDeclaration(node , kind); | ||
case SK.EnumDeclaration: | ||
case SK.ModuleDeclaration: return visitEnumOrModule(node ); | ||
case SK.EnumDeclaration: return visitEnum(node ); | ||
case SK.ModuleDeclaration: return visitModule(node ); | ||
case SK.IndexSignature: blankExact(node); return VISIT_BLANKED; | ||
@@ -520,6 +520,14 @@ case SK.TaggedTemplateExpression: return visitTaggedTemplate(node ); | ||
function visitEnumOrModule(node ) { | ||
function visitModule(node ) { | ||
if ( | ||
(node.modifiers && modifiersContainsDeclare(node.modifiers)) || | ||
(node.kind === SK.ModuleDeclaration && !valueNamespaceWorker(node )) | ||
// `declare global {...} | ||
node.flags & tslib.NodeFlags.GlobalAugmentation || | ||
// `namespace N {...}` | ||
(node.flags & tslib.NodeFlags.Namespace && | ||
// `declare namespace N {...}` | ||
((node.modifiers && modifiersContainsDeclare(node.modifiers)) || | ||
// `namespace N { <no values> }` | ||
!valueNamespaceWorker(node))) || | ||
// `declare module "./path" {...}` | ||
node.name.kind === SK.StringLiteral | ||
) { | ||
@@ -534,2 +542,12 @@ blankStatement(node); | ||
function visitEnum(node ) { | ||
if (node.modifiers && modifiersContainsDeclare(node.modifiers)) { | ||
blankStatement(node); | ||
return VISIT_BLANKED; | ||
} else { | ||
onError && onError(node); | ||
return VISITED_JS; | ||
} | ||
} | ||
function valueNamespaceWorker(node ) { | ||
@@ -536,0 +554,0 @@ switch (node.kind) { |
{ | ||
"name": "ts-blank-space", | ||
"description": "A small, fast, pure JavaScript type-stripper that uses the official TypeScript parser.", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "homepage": "https://bloomberg.github.io/ts-blank-space", |
48711
1.18%724
2.4%