This TypeScript issue in ServiceStack ignores namespaces, leading to duplicate declarations

Currently, I am exploring NativeScript and Angular2 with ServiceStack in C# as the backend.

To develop the application, I utilized the typescript-ref command to generate TypeScript classes for use with the JsonServiceClient in ServiceStack:

>typescript-ref http://192.168.0.147:8080 RestApi

Everything seemed fine until I noticed that it appears to be overlooking the fact that ServiceStack Services and Response DTOs are located in different namespaces on the .NET side:

https://i.sstatic.net/Nk3Oz.png

I have multiple branches of services where each service may have slightly different handlers between the branches. This setup works seamlessly in ServiceStack, especially with the Login and handlers functioning as expected.

For the app built with NativeScript/Angular2, I used the typescript-ref tool to create the restapi.dtos.ts. However, it seems to ignore the namespace disparity and produces duplicate classes instead (as seen in VSCode):

https://i.sstatic.net/jwdsT.png

The backend WS in ServiceStack follows a "branched" approach so I can avoid running different services on separate ports but rather consolidate them all on one port for simplicity and clarity.

Is there a solution to my issue?

Answer №1

It is important to avoid relying on .NET namespaces in your public facing Services Contract. While it may be supported in .NET Clients, it is not compatible with other languages that require each DTO to have a unique name.

It is recommended that your DTOs are distinct within your entire SOA boundary. This ensures that there is only one Test DTO that corresponds to a single schema definition. By doing so, when the DTO is transmitted through a Service Gateway, accessed via Service Discovery, or published to an MQ Server, it adheres to a singular DTO contract.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I prevent the enter key from working with Twitter Typeahead?

Is there a way to prevent the enter key from being pressed on an element within Twitter Typeahead's dropdown feature while using Angular with Typescript? I attempted to utilize preventDefault() when event.keycode === 13 on the ng-keydown event for th ...

Angular with Firebase: How to ignore a field in a query

I am curious to see if my current structure is compatible with Firebase, or if I need to make adjustments. Let's take a look at an example using the "/rooms" endpoint, which contains an array of Room objects: export class Room { id: number; p ...

Parent composition failing to receive emissions from Vue3 child component

Recently started learning vue and exploring event handling between Children and Parents. I've developed a child component with an emit exposed in the script setup: const emit = defineEmits(['OnTileClicked']) function TileClicked() { ...

Is it possible to omit the 'children' property when extending an HTMLDivElement in Typescript?

Currently, I have a SplitPane component that has the functionality to adjust the size of the second child to fill the remaining space whenever the first child's size changes. While this implementation works, I am looking to enhance the interface by ad ...

Maintain the spacing of an element when utilizing *ngFor

Using Angular.js and *ngFor to loop over an array and display the values. The goal is to preserve the spaces of elements in the array: string arr1 = [" Welcome Angular ", "Line1", "Line2", " Done "] The ...

When using TypeScript, a custom property name within a type declaration must explicitly point to a predefined symbol

An error has occurred in ...component.ts (..,..): A computed property name in a type literal must directly refer to a built-in symbol. Error message: Cannot find name 'any'. I am seeking an object that contains strings that have another stri ...

SignalR 2.2 application encountering communication issues with client message reception

I am facing an issue in my application where clients are not receiving messages from the Hub when a user signs in. Here is my Hub class: public class GameHub : Hub { public async Task UserLoggedIn(string userName) { aw ...

What is it about Kyle Simpson's OLOO methodology that seems to swim against the tide of Typescript's popularity?

Disclaimer: this post might come across as impulsive. Warning for Typescript beginners! Also, a bit of a vent session. Recently, I delved into the OLOO approach from the YDKJS book series within a Typescript and Node environment. // ideal JS syntax le ...

When implementing ReplaySubject in Angular for a PUT request, the issue of data loss arises

I seem to be encountering a problem with the ReplaySubject. I can't quite pinpoint what I've done wrong, but the issue is that whenever I make a change and save it in the backend, the ReplaySubject fetches new data but fails to display it on the ...

Setting up a custom PrimeNG theme to match our unique style is a great way to

I am currently using the most recent version of "primeng": "^12.2.0", and I am looking to implement my own custom theme for primeng. Despite searching through numerous blogs, I have yet to find a solution. In an attempt to create my cu ...

Defining the range of an array of numbers in TypeScript: A complete guide

When working with Next.js, I created a function component where I utilized the useState hook to declare a variable for storing an array of digits. Here is an example: const [digits, setDigits] = useState<number[]>(); I desire to define the range of ...

Troubleshooting the issue with integrating a user-defined Cordova plugin in Ionic 2 using TypeScript

I have developed a custom Cordova plugin and I am trying to integrate it with an Ionic 2 project that is using TypeScript and Angular 2. While I have successfully added the plugin to the Ionic 2 project, I am facing issues when trying to call methods defin ...

Unable to activate the 'Click' function in Angular/Typescript after selecting element with 'document.querySelector'

In my Angular 8 Project, there is an element on a page with a unique string attached to the attribute 'data-convo-id'. This element has a click function that loads data based on the data attribute specified above. However, without direct access ...

Important notice: It is not possible to assign refs to function components. Any attempt to do so will result in failure. If you intended to assign a ref, consider

My console is showing a warning when I use the nextJs Link component. Can someone assist me in resolving this issue and providing an explanation? Here is the message from the console: https://i.stack.imgur.com/jY4FA.png Below is a snippet of my code: im ...

Uncovering the array within a JSON object using Angular

I am attempting to display an array in the view of my Angular project Items.json { "tipo": "texto", "texto": "A school needs to send 5 students as representatives to a forum on environmental pollution. It was decided that 2 students should be from te ...

Obtaining the value from a defined inline script in Typescript

There is a generated value called "pageId" on the page, which is added inline in a script tag. <script> var pageId = @Model.Id </script> Now, I need to utilize this value in some Typescript (Angular App), but I am encountering an error statin ...

Developing applications in AngularJS that utilize a remote REST API for data retrieval

Is there a way to make a remote REST API call within an angular js application without enabling CORS on the server? Currently, my setup includes bower for dependency management, grunt for server and build task running, and angular js as the front-end fram ...

My Nextjs project is encountering deployment issues with both Netlify and Heroku

Whenever I attempt to deploy my application on Heroku or Netlify, I encounter an ERROR related to an incorrect import path. It's perplexing because the import is accurate and functions properly locally. Log ./pages/_app.tsx:7:27 6:31:19 PM: Type err ...

"Seeking guidance on getting my carousel functionality up and running in Angular 8 - any

I tried implementing a carousel from the Bootstrap 4 documentation, but it is only displaying one image. How can I modify the carousel to show all images? I am new to using Angular. Below is the code I have: <div class=" bg-success text-white py-5 tex ...

Removing redundant names from an array using Typescript

My task involves retrieving a list of names from an API, but there are many duplicates that need to be filtered out. However, when I attempt to execute the removeDuplicateNames function, it simply returns an empty array. const axios = require('axios&a ...