Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

4
votes
0answers
16 views

Typescript monad for data being loaded

I have been struggling to make typescript happy about the types. I am pulling data from our backend API and I wanted to give context to the data. Basically it is a monad with 4 shapes: Initial (...
2
votes
0answers
20 views

The modularization of the Express entry point

I've been working on a project to make myself more comfortable with NodeJS, especially Express and TypeScript. Searching and reviewing a lot of approaches of the people, providing bootstraps for it, I ...
1
vote
0answers
19 views

Dynamically build tagged union and helper that allows its instantiation and calling of its static methods

I am working on a typescript react/redux app that provides a visual interface for the code editor with a predefined set of instructions. It's basically a tree structure of objects that I call ...
3
votes
0answers
25 views

Product allocation on trucks

The premise of this program is to use the least amount of vehicles to allocate the available load. What I did is allocate the largest amount of load on the truck that fits better. This program's ...
1
vote
0answers
18 views

Extract useMemo to its own custom hook

I wanted to know if the useMemo function extracted like this is valid at all. This is a whole component (Sorry for the imports) that uses useMemo to get a data that is grabbed from the server using ...
3
votes
0answers
33 views

Implementing custom observable classes

I want to implement my own custom observable class so I can have a hierarchy of components and the closest defined configuration item bubbles to the front. ...
1
vote
0answers
17 views

Dragging and dropping a spot using TypeScript

Currently my code is based around mouse events so that it is easier to test but I will be swapping these to touch events once I have had the code reviewed. The idea of the UX is that you need to ...
2
votes
1answer
50 views

Separating items into ordered and unordered lists

I'm trying to group all the types which have ordered-list-item & unordered-list-item into new object. How can I simplify the function and reduce multiple return statements? ...
2
votes
0answers
47 views

Communication with interactive program using ChildProcess

There is an interactive program, namely Microchip Debugger (Later called MDB), which I want to communicate with from NodeJS program. You can think about it as any console-based debugger - they all do ...
1
vote
0answers
36 views

vuejs vuex element-ui used to toggle a login dialog but req

I have a login dialog working in vue js with typescript. I want to trigger the open via a button on page, but also by toggling a value in the vuex store. It is working by 2 watchers: Watching the ...
2
votes
1answer
42 views

Primitive full-text search on some properties of an object

I am not a JS/TS Guru, so i wanted to ask if one could write this better. I needed a very primitive Full-Text-Search of some properties of an Object. What do you think? ...
1
vote
0answers
99 views

Accordion component with Angular 7

I have to made an accordion-, respectively "zippy"-component using Angular 7. I'm new to Angular. Just started with it a few weeks ago. But with some Google-usage I was able to implement the ...
1
vote
0answers
17 views

angular service for centralizing common grid functions

I have an angular 7 app that is data focused and as a result has dozens of grids. These grids are from the Kendo UI for ANgular component library made by Telerik. These grid components expose hooks ...
1
vote
1answer
33 views

Unit Test case to check if localstorage is empty once I logout of the Web app

I am trying to clear my localstorage when I am logging out of the application. I want to write a unit test case in Jasmine to check if this task is performed when logout function is run. I am writing ...
1
vote
0answers
9 views

RXJS and Ionic- Sequencial Subscriptions Waiting on User Action

In an Ionic App a user can open a new browser via "inAppBrowser". I'm trying to get the stats of the user before they go into to the inAppBrowser, get the stats again when browser closes, and then run ...
2
votes
1answer
51 views

Retry a Promise resolution N times, with a delay between the attempts

I want some JavaScript code to take 3 things as parameters: A function returning a Promise. The maximum number of attempts. The delay between each attempt. What I ended up doing is using a ...
2
votes
0answers
44 views

Angular polling and plotting component using Firebase

I could use some help refactoring my component and service. I have a lot of nested logic and wasn't sure what I could do to improve this. I'm new to Angular 7 and their piping syntax. I suspect this ...
1
vote
0answers
19 views

Versatile React component that maps style attributes

I'm creating a versatile component with styled-components that essentially just maps style attributes. I feel my type declarations seem inefficient in getting access to props. Is it appropriate to ...
0
votes
1answer
35 views
1
vote
0answers
13 views

Two Angular animations for modal dialogs

I'm using Ionic 4 and Angular animations to animate modals. I created the following two functions that control the animations but they share a lot of repeated code. Is there a way I can clean these up ...
0
votes
1answer
53 views

Angular pipe to suppress sensitive information

I have created an Angular pipe to suppress the sensitive information like credit cards, bank account, ABA numbers etc. This is working fine but I would like to know if this is the best possible way ...
1
vote
0answers
188 views

Stateless tooltip component using React hooks and ref

What I'm trying to create is a generic tooltip component that I can use anywhere. I decided on a stateless component and the use of hooks and ref. Explanation 💡 Hook, because I wanted to have a ...
2
votes
1answer
173 views

A countdown clock in TypeScript

The gist of the code is, you give it a date, it will start counting down how many days, hours, minutes and seconds left by emitting an event 'countDown' and once 0 is reached 'expired' event is ...
0
votes
1answer
61 views

JavaScript - Difference between two dates in days or less [closed]

I have 2 dates that I would like to have the difference between them in days and if less than a one day simply show "less than a day". ...
0
votes
0answers
20 views

Angular service that configures translations based on current business case

I have a simple Angular Service that pre-configures translations for the ngx-translate library based on the currently logged in business case. I'm not sure if my switch case statement within the if/...
1
vote
0answers
15 views

Optimistic validation on tab change

I have a rather large UI for editing a user within a Angular application. It is split in multiple tabs and in order to reduce complexity the user cannot change the tab unless there is no validation ...
1
vote
0answers
30 views

Angular Websocket service with wait for response sending

I am writing an Angular Websocket service that can send messages to a server and then can subscribe to the response. I am grateful for every suggestion to improve this. ...
4
votes
1answer
49 views

Searching a nested data structure for 2 attributes

So I have the following data structures ...
0
votes
0answers
15 views

Angular HTTP POST with Basic Auth and Form Data

I have an API that I need to use that requires 2 things Basic auth with user: username & password: api token The request ...
2
votes
0answers
64 views

String search function in typescript/angular

I'm trying to return a list of objects called orders based on a string search that the user enters. orders has a ...
1
vote
0answers
46 views

Angular component for select with custom input

I'm creating an Angular widget which combines a dropdown with a custom input. I've made it generic and am preparing a blogpost explaining my setup, and would love to get a review before I do so. The ...
1
vote
2answers
76 views

Get an array of currency exchange prices based on asset

Function getMarkets Makes a call to get Cryptocurrency Exchange data based on asset (USD, USDC, USDT) It calls the endpoint 3 times to return 3 arrays which are then returned to the callee. I have ...
1
vote
1answer
82 views

Angular component to render currency or date values

I have an Angular component and it is just a label which renders a value and if it has an associated pipe, the output of the pipe should be rendered as value of the label. But I don't want to declare ...
1
vote
0answers
292 views

Proper way to map Entities to DTOs in TypeScript

In a recent project my backend architecture consists of Repositories (talking to database) Services (handling business logic) <...
1
vote
1answer
50 views

Find closest greater and smaller number from a sorted array

I have a sorted array. It can be empty. I have to find its closest greater and smaller number. If the given number is present in the array, it will be considered as greater number. I implemented it ...
3
votes
2answers
83 views

Mean by properties in array of objects

I have this array of objects: ...
1
vote
0answers
18 views

Stream wrapper in node.ts

I like Node.js and typescript a lot, but i'm still pretty much a newbie with streams. I know how to use them, but I have trouble understanding how the work, what are the consequences of using them, ...
2
votes
0answers
33 views

Porting python's 'with' construct to TypeScript

Now that async generators are available in the platforms I care about, I figured I'd try porting Python's ingenious with construct to JS as a utility. My first stab ...
0
votes
0answers
27 views

Parse json data for forms

I have this form who get all the data from json, and serialized it to make it fill in the UI of material. I was thinking about making a class and name it parses who parse all the data for the ...
1
vote
1answer
104 views

Unit testing static method that imports environment file

I'm (very) new to writing unit tests and I'm wondering how I should approach testing a static method that constructs our API endpoints based on what the properties are set to in our ...
1
vote
1answer
110 views

Search Result with infinite scroll React component

I've coded a React component which should display search result and give the user the option to scroll down and retrieve 25 more objects to be displayed when the scrollbar hits the bottom. What I've ...
3
votes
0answers
101 views

Fetching user information along with user posts in Angular

Here is my code with 2 services, one is messageService which is used to get user messages: ...
2
votes
0answers
236 views

Typescript logger class

Looking for a critique of this simple logger class I'm working on in my transition to TypeScript. The purpose of the logging class is to just print to a console either info, warn or error messages. ...
0
votes
1answer
120 views

Arhitecture of Angular 7 online shop

I created online shop with angular 7 and I am not sure is good architecture. I created 5 modules: main module products shop-cart core admin I have service : ...
2
votes
1answer
78 views

List component using RXJS Angular

I have a small angular project, where I have an Article component to list articles with pagination system. The default page The placeholder loader page The main objectives are: Display the ...
1
vote
0answers
43 views

@bound decorator for TypeScript

I'm working on an angular codebase that very frequently uses constructs like: <c-whatever [action]='doSomething.bind(this)'> to pass reference to the ...
1
vote
0answers
14 views

Organization project and http-Client

I did not have experience with organization project and http-client. I suppose this is the right way. I have data-storage service where I store my data from server. ...
2
votes
1answer
62 views

Convert 'rgb()' string to hex string

The scenario is the following. I get the string from an HTML element via outerHTML and I need to convert the 'rgb(r, g, b)' part into the hexadecimal representation. I tried this with regex and it ...
2
votes
2answers
64 views

New password generation

...
1
vote
2answers
192 views

ACL express middleware implementation

I come to see you to help me improve an express middleware that allows you to control access resources by checking the rights of the user. The following code is supposed to be as generic as possible ...