Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

142 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
21 views

Error handling in express without middlewares and using class structure

This is a simple implementation of Django's sample project "Poll" using and express. The controller code: ...
2
votes
0answers
388 views

Angular 8: Scroll spy implementation for a timeline Contents

I have made a timeline component that can have multiple milestone/major/minor as sub components nested within timeline container component. I have also added a side navigation for that lists all ...
2
votes
0answers
33 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 ...
2
votes
0answers
730 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 ...
2
votes
0answers
663 views

Mapping nested arrays from API response

I have some selects on my html page that I want to populate with the response from my backend API. The response looks like this JSON response ...
2
votes
0answers
146 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 ...
2
votes
0answers
32 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 ...
2
votes
0answers
163 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 ...
2
votes
0answers
35 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 ...
2
votes
0answers
486 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. ...
2
votes
0answers
75 views

Addition of defaults to components in AngularJS

I wrote a small module in typescript that augments the angularjs registerComponent function to provide a new way of default values for the component controller. ...
2
votes
0answers
885 views

Robot on a Grid: Find a path between two corners with forbidden cells on the road

Problem statement The problem is defined in the book as following: 8.2 Robot in a Grid Imagine a robot sitting on the upper left corner of grid with r rows and <...
2
votes
1answer
401 views

Parse big JSON for reactive form

I implements big reactive form on angular5. This form get data from JSON. I use formBuilder and several nested formGroups. Every field have default value before rendering form. In console output form ...
2
votes
0answers
121 views

Space shooter game in TypeScript

I recently started learning TypeScript and created a small space shooter. I would like to get some feedback on the structure of my code. I have some classes with both static and instance methods with ...
2
votes
0answers
52 views

Class to handle complex form using Angular ReactiveForms

I'm working with the ReactiveForms in Angular5 and trying to find a good way to do this. So, in my use case, I have a FormGroup inside my example.component.ts and when I need to add some FormControl ...
2
votes
0answers
2k views

Angular 5 Forms - Extending Form Control

Currently taking a first pass at Angular Forms with some colleagues and I'm noticing an interesting design pattern implemented by a coworker where the FormControl is being extended to allow for ...
2
votes
0answers
2k views

RXJS queue up multiple http requests and send when x conditions happens

Just started to use rxjs few weeks ago, I think I'm getting most of it right, but my code seems to be not that efficient and prone to bugs I haven't run into yet! I need to be able to send http ...
2
votes
0answers
2k views

Creating a logger that wraps around winston and express-winston

I am trying to create a logger wrapper around winston and express-winston (enables middleware error log) that is configurable . How could i improve this code? //logger.ts ...
2
votes
0answers
25 views

Adjust Hours on UTC String to Account for TimeZoneOffset

I have a library that provides a time-picker HTML element, which takes a UTC string as an input. The timepicker adjusts any UTC string it receives to local time. So, for example, if it takes ...
2
votes
0answers
241 views

Alpha Beta Pruning

I'm implementing alpha-beta pruning for a chess engine in TypeScript Here's the code: ...
2
votes
0answers
337 views

Wrapping MongoDB Call Results in Observables

I have a number of functions that follow the basic pattern below. The intent is to provide a MongoDB implementation for a storage interface in a TypeScript application. Is there a better way to ...
2
votes
0answers
2k views

Reusable REST service class for Angular2 in TypeScript

I am creating an Angular 2 web application using TypeScript. This application performs REST requests to a REST "service". For each REST resource in my service I create a separate "Service" class in ...
1
vote
0answers
20 views

React with Typescript - stopwatch component

I've been trying to learn React and I'm currently building a time-tracking application. The-end goal of the app will be for users to be able to track time against different tasks from different ...
1
vote
0answers
33 views

Typescript Express - Controller in Controller via dependency Injection or logic in routes

I'm trying to give one Controller one operation. However, some Controllers exists of 2 or more operations. I'm not sure whats the best way to structure this part of the app. For example, I have 2 ...
1
vote
0answers
28 views

Await all HTTP request body chunks before moving on

I'm developing a man-in-the-middle proxy that will let the user see and modify HTTP and HTTPS requests before they leave the client and responses before they arrive at the client. The code I'm working ...
1
vote
0answers
18 views

React App with Redux

Decided to give ReactJS + Redux + Typescript a try this weekend. Going to include the code first and then summerize a few questions that came into my mind during development. Also posting here to get ...
1
vote
0answers
74 views

React virtualized list dynamic width/height

I'm using react-window to virtualize a list. My list is supposed to fill in the container's completely and the container's width and height are 30vh and 100vh. ...
1
vote
0answers
84 views

create vscode tree item extesion

I use the following code to add tree item to vscode extension, Im getting the data and build the tree according to the entries I got, the code works. As I new to typescript I appreciate your feedback'...
1
vote
0answers
22 views

Angular ReactiveForm Error Association

I want to associate an error message to a Validator and not have to in the html check for a specific error. aka *ngIf="controls.name.required". I've seen generic error message helpers that build up ...
1
vote
0answers
19 views

Error handling approach for parameter errors in Typescript modules?

I have been tormented by the question of how to handle parameter errors by consumers of my modules, and also in classes which are extended from base classes. The particular sort of concern I have is ...
1
vote
0answers
27 views

Custom validator for reactive forms angular

I have created like this validator for reactive form, all working but I think I used so many statements, can somebody help me to make proper validation Here is my validator ...
1
vote
0answers
26 views

Adding conditional check to display information in Angular 8

I am displaying the following information in angular 8 application. I need to display only the partnerName if it exists. ...
1
vote
0answers
35 views

Is it possible to use “reduce” instead of for to set data to MapObject?

I want to remake and sort an array. Is it possible to use "reduce" instead of "forEach" or "map"? return beeProps.valueInfos.reduce (reduce()) would be great. Anything else looks like it could be ...
1
vote
0answers
23 views

Function that provides callback for promise or non-promise

Below I created a use function that wraps a promise or non-promise, providing the a value callback all-while preserving the original function type. ...
1
vote
0answers
74 views

Binary Heap module in Typescript/Javascript supporting min-heap and max-heap

About binary heaps: https://en.wikipedia.org/wiki/Binary_heap The purpose of this module is to allow quick and efficient priority queue management, compared to linked list. Efficiency: insert: \$O(\...
1
vote
0answers
51 views

Refactor this RXJS code

I have this angular service that is working perfectly but I'm feeling that it isn't very readable. How would you refactor it? (Simple tips as "try this instead of that..." are very welcome. I'm ...
1
vote
0answers
20 views

Angular 6+ Conditionally Chained HTTP Calls

I have a number of async calls that get chained conditionally based on the previous data dependency. I.e. perform call A -> if the result is defined/not an error execute a side effect, if not perform ...
1
vote
0answers
33 views

Media library project using Angular

Recently I created a small project: 'media library' (which allow to search, sort and filter items) and I will be glad if some give me constructive feedback about my code. The starting point is Angular-...
1
vote
0answers
45 views

React Native Lazy Collapsible Panel

What is it? React native Accordion Collapsible Panel. You pass the summary (always shown bit) and the detail (sometimes hidden bit). If the detail is passed as a function or promise (ie async ...
1
vote
0answers
74 views

TypeScript Salesforce client library wrapper

I have made a class which wraps the JSForce Salesforce API Client: ...
1
vote
0answers
56 views

React.js hook to validate a form on submission

I am fooling around with hooks in React and I'm stumbling against decisions that I need to make regarding implementation. Below is the code for the custom useForm hook which can be used to hook up ...
1
vote
0answers
21 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 ...
1
vote
0answers
120 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 ...
1
vote
0answers
26 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 ...
1
vote
0answers
134 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 ...
1
vote
0answers
34 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
0answers
11 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 ...
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 ...
1
vote
0answers
1k 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 ...
1
vote
0answers
43 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 ...