Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

139 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
197 views

React Context & Hooks custom Vuex like store

I've been experimenting with Hooks lately and looking more into how can I replace Redux with useContext and useReduer. For me, ...
5
votes
0answers
156 views

Reference enum values in Angular template without aliasing the enum type

Is there a way to improve this code? I'd like to use the enum type PaymentMethoddirectly in the angular template without renaming it to ...
5
votes
0answers
41 views

Macao, a General Game Playing AI library - Game state goes in, best move comes out

I'm working on a simple General Game Playing AI library. The idea is that it should work with almost any kind of game, with a minimum of configuration. At the moment, I have it working on 2 player ...
4
votes
0answers
119 views

Model profit/loss of a time series of financial position state changes

I'm newly exploring time series databases, and trying to wrap my head around what data I'll store and how I'll query it. Also, I'm relatively new to TypeScript. This prototype exercises my current ...
4
votes
0answers
34 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 ...
4
votes
0answers
464 views

Automatically generate TypeScript classes from database tables

Made a project to generate TypeScript classes from database tables, and I'm looking for input if the code is reasonable. pg and ...
3
votes
1answer
72 views

Extending react hook useState for use in event handlers

I use React with material-ui.com and I love them both, but I'm tired with writing the boilerplate handlers like ...
3
votes
0answers
93 views

@angular/fire Firestore cached service

I've written a service for firebase that handles all my Firestore calls. The goal is to only read the database once on app init( load() function) and then keep a copy of the database inside local ...
3
votes
0answers
76 views

A reusable card component

I tried to create a reusable component which would allow the user to create cards which can have a header, cover image, avatar section (image, title and sub title), a description, a table, a list and ...
3
votes
0answers
89 views

Create one class to perform all type orm functionalities

I'm trying to create a separate package in a monorepo to handle TypeORM functions. So if I have two APIs (User API, Admin API), both can refer to the same package ...
3
votes
0answers
68 views

Flashcard Website

In my endeavor to learn Angular, I've created a flashcard site with an F#/Mongo backend. As I'm new to Angular, I'm going to post everything; any and all feedback is welcome. First, some pictures of ...
3
votes
0answers
86 views

Copy-to-clipboard function from a React.js component

I have a React component with a copyToClipboard method, which all works fine, but feels extremely verbose and quite hacky (namely, having to create a new select ...
3
votes
0answers
71 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. ...
3
votes
0answers
56 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 ...
3
votes
0answers
109 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: ...
3
votes
0answers
67 views

Override prototype inside of constructor of ES6 class for dependency injection

We implemented a small dependency injection mechanism which we use in our project. Now after 2 years of developing our project we need our classes to know who instantiated them via dependency ...
3
votes
0answers
84 views

Tic Tac Toe game (Game logic, no UI)

I've implemented a simple class for managing a Tic-Tac-Toe game's logic and state in Typescript. This code is intended to be used by a larger program; it doesn't implement any aspects of a UI. I've ...
3
votes
0answers
3k views

Angular async pipe with loading spinner and manual refresh

I have an Angular 6 app with the following requirements: Get data from a web service. Load the data when the page is displayed. Reload the data when the user requests a reload by through some UI, ...
3
votes
0answers
164 views

Optimizing NICK binary thresholding

NICK binary thresholding essentially boils down to a convolution where the kernel at each pixel calculates the sum and squared sum (for the standard deviation). These values are then used in the ...
3
votes
0answers
33 views

The Beginnings of a HexCells Editor

This is my first foray into a full TypeScript program, and one I decided to do for fun and without the aid of jQuery. It is also my first time developing with the HTML canvas. That's quite a lot of ...
3
votes
0answers
396 views

Filter properties and format values if they are currency

The function I've written in Typescript works great, but I'm not convinced that it's the cleanest and most efficient function. The function takes an object, omits properties found in an array, and ...
3
votes
0answers
93 views

Boilerplate-free mixin pattern for a TypeScript charting library

The TypeScript handbook provides a mixin pattern but it requires a bunch of boilerplate, doesn't work for getters/setters and doesn't support defining default values (or any constructor work) in the ...
3
votes
0answers
180 views

Build dynamic HTTP service with Angular

I have an Ionic application, this application contains set of pages and services. Since I'm working with Ionic and Angular I decided to build reusable code for different projects, for example: HTTP ...
3
votes
0answers
391 views

Blocking Promise-driven queues with ECMAScript's async/await and generators

I implemented an AsyncQueue, whose dequeue() operation returns a Promise. The ...
3
votes
0answers
55 views

“Academic interest” implementation of a Finite State Machine

Context I'm playing around the concept of a Finite State Machine. While I understand the basic principles behind it, I want to implement a simple, yet generic class which could be reused in the ...
3
votes
0answers
272 views

Vehicle price calculation Angular service

I have written a service which can generate prices from inputs. However, I feel that this can be "refactored" because it is not flexible enough. The code "works" however I feel if I could make this ...
3
votes
0answers
88 views

Optionally disabling a call-tracing decorator in Typescript

I have a Typescript decorator that traces method calls. The decorator can be applied at both the class level and method level. I want to disable the decorator in production. Is this code the most ...
3
votes
0answers
132 views

React.JS functional paradigm

I have some (minimal) experience with the functional programming paradigm and I'm new to React.js and reactive programming. I'm trying to get a flavour for the React.js philosophy and I keep seeing ...
3
votes
0answers
412 views

Publishing angular-cli component library to npm or like

I've found a lot of blog posts that seem to suggest publishing a library TypeScript (as source) and all to npm or to a private repository. It feels like we should be doing some transpiling first and ...
2
votes
0answers
15 views

Actions component in Angular

I have an action bar component. It helps do the CRUD operation for different component. Its only job is emit events. The emitted events are listened by the caller component. I am using a switch case ...
2
votes
0answers
95 views

Typescript QuadTree

everybody. It took a tree of squares for my web game. I wrote a preview using Typescript. I would like to hear from you tips on how to improve the code (I just started writing in Typescript). First ...
2
votes
0answers
74 views

Loading weak cache in typescript

In Java, I use a LoadingCache which offers weakKeys and I need something similar in Typescript, so I wrote the following: ...
2
votes
1answer
28 views

build up object[] from raw data set

I have a list of raw data like following mockData and need to generate to a object[] format, some key-value pair are required from raw data like first, last, state. but some key-value pair are option ...
2
votes
0answers
21 views

Object oriented behavioural project structure in Typescript

This code structure allows me to quickly create and manage behaviours on p5.js sketches. I'm planning to move to Java but wanted feedback beforehand. The behaviour interface: ...
2
votes
0answers
161 views

Method to hide/show table columns with React/JSX

I am writing a function inside of a React component to hide/show columns in a table. The table is generated from an imported config object containing objects which model the column data. We render by ...
2
votes
0answers
32 views

Credit Card Form using RXjs

I am trying to improve my skills and I'd like to work on avoiding bad practices and mistakes. Can anyone skim over my code and point out what should have been implemented more efficiently or in a ...
2
votes
0answers
29 views

Codewars: Remote Control Virtual Keyboard

This is my solution to the Codewars problem TV Remote (symbols). Description In short, you are given a virtual keyboard with 3 modes between which can be switched by pressing the ...
2
votes
0answers
260 views

Redux pagination transducer

Motivation In my web app (React, Redux, TypeScript) we have a common need to write paginated API calls, with various UI interactions (infinite scroll, prefetch pages in the background, or manual page ...
2
votes
0answers
38 views

Composable async methods

Given a class where the methods return this you can chain them. const e = new Example() e.add(1).add(1).add(1).add(1).add(1) ...
2
votes
0answers
30 views

Property typed lodash compose function

Here I created a typed version of lodash flow that offers more specific typing. I'm curious if this exists in any other library, which optimized in tying any way —...
2
votes
0answers
52 views

Reduce repetition in these Redux CRUD actions

My React application manages some entities. I'm using Redux (with redux-thunk) to manage the application state. I've created a RESTClient based on Axios: ...
2
votes
0answers
64 views

DDD - Interaction between 2 entities

I've been taking a crack at Domain Driven Design, SOLID principles, and unit tests to write more maintainable code in the future. Though I tend to run into the same issue: While I have many classes/...
2
votes
0answers
55 views

Need feedback for a anglar 8 simple calendar appplication with the abilily to show to dos

I just built a simple calendar app using angular 8. I would like to get some suggestions for improvements in the project. any feedback will be appreciated. I would like to know what I could have done ...
2
votes
0answers
91 views

Simple Tictactoe game in Typescript

I'm mostly wondering if I can simplify the code. I've been told that it's needlessly complicated. HTML: ...
2
votes
0answers
17 views

Submiting form and transform model to match backend

I have different model in frontend and backend. When I submit form in frontend I need to transform that object to match backend model. Is there a better way than this one: ...
2
votes
0answers
54 views

RxJs observables pipes SwitchMap and async with typealong search input

I'm using RxJs for type along search, I setup an observable to emit a value after 1 second so it behaves like http with delay. I subscribe to it via the async operator in the template, the component ...
2
votes
0answers
22 views

Recuperate user's details into fake JSON server

This is the 'details.ts' which define the user's details that I want to recuperate in a JSON (user's role, logintime, duration). ...
2
votes
0answers
47 views

Calculate reservation cancellation penalty based on date difference

The website I'm developing allows customers to book an appointment. They can also cancel their appointment with the following rules: if the appointment is cancelled between 48 hours and 1 hour in ...
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
374 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 ...