0

We are developing a Web API RESTful service in C# and UI in React + Typescript.

After I renamed/add/remove some proeprties in C# REstAPI models the web UI stopped to work, because I forgot to rename it in UI.

Futhermore it is for me almost impossible to find all usage of API calls of such objects.

I would like to configure strongly typed, compiled time checked system that typescript object will be mapped somehow to C# object and compiler will check it.

I can image that I (programmer) would mark javascript/typescript object with some metadata (C# namespace and class name).

How can I do that.

1
  • Have you tried writing your own compiler? :) Commented Nov 17, 2018 at 7:23

1 Answer 1

1

The key to resolving this issue is to abstract out a level to a configurable multi-language definition. From that definition you will be able generate both c# and typescript object definitions. The two major type descriptive options are Protos , and OpenApi from Google/Microsoft respectively.

This allows your workflow to become:

  1. Change the type configuration.
  2. Build the type configuration into the C# and Typescript definitions.
  3. Build the C# and Typescript libraries.

This ensures the object definitions are always in sync as the C# and Typescript libraries can depend directly on the auto-generated code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.