@travetto/transformer
Advanced tools
Comparing version 3.0.0-rc.0 to 3.0.0-rc.1
{ | ||
"name": "@travetto/transformer", | ||
"displayName": "Transformation", | ||
"version": "3.0.0-rc.0", | ||
"version": "3.0.0-rc.1", | ||
"description": "Functionality for AST transformations, with transformer registration, and general utils", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -167,5 +167,5 @@ import * as ts from 'typescript'; | ||
getDecoratorList(node: ts.Node): DecoratorMeta[] { | ||
return (node.decorators ?? []) | ||
return ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? []) | ||
.map(dec => this.getDecoratorMeta(dec)) | ||
.filter(x => !!x.ident); | ||
.filter(x => !!x.ident) : []; | ||
} | ||
@@ -172,0 +172,0 @@ |
@@ -27,7 +27,10 @@ import * as ts from 'typescript'; | ||
*/ | ||
static spliceDecorators(node: ts.Node, target: ts.Decorator | undefined, replacements: ts.Decorator[], idx = -1): ts.Decorator[] { | ||
static spliceDecorators(node: ts.Node, target: ts.Decorator | undefined, replacements: ts.Decorator[], idx = -1): ts.ModifierLike[] { | ||
if (!ts.canHaveDecorators(node)) { | ||
return []; | ||
} | ||
if (idx < 0 && target) { | ||
idx = node.decorators?.indexOf(target) ?? -1; | ||
idx = node.modifiers?.indexOf(target) ?? -1; | ||
} | ||
const out = (node.decorators ?? []).filter(x => x !== target); | ||
const out = (node.modifiers ?? []).filter(x => x !== target); | ||
if (idx < 0) { | ||
@@ -34,0 +37,0 @@ out.push(...replacements); |
74944
1926