Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Testing whether parenthesis are correct in a string in functional JS

This is a homework exercise and therefore has no further purpose. The writing to me feels clunky, and the typescript types on addParenthesisFactory are unreadable, ...
0 votes
0 answers
20 views

Construction Permit Web App

I have a Next.js + Node.js + TypeScript + Tailwind + tRPC project whose objective is to allow a construction manager to figure out what permits are required for his renovation based on if it's an ...
-2 votes
0 answers
32 views

Learning some functional programming - would like your input on code readability [closed]

These are three different exercises I was working on. I'm new to JS and FP as well, and I'm not sure what guidelines to follow to make my code readable. My tabs got a bit borked. All code has: ...
-3 votes
0 answers
28 views

How do i change this code to better, using ReactJS with useMemo hook? [closed]

This is a good code practice? ...
2 votes
1 answer
98 views

Abstract navigationOptions react navigation

I have many stacks with the same navigation options. How do I abstract the navigationOptions part to have it repeat in all my stacks? ...
1 vote
0 answers
73 views

To-do app with TypeScript backend (violations of TS best practices or unidiomatic code)

The working code in full is here. It's a To-Do App with a TypeScript backend, written as practice for an upcoming 4-hour interview for a TypeScript backend role. My colleague and I would like to know, ...
0 votes
0 answers
22 views

Seeking Feedback on React Authentication System Implementation

I've developed a React authentication system for my application and would like to receive feedback on its correctness and potential improvements. Below is an overview of the key components and ...
2 votes
1 answer
87 views

Generic function accepting object and validators for this object's fields

I recently started TS. I was looking for feedback on my below function (for example maybe it can be written in shorter way). Let's assume we still use the reduce ...
0 votes
0 answers
33 views

Scaffolding through my own language (Rapid Application Development)

I'm developing a webapp where some parts that repeat, so I made source code to generate source code. I had a lot of fun using Spring-Roo and Grails in the past but was sad that the difference between ...
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 ...
0 votes
0 answers
19 views

Reusable HorizontalItemList component in React and Typescript

I'm new to React and need to display a horizontal list of items at several places in my app in differing sizes and styles. This is a utility component I came up with: ...
0 votes
1 answer
201 views

Filter based on object field in TypeScript

I have four arrays of the same object which I use for a form. They work as pairs such as list_1 contains all possible values and ...
2 votes
1 answer
254 views

Efficient browser `StorageEvent` handling

I have this class EfficientStorageEventProvider, which is responsible for efficient handling of StorageEvent ...
5 votes
1 answer
1k 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 ...
1 vote
1 answer
435 views

Awaited store for Svelte

In my Svelte app, I need to reactively fetch data from the server and then render the result. The ideal data struture for this is a store whose values are promises – eg. like this: ...
0 votes
0 answers
24 views

React equivalent to Blazor singelton pattern

I'm refactoring a code-base in React, and our design team have decided to move a button out of its usual flow and instead to a component that's very much not a descendant of the logic. I'm relatively ...
1 vote
2 answers
175 views

Virtual scroller Vue component

Problem The scrolling looks smooth on Windows, but very laggy on Linux (Webkit webview and Webkit browsers). Any thoughts on what could be optimized or what's obviously broken? Demo playground: https:/...
0 votes
0 answers
14 views

Handling request failure in Next.js server-side component

I have a server-side component getting an id from the url query string to fetch data before displaying it. Everything works, but the request failure handling looks off. I'm just not sure what to put ...
0 votes
0 answers
32 views

Calendar Grid with layering of multiple events

My attempt at coding an adjusting calendar grid. It seems to work in most cases I've tried (although I haven't tested it exhaustively yet) but my DOM is a bit rusty and I wonder if there's better ways ...
1 vote
0 answers
30 views

Fully updating DB table with Prisma (TypeScript)

I'm often updating the Pokemon model with more detail. This detail is then sent to the UI to be displayed in the new sections I add over time. Since there are ...
1 vote
1 answer
57 views

How to encapsulated javascript code using imutable method?

I have this code, but I need to return pure functions instead the mutating functions. Is it possible? Perhaps using OOP? I don't know how to improve it. I tried to return the values in each function, ...
2 votes
1 answer
99 views

Move timestamp to the next Monday 10:01 AM [closed]

I've been battling ChatGPT for hours now and can't get satisfied with this simple algorithm in TypeScript. These two (hopefully correct) TypeScript+ReactNative solutions should move the timestamp ...
3 votes
1 answer
81 views

Random generation of points for the graphs of 3 stock share parameters

I currently studying OOP and related design patterns, and tried to implement random data generation for some stock charts using OOP as an exercise. This code randomly generates data points for 3 ...
0 votes
1 answer
68 views

Parsing fetched data in TypeScript

I use this code to populate a DB with a batch of pokemon entries from the POKEAPI. Since I'm using TypeScript, I added some custom parsing to use the data's type in the code. I've used a mix of ...
3 votes
0 answers
63 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. ...
1 vote
0 answers
47 views

Simple Todo app using latest React and TypeScript

I would like to ask your advice on the frontend code of todo app. Main functionalities: The app has authorization and authentication using backend. The CRUD functionality for managing tasks What may ...
0 votes
0 answers
22 views

matching generic items

Hello fellow developers I was wondering if anyone, with more understanding of javascript, is able to detect some potential flaws or performance issues with this recursive function. It works as ...
1 vote
1 answer
47 views

Typescript React-Native Component Dimension Hook

I did a lot of research trying to find a React Native component which could reference its own dimensions in order to scale different elements in its style, but could not find any solid examples. I ...
3 votes
1 answer
250 views

Find the closest named color

I have a .json file with name (string) and RGB (r, g, b: numbers) with 30.000 key-value pairs. I am looping the json multiple times per second to find the closest name to a given RGB color. Any idea ...
1 vote
1 answer
107 views

Simple Curry function

This is a interview practice question from BFE.dev. Currying is a useful technique used in JavaScript applications. Please implement a curry() function, which ...
1 vote
0 answers
111 views

Simple Table With Collaborative Editing

The following is my React code to create a simple app containing a table which can be edited by multiple people at the same time. Each client connects to a WebSocket via a custom hook. The WebSocket ...
1 vote
0 answers
46 views

Functional style dependency injection to make business logic unit-testable

My project is a blogging app, which is a recruitment assignment. It is now finished and working. Following function handles updating a comment votes, very similar as on StackExchange sites, preventing ...
0 votes
0 answers
71 views

Typewriter component that updates span one char at a time in Next.js + TailwindCSS

I have created a Typewriter component that animates a span to display text for my portfolio website. The goal was to have an array of strings that are cycled through and an animation that types them ...
3 votes
1 answer
11k views

TypeScript Generics: Create a generic map

Exercise from a TypeScript course: Create a map using TypeScript Generics. The key is always a string. The value can be a string or a number. It has to work with both types. It's got to have the ...
3 votes
1 answer
355 views

I need help optimizing a function that returns all divisors

This is my code: export function all_divisors(num: number): number[] { return range(1, num+1).filter(i => num % i === 0).toArray(); } the ...
1 vote
3 answers
272 views

List consecutive days

I created this method for consecutive days to be listed with a dash, non-consecutive are separated by “and”. In my UI control I am only getting back a ...
1 vote
0 answers
66 views

Calculate total running time for movie series

Which of these 2 functions is better and more readable and why? (Both functions do the same thing). My goal is to get the total time of a series, using the TMDB API (which has a limit of 20 different ...
0 votes
1 answer
195 views

Spring Boot Account API with React Frontend and Identicon Integration

I have recently been exploring React and Spring Boot, and I would greatly appreciate your feedback on a practice application that I have developed. The application consists of a Spring Boot backend ...
0 votes
3 answers
73 views

Find an object based on substring value

...
0 votes
0 answers
71 views

Removing Brackets and Bracketed Content from a String

I have a site that I made to parse parts of Wikipedia articles for me. Part of this is removing parentheticals and citations. I came up with the following implementation: ...
0 votes
1 answer
37 views

Creating functions in a hierarchy where they get the same arguments

When I write code, I tend to follow functional paradigms often. The main thing I try to do is use values returned from functions. What I notice though, is I end up having a sort of function argument ...
1 vote
1 answer
321 views

Movies App with Vue 3 and TypeScript

I have made a Movies App with Vue 3, TypeScript and The Movie Database (TMDB) API. For aesthetics, I rely on Bootstrap 5. In src\App.vue I have: ...
1 vote
0 answers
32 views

Asynchronous Generic Resource Pooler

A personal project I'm working on needs Worker (thread) pool. The libraries I looked at were too high-level for my needs, as I simply needed access to the Worker itself while the libraries offered ...
0 votes
1 answer
32 views

Choose a marker for the map based on the alerts it has

I need help to refactor this code, I think I can avoid the first two functions that filter the array. Also in the third part where I use the result of these two filters: ...
0 votes
0 answers
71 views

Chaining react hooks using uniswap style template

I'm trying to chain react hooks together. I need to do the following Obtain the Balance of NFT's a user has Enumerate the balance of nft's and generate index arguments to call the RPC to get the ...
1 vote
0 answers
89 views

Angular Lazy Loading Component into HTML template

I want create a generic component for lazy loading other component Demo online (click on load button) https://stackblitz.com/edit/angular-v7xfwb this is the code ...
5 votes
1 answer
295 views

Most compact data format for a shopping cart

I'm trying to build a format that can represent the user's cart on my website in the most compact way. The website is related to computer parts and there are 23 product categories. Each product has an ...
6 votes
1 answer
2k views

Custom RxJS operator to prevent duplicate API calls in Angular

I have a usecase where I want to prevent unexpected duplicate Http calls. I'm wondering if I can have a custom operator which can be used in pipe for any API as shown in below ...
1 vote
1 answer
152 views

Function component wrapper for the js-year-calendar widget

I have this class component from the rc-year-calendar library. ...
2 votes
0 answers
733 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 ...

1
2 3 4 5
11