Skip to content

Commit

Permalink
make type literal to extend TypeTree
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegDokuka committed Nov 21, 2024
1 parent 6ce9ada commit 4e4740d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion openrewrite/src/javascript/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,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;
Expand Down
16 changes: 8 additions & 8 deletions openrewrite/test/javascript/parser/function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ describe('function mapping', () => {
);
});

test.skip('parameter with anonymous type', () => {
test('parameter with anonymous type', () => {
rewriteRun(
//language=typescript
typeScript(`
function create<Type>(c: { new (): Type }): Type {
return new c();
}
`)
function create<Type>(c: { new (): Type }): Type {
return new c();
}
`)
);
});

Expand All @@ -170,7 +170,7 @@ describe('function mapping', () => {
(function() {
console.log('IIFE');
})();
`)
`)
);
});

Expand All @@ -183,7 +183,7 @@ describe('function mapping', () => {
var hello = function hello() {
return helloString;
};
`)
`)
);
});

Expand All @@ -196,7 +196,7 @@ describe('function mapping', () => {
var hello = /*a*/function/*b*/ hello /*c*/(/*d*/) {
return helloString;
};
`)
`)
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3105,31 +3105,27 @@ public FunctionDeclaration withParameters(JContainer<Statement> 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
Expand Down

0 comments on commit 4e4740d

Please sign in to comment.