Skip to content

Commit

Permalink
make type literal to extend TypeTree (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegDokuka authored Nov 22, 2024
1 parent 8fe818e commit b2ba10e
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 @@ -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;
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 @@ -3372,31 +3372,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 b2ba10e

Please sign in to comment.