Agreed. We migrated most of the ES6 codebase to Typescript, and it feels great.
We have an angular.js app that makes REST calls. The Java backend has DTOs (data transfer objects) that are mapped by Jackson to json, and after migrating to Typescript, we also run the DTOs through compile-phase that generates corresponding typescript interfaces.
i.e.
in Java:
public class PersonInfo { // the dto for person
public final String name;
public final PersonId id; // we have a class for each id type
public PersonInfo(...) { ... }
}
@RestController
public PersonController {
@RequestMapping("/get-person-info")
public PersonInfo getPersonInfo(@RequestParam int id) {
// dummy example
return new PersonInfo("Peter Jackson", id);
}
}
In the java->typescript generator we add the controllers for which we need the rest API definitions to be generated as typescript interfaces:
It's custom made. We are extracting it from our current project, anyway, so I'll ask the dev responsible if he would release it as open source project.
We have an angular.js app that makes REST calls. The Java backend has DTOs (data transfer objects) that are mapped by Jackson to json, and after migrating to Typescript, we also run the DTOs through compile-phase that generates corresponding typescript interfaces.
i.e.
in Java:
In the java->typescript generator we add the controllers for which we need the rest API definitions to be generated as typescript interfaces: And when the generator is run, a typescript file is generated with following definitions: