Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

206 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
1answer
4k views

Angular 5 Forms - Extending Form Control

I am taking a first pass at Angular Forms with some colleagues and noticed an interesting design pattern implemented by a coworker where the FormControl is being ...
8
votes
0answers
148 views

React Typescript Boilerplate

I'm trying to build a React Boilerplate Using multiple tools. They are all: React, TypeScript, ESLint, Webpack, Babel, Prettier, VSCode and with Airbnb's code style guide. Actually, this is my first ...
5
votes
0answers
432 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
305 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
4k 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, ...
5
votes
0answers
46 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
96 views

This recursive function encrypts a string

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-...
4
votes
0answers
127 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
1answer
149 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 ...
4
votes
0answers
38 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
870 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 ...
4
votes
1answer
752 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 ...
3
votes
0answers
49 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 ...
3
votes
1answer
75 views

Typescript design pattern for rendering different objects with similarities

It's a web project. The code is working. The question is a design pattern question to write code that's more elegant, you know. I've created a Codepen of this question. I created a ...
3
votes
0answers
36 views

React hook: useAsyncValue

I wrote this little hook so I could fetch some remote resources: ...
3
votes
0answers
28 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 ...
3
votes
0answers
42 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 ...
3
votes
0answers
393 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 ...
3
votes
1answer
553 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
98 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
122 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
144 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
105 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
153 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
62 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
6k views

Mapping Entities to DTOs in TypeScript

In a recent project my backend architecture consists of Repositories (talking to database) Services (handling business logic) <...
3
votes
0answers
111 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
120 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
88 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
243 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
1k 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 <...
3
votes
0answers
38 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
125 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
149 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 ...
3
votes
0answers
221 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
452 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
57 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
278 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
134 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
144 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
416 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
66 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 ...
2
votes
0answers
30 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. ...
2
votes
0answers
31 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> ...
2
votes
0answers
46 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. ...
2
votes
0answers
29 views

How to best persist context to local storage

I want to be able to persist context to local storage. My router looks like: ...
2
votes
0answers
37 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 ...
2
votes
0answers
88 views
2
votes
0answers
52 views

Hashtable Visualizer in TypeScript

Implementation is based on the MVC design pattern, with callbacks to allow model and view to communicate with controller. Concerns: It's not ideal to have async code inside the model, i.e the model ...

1
2 3 4 5