Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

160 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
150 views

Hutton cipher implemented using recursive functions

Is there a way to rewrite these last 2 recursive functions with fewer arguments (preferably 2) while keeping them recursive? The entire code can be seen here: https://github.com/GirkovArpa/hutton-...
GirkovArpa's user avatar
5 votes
0 answers
565 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, ...
htmn's user avatar
  • 218
5 votes
0 answers
348 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 ...
Anthony Faull's user avatar
5 votes
0 answers
5k 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, ...
rveerd's user avatar
  • 151
5 votes
0 answers
52 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 ...
snowfrogdev's user avatar
4 votes
0 answers
1k views

RxJS - Prevent valueChange of one form control if another form group is dirty OR an HTTP error has occurred

I've recently started working on an Angular 7 project (I'm pretty new to Angular and RxJS), and I was requested to implement this new functionality: The Problem I have to implement a component to ...
user avatar
4 votes
0 answers
138 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 ...
feuGene's user avatar
  • 363
4 votes
0 answers
41 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 ...
Multitut's user avatar
  • 141
4 votes
0 answers
2k 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 ...
data's user avatar
  • 141
4 votes
0 answers
283 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 ...
Drakarah's user avatar
  • 141
3 votes
0 answers
65 views

Custom AutoComplete component with Typescript Generics

I've created my own AutoComplete form element based on @nextui-org/autocomplete to be able to use it along with react-hook-form. ...
kursat's user avatar
  • 131
3 votes
0 answers
108 views

Create a collection of truly unique objects of custom type

I'm using TypeScript for my Vue app and have a custom type I'm working with ...
spa7Pdnt's user avatar
  • 131
3 votes
0 answers
576 views

Use formats phone numbers into XXX-XXX-XXX

I created an input that accepts and formats phone numbers into XXX-XXX-XXX. The user should be able to type numbers and the dashes should insert themselves automatically. Example #1: The user types 1 ...
Alex's user avatar
  • 131
3 votes
0 answers
123 views

Testing a javascript function that performs side effects

Application context I am working on a game I call "Apes and Snakes". So far the code only allows players to connect to a host using a room code and WebRTC. Players and the host send messages ...
Samuel Cole's user avatar
3 votes
0 answers
30 views

Alternative Way of comparing multiple variable's to multiple variables

Hi guys Im very very new To Angular/Typescript Im teaching my self section by section by just messing around and figuring things out. Currently im just doing loop's and outputs so I decided to write a ...
Roy Lion's user avatar
  • 131
3 votes
0 answers
113 views

onChange Switch Handler

In react I have a HTML Element Factory, it allows several different types of form elements to be created most with the same onChange but some have specific uses. I have been capturing them in this ...
Terry's user avatar
  • 131
3 votes
0 answers
117 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 ...
sm12's user avatar
  • 51
3 votes
0 answers
124 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 ...
THpubs's user avatar
  • 81
3 votes
0 answers
211 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 ...
user avatar
3 votes
0 answers
118 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 ...
mrseanbaines's user avatar
3 votes
0 answers
207 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. ...
Adrian Brand's user avatar
3 votes
0 answers
73 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 ...
Enbyted's user avatar
  • 31
3 votes
0 answers
10k views

Mapping Entities to DTOs in TypeScript

In a recent project my backend architecture consists of Repositories (talking to database) Services (handling business logic) <...
pschild's user avatar
  • 131
3 votes
0 answers
115 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: ...
Alireza's user avatar
  • 91
3 votes
0 answers
193 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 ...
stephan.niedermayr's user avatar
3 votes
0 answers
95 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 ...
DylanSp's user avatar
  • 203
3 votes
0 answers
2k 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 <...
Igor Soloydenko's user avatar
3 votes
0 answers
42 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 ...
Jason Clement's user avatar
3 votes
0 answers
404 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 ...
Blexy's user avatar
  • 540
3 votes
0 answers
145 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 ...
Pace's user avatar
  • 131
3 votes
0 answers
182 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 ...
Jonathan's user avatar
  • 392
3 votes
0 answers
407 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 ...
Raed Khalaf's user avatar
3 votes
0 answers
635 views

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

I implemented an AsyncQueue, whose dequeue() operation returns a Promise. The ...
ComFreek's user avatar
  • 751
3 votes
0 answers
62 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 ...
Igor Soloydenko's user avatar
3 votes
0 answers
284 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 ...
Moshe's user avatar
  • 139
3 votes
0 answers
230 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 ...
Learner's user avatar
  • 131
3 votes
0 answers
151 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 ...
Mike's user avatar
  • 131
3 votes
0 answers
425 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 ...
Arran Bartish's user avatar
2 votes
0 answers
26 views

React/Typescript/Redux Tool Kit work flow for Category component

I'm quite new to React hooks/Typescript/Redux. I'm building a mock e-Commerce website for my portfolio. I've got a component (Category) working and rendering data with no issues, it follows the below ...
Corey's user avatar
  • 21
2 votes
0 answers
735 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
2 votes
0 answers
224 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
  • 4,294
2 votes
0 answers
168 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
2 votes
0 answers
136 views

Type-safe mixin builder

The purpose of this code is to provide a type-safe approach to apply mixins to classes. It also prevents duplicate mixins. The code depends on ts-toolbelt. It is divided into multiple files, but I've ...
Oliver's user avatar
  • 93
2 votes
0 answers
126 views

useActions hook function overload signature

Does the below TS type still need to be improved? I use actions: any as the more general signatures. Is there any better way? ...
Lin Du's user avatar
  • 159
2 votes
0 answers
44 views

Keyboard Tester Web Application in Vue 3 + TypeScript

I'm working on keyboard testing web application. As a mechanical keyboard enthusiast, I need to test that all the keys on my keyboard work whenever I build one, or change the firmware for one. ...
hwrd's user avatar
  • 151
2 votes
0 answers
38 views

I’d like some feedback on my theme system implementation in TypeScript for my website

I’m currently building myself a website using GitHub pages. I wanted to have a theme system, and recently rebuilt my implementation. It now manages a <style> ...
schuelermine's user avatar
2 votes
0 answers
55 views

How to reduce the Cognitive Complexity of this code based on Thomas J. McCabe’s Cyclomatic Complexity

I know there are if, then, else and switch. But the code below is a mixture of if, then else, else if, else. ...
Peter B's user avatar
  • 21
2 votes
0 answers
95 views

How to abstract DOM manipulation in a simple intuitive way

I am building a library to abstract DOM manipulation. Here's what the usage looks like: ...
eguneys's user avatar
  • 121
2 votes
0 answers
47 views

How to best persist context to local storage

I want to be able to persist context to local storage. My router looks like: ...
Bill's user avatar
  • 121
2 votes
0 answers
93 views

what should be the best approach to follow DRY principle here

My first component ...
Dewanshu's user avatar
  • 129