Programmatically generate Interface with TypeScript
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Sharing here this exciting project, for which I don't have enough time myself.

Foundation for this project can be found here:
Check the readme; Clone and fork at will.

The task is, based on the resource files found in the resources folder, to programmatically create the corresponding interface that should match

The generation code is to be added to generator.ts

usage-sample.ts can help to make sense of this. It's all about providing a strongly-typed library with a nice documentation. Mouse over the properties and functions from your intelligent code editor (I use VSCode) to see what I mean.

I expect questions regarding some generation rules. I may update the repo with additional info and clarification. Check back often.

Granted, there is some scale to this task. I can accept incomplete generators.

Looking forward to what you can get done!


What's the syntax grammar for the Samples.Common.Translation resource? I see its content is "{ form, select, other {Internationalization} abbr_a {Internationaliz.} abbr_b {I18n} }", but I'm not sure how I should parse this.
feroldi 1 month ago
@feroldi. My bad. This should be "{ form, select, other {Translation} abbr_a {Transl.} abbr_b {T9N} }" I updated the repo accordingly
valentin1402 1 month ago
The syntax is ICU ( I don't think you need to parse it to be able to generate the interface
valentin1402 1 month ago
awarded to CyteBode

Crowdsource coding tasks.

1 Solution

Winning solution

It's not perfect, but here's my solution:

I didn't deal with the ICU Message Formatters and I had to make a couple changes to the resource files in order for things to make more sense. All those changes are in the first commit.

There's also some differences with the empty lines/comments and semicolons, but it's still semantically the same in the end.

Hi CyteBode! That's quite a pleasing code :-) Thanks for pulling it together.
valentin1402 1 month ago