Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

Filter by
Sorted by
Tagged with
0 votes
0 answers
32 views
+100

Spring Boot Account API with React Frontend and Identicon Integration

I have recently been exploring React and Spring Boot, and I would greatly appreciate your feedback on a practice application that I have developed. The application consists of a Spring Boot backend ...
thebluepandabear's user avatar
0 votes
0 answers
22 views

Removing Brackets and Bracketed Content from a String

I have a site that I made to parse parts of Wikipedia articles for me. Part of this is removing parentheticals and citations. I came up with the following implementation: ...
Christopher Fimbel's user avatar
1 vote
1 answer
157 views

Movies App with Vue 3 and TypeScript

I have made a Movies App with Vue 3, TypeScript and The Movie Database (TMDB) API. For aesthetics, I rely on Bootstrap 5. In src\App.vue I have: ...
Razvan Zamfir's user avatar
1 vote
0 answers
20 views

Asynchronous Generic Resource Pooler

A personal project I'm working on needs Worker (thread) pool. The libraries I looked at were too high-level for my needs, as I simply needed access to the Worker itself while the libraries offered ...
Slava Knyazev's user avatar
-2 votes
0 answers
26 views

shift the first n bytes of a Uint8Array stream (in form of AsyncIterable<Uint8Array>)

reading the first n bytes of a byte stream (in form of a AsyncIterable<Uint8Array>) feels cumbersome and error prone. Is there a better way to implement this? ...
Max Fichtelmann's user avatar
0 votes
1 answer
34 views

Creating functions in a hierarchy where they get the same arguments

When I write code, I tend to follow functional paradigms often. The main thing I try to do is use values returned from functions. What I notice though, is I end up having a sort of function argument ...
Vinn's user avatar
  • 119
0 votes
0 answers
20 views

Chaining react hooks using uniswap style template

I'm trying to chain react hooks together. I need to do the following Obtain the Balance of NFT's a user has Enumerate the balance of nft's and generate index arguments to call the RPC to get the ...
Ritzy Dev's user avatar
  • 111
1 vote
0 answers
21 views

Angular Lazy Loading Component into HTML template

I want create a generic component for lazy loading other component Demo online (click on load button) https://stackblitz.com/edit/angular-v7xfwb this is the code ...
ar099968's user avatar
  • 201
0 votes
0 answers
61 views

Promise queue Typescript

As an exercise, I wrote a promise queue in Typescript. The point of it is to parallelise a maximum number of promises, and not just Promise.all() to batter the ...
Lewis Farnworth's user avatar
5 votes
1 answer
288 views

Most compact data format for a shopping cart

I'm trying to build a format that can represent the user's cart on my website in the most compact way. The website is related to computer parts and there are 23 product categories. Each product has an ...
Raees Iqbal's user avatar
0 votes
1 answer
31 views

Choose a marker for the map based on the alerts it has

I need help to refactor this code, I think I can avoid the first two functions that filter the array. Also in the third part where I use the result of these two filters: ...
John Alberto López Hernández's user avatar
2 votes
0 answers
198 views

React hook to play audio with Web Audio API

My goal was to make playing sounds in my React game easy and efficient. Using <audio> tags wasn't an option, because on mobile it creates huge delays between ...
Robo Robok's user avatar
1 vote
1 answer
73 views

Function component wrapper for the js-year-calendar widget

I have this class component from the rc-year-calendar library. ...
Helder Batalha's user avatar
1 vote
1 answer
83 views

Rock, paper, scissors game in expressjs typescript

This is a simple 2 player game made in NodeJS and the ExpressJS framework with typescript. I've built using OOP approach to as far of an extent as I know of it. I'm really curious as to how further ...
Exodus Reed's user avatar
1 vote
0 answers
205 views

NextJS NextAuth Implementation using Custom Token Source

I am new to NextJS, it has somewhat been forced on me and the existing code was not authenticating correctly (after a period the site would hang - not return to login - this was due to the way we were ...
MoonKnight's user avatar
1 vote
1 answer
63 views

PaginationBar component that renders links or buttons depending on optional callback prop

I have several components/pages in my personal project that contain complex logic and even nested ternary operators. Since I'm the only person working on this project, I don't have a hard time ...
Florian Walther's user avatar
0 votes
2 answers
80 views

Complex statement in typescript get?

I have some get function like this ...
Miomir Dancevic's user avatar
0 votes
1 answer
91 views

Filter based on object field in TypeScript

I have four arrays of the same object which I use for a form. They work as pairs such as list_1 contains all possible values and ...
Neo's user avatar
  • 129
0 votes
2 answers
79 views

How to write repetitive styled components in a cleaner way

I'm using Styled Components for styling and there are many icons defined in the project so in the style file we have this code: my-component.styles.ts ...
Leo Messi's user avatar
  • 181
0 votes
1 answer
65 views

How to reduce the 'useEffect` hook to make more performance

I have created a tab Accordion. at present it works fine. it should: open and close on click ( shuffling ) on click of a tab other tabs should be closed if open ...
3gwebtrain's user avatar
0 votes
1 answer
75 views

Check if string starts with vowel

I am using a template for a text inputs and feedback messages to simplify my html code. This passes in variable string called label and populates the placeholder ...
WhatsThePoint's user avatar
1 vote
2 answers
81 views

Optimizing - formatting a person's name

I need to take a user's name and format it 'lastName, firstName middleName'. If firstName and middleName are not present then the comma should not be included with lastName. Below is what I came up ...
Samuel's user avatar
  • 21
2 votes
2 answers
255 views

React component which uses another component for rendering

Having this React component: ...
Leo Messi's user avatar
  • 181
1 vote
0 answers
42 views

Set-new-password form, including validation

I've got to make a form using Bootstrap and Angular, which validates the following requirements: Old password, new password and confirm password are mandatory fields. New password has to be equal ...
michael.zech's user avatar
  • 3,980
1 vote
1 answer
98 views

A graph interface for Wikipedia

I'm building a graph-based interface to explore Wikipedia, but I'm not really familiar with TypeScript/React (especially state management), so I really feel like I'm just Frankensteining things ...
Janice Lee's user avatar
0 votes
0 answers
31 views

Asynchronously building a service container in TypeScript

The compiler provides a synchronous use() method which accepts a middleware - that is a function that creates any services it wants, the ...
slepic's user avatar
  • 5,327
3 votes
2 answers
127 views

Get an `Object` that is the difference between O & O1

There was this type challenge: Get an Object that is the difference between O & O1 I ...
john's user avatar
  • 39
2 votes
1 answer
142 views

Two Sum Leetcode problem using Typescript

I've recently gotten into Typescript and I'm solving some Leetcodes to learn. Problem description: Given an array of integers nums and an integer ...
average norman's user avatar
1 vote
0 answers
25 views

Figure out all paths of all nodes up to k depth

I'm trying to figure out all the paths of all the nodes up to K depth. It seems to be a dynamic programming problem, my attempt seems to be working however its slower than I expected I would think ...
Ritzy Dev's user avatar
  • 111
0 votes
1 answer
56 views

typescript poker filter pairs from 7 card deck

I am making a poker game and poker-evaluator that I am using to tell me only the outcome from the cards ...
user266203's user avatar
1 vote
1 answer
39 views

DRY-ness of two typescript functions

Is there a way to make this code bellow more DRY or is this fine as it is? I am wondering if there could for instance be a way to combine the two functions in to 1, the output type of which would be ...
sev's user avatar
  • 183
2 votes
0 answers
108 views

Angular: ViewModel for safe two-way binding & MVVM

Introduction: Any angular dev should know that Angular tends to provide multiple ways of doing things. When it comes to forms, I tend to prefer to rely on forms of the template-driven variety, and ...
RTD's user avatar
  • 121
0 votes
1 answer
179 views

Awaited store for Svelte

In my Svelte app, I need to reactively fetch data from the server and then render the result. The ideal data struture for this is a store whose values are promises – eg. like this: ...
m93a's user avatar
  • 286
-1 votes
1 answer
35 views

A better way to write if this then this = this / number or * number [closed]

Im wondering if there is a better way to write these expressions in Angular 13, They dont fit most of my more senior compatriots code, And i'd like to not add messy conditionals if not needed. They ...
Someonesometime 's user avatar
0 votes
1 answer
37 views

Function to evaluate loan eligibility

I have a function and am wondering whether I have written it the most performant way by using multiple guard clauses in the code above some of the variable declaraciont. Here is my code: ...
user8758206's user avatar
1 vote
1 answer
56 views

Generic function accepting object and validators for this object's fields

I recently started TS. I was looking for feedback on my below function (for example maybe it can be written in shorter way). Let's assume we still use the reduce ...
user avatar
0 votes
0 answers
210 views

Angular Kendo date formatting directive

I created the following directive to format dates in kendo grid cells, in Angular: ...
Jason's user avatar
  • 385
3 votes
3 answers
87 views

Display random simpson quotes

I'm new to Typescript though I've got a few years experience with plain Javascript. This is the first full program I've built in Typescript using Next.js. I'm just curious about areas where I can ...
user avatar
0 votes
1 answer
40 views

Grouping countries and years

Here is an input array that contains country name, year and value. I need to group values by country and years. I use this approach that works for me, but I wonder how to optimize it: ...
user264870's user avatar
1 vote
0 answers
24 views

Creating a type safe wrapper function which provides some default parameters

I have a generic function "all" for which I want to create a helper function factory returning functions where some default parameters are set for the "all" call. The source I have ...
Kent Larsson's user avatar
0 votes
0 answers
71 views

Temperature Scale Converter in Typescript

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
0 votes
0 answers
133 views

SignalR multiple connection hub callbacks on SPA

Using VueJS plugin feature I created an NotificationHub, I have a requirement where I need to call hub multiple times on the same Vue screen. But this causes a lot of callbacks. so I am just ...
R4nc1d's user avatar
  • 361
2 votes
1 answer
52 views

Small typesafe assertion library, is()

I need to write a function with the following requirements (Programming TypeScript book by B. Cherny, Chapter 4, exercise 5): Implement a small typesafe assertion library, ...
user3132457's user avatar
0 votes
0 answers
20 views

Saving and validating data using http subscribe ExpressJS

I wrote some code to save data to the MongoDB database using ExpressJS. I'm concern about my validation, I think when I have more validations, it could be complicated to maintain it. WordController.ts ...
Pankwood's user avatar
  • 173
0 votes
0 answers
18 views

NextJS component that links to dynamically routed pages

I'm working on a project in NextJS for the first time, and I'm wondering what the right way to handle dynamic routing is. I have a http://localhost:3000/trips route ...
FlameDra's user avatar
  • 151
1 vote
1 answer
224 views

Converting one JSON schema to another

Recently on Stack Overflow, a now deleted question was wondering how to convert one particular model of JSON that their code was outputting to another. The OPs main issue was that the JSON generated ...
SomeStudent's user avatar
0 votes
0 answers
34 views

Developer experience for Nextjs Google Analytics library

I wrote this Nextjs Google Analytics library. The basic usage requires a component and a hook: ...
MauricioRobayo's user avatar
0 votes
1 answer
57 views

React Typescript Table Component

I built a table component for an admin panel app using React and Typescript. This admin panel is for a Discord bot where you can do your moderation solely through a web app. This table lists the ...
amicharski's user avatar
4 votes
1 answer
615 views

NextJS with a root level catchall route for all URLs dynamic middleware that splits into components

Here is the solution that I have. Due to the legacy product we have all of our URLs in one big Slug model in rails that maps URLs to models. EG ...
Romuloux's user avatar
3 votes
1 answer
947 views

TypeScript function to compare two arrays while ignoring case and whitespace

I'm just looking for general guidance on this short TypeScript function I implemented. Are there any glaring violations? Are there better practices for accomplishing this? Should I be using map/reduce/...
Bob Horn's user avatar
  • 203

1
2 3 4 5
11