@travetto/transformer 3.0.0-rc.0 → 3.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/state.ts +2 -2
- package/src/util/decorator.ts +6 -3
package/package.json
CHANGED
package/src/state.ts
CHANGED
|
@@ -164,9 +164,9 @@ export class TransformerState implements State {
|
|
|
164
164
|
* Get list of all #decorators for a node
|
|
165
165
|
*/
|
|
166
166
|
getDecoratorList(node: ts.Node): DecoratorMeta[] {
|
|
167
|
-
return (node.
|
|
167
|
+
return ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? [])
|
|
168
168
|
.map(dec => this.getDecoratorMeta(dec))
|
|
169
|
-
.filter(x => !!x.ident);
|
|
169
|
+
.filter(x => !!x.ident) : [];
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
package/src/util/decorator.ts
CHANGED
|
@@ -24,11 +24,14 @@ export class DecoratorUtil {
|
|
|
24
24
|
/**
|
|
25
25
|
* Replace or add a decorator to a list of decorators
|
|
26
26
|
*/
|
|
27
|
-
static spliceDecorators(node: ts.Node, target: ts.Decorator | undefined, replacements: ts.Decorator[], idx = -1): ts.
|
|
27
|
+
static spliceDecorators(node: ts.Node, target: ts.Decorator | undefined, replacements: ts.Decorator[], idx = -1): ts.ModifierLike[] {
|
|
28
|
+
if (!ts.canHaveDecorators(node)) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
28
31
|
if (idx < 0 && target) {
|
|
29
|
-
idx = node.
|
|
32
|
+
idx = node.modifiers?.indexOf(target) ?? -1;
|
|
30
33
|
}
|
|
31
|
-
const out = (node.
|
|
34
|
+
const out = (node.modifiers ?? []).filter(x => x !== target);
|
|
32
35
|
if (idx < 0) {
|
|
33
36
|
out.push(...replacements);
|
|
34
37
|
} else {
|