Is it possible for Go's http server to compile TypeScript?

My current setup involves a NodeJS Application that launches an http server and utilizes client side code written in TypeScript with Angular 2.

I'm curious if it's possible to achieve the same functionality using Go programming language?

I tried searching for information on using TypeScript and Go together but couldn't find anything relevant.

Do I need to have NodeJS installed, set up typescript compiler with npm install -g typescript, then compile the TypeScript files every time they are modified and serve the JavaScript files from my Go Server?

Any insights or guidance on this matter would be highly valued.

Thank you!

Answer №1

There are a few different paths you could take in this situation:

  1. You can opt to translate client side by integrating the typescript library into your html and incorporating

    <script type='text/typescript' src="/myscript.ts"></script>

  2. Alternatively, you could run tsc -w in the background and simply serve the compiled javascript. Starting it when your application launches ensures it terminates along with the app. I reserve running tsc in "dev" mode only, keeping the js files for production use.

  3. Another option is to run tsc as needed when requests come in, then cache the results. It may be challenging to detect changes, but there are available packages that can assist with this task.

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

Error in Ionic2 TypeScript: 'google' and '$' names not found, despite Google Maps and jQuery functioning correctly

I am currently working on developing an ionic2 application using TypeScript. Within the index.html file, I have attempted to integrate jquery and the Google Maps JS API before cordova.js: <!-- Vendor --> <script src="https://maps.googleapis. ...

I am running into issues while trying to complete the npm install process for Angular 2

I encountered an error in the command prompt: npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="34595d5a5d595540575c74061a041a0504">[email protected]</a>: To avoid a RegExp DoS issue, please up ...

Instructions for making a vertical arbitrary line on a financial graph

I came across this example on a website and it's functioning perfectly. The code creates a vertical line at the specified index location when x and y values are passed separately. example() { var originalLineDraw = Chart.controllers.line.prototype ...

Eliminating tail recursion for conditional types is ineffective

In TypeScript version 4.5, the feature of tail call optimization was introduced for recursive generics. The code snippet below calculates Fibonacci numbers (in unary) up to F12, but encounters an error when trying to compute F13 due to the "Type instantiat ...

Ways to rename a sequelize property following a join operation

I am encountering a problem with sequelize ORM. The data returned after joining has a nested object: { "id": 1, "username": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4125342e2f26252e282220 ...

Show real-time validation messages as the form control values are updated

Instructions: Visit Plunker Locate the input box labeled 'Name' Do not enter anything in the 'Name' field Move to the 'Email' field and start typing An error message will appear for the 'Name' field as you type in ...

Issues with card flip functionality in Firefox

I designed this animation specifically for my website to create a unique effect. The animation involves translating on the Z-axis, making it appear as though the object is getting smaller, flipping to reveal the back of the card, and then translating back. ...

Navigating Angular: Strategies for Managing Nested FormGroups in the HTML Template

I have recently started learning Angular and am currently working on creating a form for gathering user details. Imagine a scenario where a user can have a "friend" linked to them. This is how my FormGroup looks in a simplified version: userInformation = ...

Ways to implement a loading template with OnPush change detection technique

Currently, I am retrieving a route parameter: searchResults$: Observable<string[]>; constructor( private route: ActivatedRoute, private svc: SearchService) { this.searchResults$ = this.route.paramMap.pipe( map((p: ParamMap) => p.get(&a ...

Angular Material Datepicker with Selectable Date Range

In my project using Angular 8, I needed to incorporate a datepicker with highlighted date ranges. I came across an example image here: view image. I tried to find a suitable package like the one mentioned in this link: https://www.npmjs.co ...

Creating a Personalized Color Palette Naming System with Material UI in TypeScript

I have been working on incorporating a custom color palette into my material ui theme. Following the guidance provided in the Material UI documentation available here Material UI Docs, I am trying to implement this feature. Here is an excerpt from my cod ...

Provide a string argument when instantiating an abstract class

I am searching for a method to assign a name string within a class and utilize it in the abstract class at the constructor level, without the need for a function. Opening up the constructor is not an option due to using typedi. You can access the playgrou ...

The enigmatic dance of Angular and its hidden passcodes

Recently, I've been diving into learning Angular 2 and I'm exploring ways to safeguard the data in my application. I'm curious about how one can prevent data from being accessed on the front end of the app. Could serving the angular app thr ...

Customizing MUI DataGrid: Implementing unique event listeners like `rowDragStart` or `rowDragOver`

Looking to enhance MUI DataGrid's functionality by adding custom event listeners like rowDragStart or rowDragOver? Unfortunately, DataGrid doesn't have predefined props for these specific events. To learn more, check out the official documentati ...

Why is my Angular2 reactive form not submitting on button click? (Manually calling form.submit() using getElementById workaround)

When I click on <input type='submit' />, the form is submitted with a POST request and redirects me to mockURL, which is exactly what I want. In xForm.html: <form id="xForm" [formGroup]="xFormGroup" met ...

Exploring File Read and Write Functionality in Angular 4

I want to develop an offline Task List in Angular 4. However, I am facing difficulty in finding a method to save data in a file on the client side using JavaScript or Angular. My current approach involves using browser's localStorage, but it is slow ...

Troubleshooting Observable data in Angular 2/Typescript - A Comprehensive Guide

After going through the Angular 2 tutorial, I managed to create a search feature that asynchronously displays a list of heroes. <div *ngFor="let hero of heroes | async"> {{hero.name}} </div> In my component, I have an observable array of ...

The module '@angular/core' could not be located in the '@angular/platform-browser' and '@angular/platform-browser-dynamic' directories

Attempting to incorporate Angular 2.0.0 with JSMP, SystemJS, and TS Loader in an ASP.NET MVC 5 (non-core) application. Encountering errors in Visual Studio related to locating angular modules. Severity Code Description Project File Line Suppr ...

What does the reportProgress function do in HTTP services with JavaScript?

Can someone explain the functionality of reportProgress in JavaScript, specifically when used with Angular Typescript? I am having trouble finding documentation on this. return this.httpClient.request<ProductResponse>('get',`${this.basePath ...

The function response.body.getReader is not defined

While making a call to a web api using fetch, I encountered an issue when attempting to read the response as a stream. Despite calling getReader() on response.body, I received the error message: "TypeError: response.body.getReader is not a function". ...