Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

Filter by
Sorted by
Tagged with
1
vote
0answers
14 views

Matrix Multiplication in Typescript

I would like some help on making my solution more functional. At present, I rely heavily on using indexes in my map functions. I am also seeking general feedback and advice, thanks. ...
3
votes
1answer
70 views

Finding Common Items in arrays

My goal is to get a list of related statementIds in order of most repeated. In my database I have stems(Words): ...
2
votes
0answers
53 views
+50

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: ...
1
vote
0answers
11 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
1answer
19 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
13 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: ...
0
votes
1answer
39 views

JS, TS, handle 3 consecutive ifs / ternaries [closed]

I need to compare a title for 3 strings here what I'm doing ...
0
votes
1answer
27 views

Is there a better way to assign constructor parameter in Typescript?

I have a class with a various set of optional parameters when instantiated. I would like to be sure that the user input ONLY the available parameters option, and also add a default value if nothing is ...
2
votes
0answers
26 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 ...
0
votes
1answer
37 views

Sock merchant from hackerrank - idiomatic typescript?

Sock Merchant John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many ...
3
votes
0answers
44 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 ...
2
votes
0answers
25 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 ...
5
votes
2answers
163 views

Prettier Pug Plugin

I'm the creator of the plugin Prettier Pug Plugin. Everything works fine and I have a lot of tests because I used TDD I currently have a large index.ts (permalink). In this file mainly an array of ...
0
votes
0answers
19 views

Small global state handler in React using hooks

I've been working in React for a while now and I decided to try out my knowledge in hooks by creating a small global state manager using said hooks. This is what I came up with: index.js ...
3
votes
3answers
125 views

Maintain the ordering of the original array, but group either negative or positive numbers into sub arrays

For a code challenge I thought it'd be useful to have a helper function to group positives and negatives into their own sub arrays while maintaining the ordering of the original array. I'm sure there'...
1
vote
0answers
18 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 ...
2
votes
1answer
50 views

Object array with identifier: use index to quickly access elements by id?

I must access the elements of an object array very often by an identifier id, i.e. ...
1
vote
0answers
21 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 ...
2
votes
0answers
18 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 ...
3
votes
0answers
71 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 ...
1
vote
3answers
56 views

Simplified method with multiple if-else

I need to refactor some pice od method for drag-and-drop angular material. Here is a working method in production, I need suggestion for CLEAN way to write this method. I can't change var name and ...
0
votes
1answer
46 views

Use of Factory pattern — how to implement it

I am trying to figure out how Factory pattern works. I implemented it with TypeScript in this github repo: https://github.com/emilecollin/factory_pattern Basically this is emulating spaceships gaming ...
1
vote
0answers
22 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
34 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 ...
0
votes
0answers
29 views

Styled components in typescript

I'm new to typescript and I'm trying to migrate this styled component from JS to TS but I'm stuck with types and calling of methods inside css helper. JS File to be converted: https://gist.github.com/...
3
votes
1answer
71 views

Dynamically create array with nested objects/array

I need help to dynamically create an array with nested objects holding again an array of objects each. The structure is as follows: ...
1
vote
0answers
125 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 ...
0
votes
0answers
34 views

CRUD data in React with hooks and Typscript. Frontend only

Im looking for input on my project where the user can create, read, update and delete data. This is my first test project with both hooks and Typescript. The project is working fine but would like to ...
2
votes
0answers
37 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) ...
3
votes
0answers
69 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 ...
5
votes
1answer
87 views

Roman Number to Integer

Problem Definition Roman numerals are represented by seven different symbols: I, V, X, <...
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. ...
2
votes
0answers
28 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
47 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: ...
3
votes
0answers
56 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 ...
2
votes
0answers
52 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/...
0
votes
1answer
58 views

Choosing between 2 Fibonacci alternatives [closed]

Task: Return the fibonacci value at a given index. e.g: input: 6, return: 8. Algorithm 1: ...
3
votes
1answer
65 views

Algorithm to find the Array Balance Point

Task: Find the balance point of an array; return the index that if you break the array into left and right at that point will ...
0
votes
1answer
22 views

for of loop that stops at last object of array

I have a for of loop, for each item in the childElements HTMLCollection I want to subtract the height of the elements from the parent height. ...
1
vote
0answers
42 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
48 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 ...
0
votes
0answers
27 views

Angular pagination component

I have written an Angular component for pagination. It works like this: page count < 12 all pages are shown Example: < 1 2 *3* 4 5 6 > page count >= ...
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 ...
1
vote
1answer
16 views

Return value related to file content header

I have an attachment uploading feature in my web app. File can have type- image/png or image/jpg or ...
2
votes
0answers
81 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: ...
4
votes
1answer
121 views

Check a string for 2 values

I have a string, for example: dashboard/12398911/overzicht and I want to check that string for 2 values. For dashboard and ...
6
votes
2answers
325 views

Angular control for inputting latitude and longitude with validation

I've built a custom control to handle user input in a human-readable format, but save in a machine-format. It needs to have input validation, and to convert UI-input to a base format. I'm interested ...
2
votes
1answer
155 views

StringBuilder: To Build or Not to Build

StringBuilder class is a common class that many have become accustom to, including me. An individual posted a question regarding if there was a comparable method in typescript. Several solutions were ...
1
vote
1answer
41 views

Sudoku validation

Problem explanation I've written a function to validate sudoku. Given a two-dimensional 9×9 array of numbers: Each row should have each of the numbers 1–9 exactly once. Each column should have each ...
2
votes
1answer
79 views

Simpler state manament alternative to Redux, MobX, Context API, etc

I got frustrated with the jargon and created an alternative state management solution. Its up at https://github.com/smakazmi/react-soliit. It goes something like this ...

1 2 3 4 5 7