From b2ba10e031d228b3b8bb185dc86533ed44b52d03 Mon Sep 17 00:00:00 2001 From: Oleh Dokuka <5380167+OlegDokuka@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:56:26 +0200 Subject: [PATCH] make type literal to extend TypeTree (#155) --- openrewrite/src/javascript/tree/tree.ts | 2 +- .../test/javascript/parser/function.test.ts | 16 ++++++++-------- .../java/org/openrewrite/javascript/tree/JS.java | 8 ++------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/openrewrite/src/javascript/tree/tree.ts b/openrewrite/src/javascript/tree/tree.ts index 2ad8883e..cc915b0c 100644 --- a/openrewrite/src/javascript/tree/tree.ts +++ b/openrewrite/src/javascript/tree/tree.ts @@ -3686,7 +3686,7 @@ export class FunctionDeclaration extends JSMixin(Object) implements Statement, E } @LstType("org.openrewrite.javascript.tree.JS$TypeLiteral") -export class TypeLiteral extends JSMixin(Object) implements Expression, TypedTree { +export class TypeLiteral extends JSMixin(Object) implements Expression, TypeTree { public constructor(id: UUID, prefix: Space, markers: Markers, members: Java.Block, _type: JavaType | null) { super(); this._id = id; diff --git a/openrewrite/test/javascript/parser/function.test.ts b/openrewrite/test/javascript/parser/function.test.ts index 0b6f8887..16c84ca3 100644 --- a/openrewrite/test/javascript/parser/function.test.ts +++ b/openrewrite/test/javascript/parser/function.test.ts @@ -152,14 +152,14 @@ describe('function mapping', () => { ); }); - test.skip('parameter with anonymous type', () => { + test('parameter with anonymous type', () => { rewriteRun( //language=typescript typeScript(` - function create(c: { new (): Type }): Type { - return new c(); - } - `) + function create(c: { new (): Type }): Type { + return new c(); + } + `) ); }); @@ -170,7 +170,7 @@ describe('function mapping', () => { (function() { console.log('IIFE'); })(); - `) + `) ); }); @@ -183,7 +183,7 @@ describe('function mapping', () => { var hello = function hello() { return helloString; }; - `) + `) ); }); @@ -196,7 +196,7 @@ describe('function mapping', () => { var hello = /*a*/function/*b*/ hello /*c*/(/*d*/) { return helloString; }; - `) + `) ); }); }); diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java index b7490ce6..7f9d8ca6 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java @@ -3372,31 +3372,27 @@ public FunctionDeclaration withParameters(JContainer parameters) { } + @Getter @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) @RequiredArgsConstructor - final class TypeLiteral implements JS, Expression, TypedTree { + final class TypeLiteral implements JS, Expression, TypeTree { @With @EqualsAndHashCode.Include - @Getter UUID id; @With - @Getter Space prefix; @With - @Getter Markers markers; @With - @Getter J.Block members; @Nullable @With - @Getter JavaType type; @Override