Category "typescript"

How to iterate over keys of a generic object in TypeScript?

I need to iterate over a large object which is just typed as "object". It contains an unknown number of objects of the same type. In older posts I had found so

Angular 13 Prerender error could not find main bundle

I'm trying to pre-render my Angular 13 application. The command which I'm running is: ng run ipe:prerender --routes-file ./data/routes.txt The error that occur

How to handle "else if" in fp-ts

A lot of times I notice I am struggling how to implement a pretty simple flow chart with multiple if-else conditions. This example looks too verbose and is not

Check recursively if any children are active

I've a recursive list of items in Angular/TypeScript and I'm trying to only display items when they are active=true; themselves or if any children or children&a

Pagination in React/Typescript

So I am trying to achieve pagination functionality. Here I have crypto API and a table where data lies, the thing I want to achieve is displaying 10 items per

Forcing excess-property checking on variable passed to TypeScript function

Is there a way to force excess-property checking to happen, not just for an inlined object literal but one that derives from a variable? For example, suppose I

Optional-chaining in Angular

I'm using optional chaining on an object which in turn gives this error after compiling the code For example const someObj = {pet_animals: {'dog', 'cat'}}; cons

TypeError: Class extends value undefined is not a function or null

I am getting the following error when trying to create these entities. TypeError: Class extends value undefined is not a function or null I am assuming this h

TypeScript enum to object array

I have an enum defined this way: export enum GoalProgressMeasurements { Percentage = 1, Numeric_Target = 2, Completed_Tasks = 3, Average_Milest

How to override type properties in TypeScript

For example, I have type Line = { start: Point; end: Point; color: string; //'cyan'/'aquablue'/... } But now I want to create new line type on the base

How to get type inference using a utility type, or type parameter, when I extend the built-in array class?

Defining types for Class-member's in an Extended Array Class So below, you can see that I extend the array class via the WillyWonka class. The problem is, when

TypeScript seems to be seeing a variable as 'any' even though it's defined

I have the following component: import React from 'react'; import classNames from 'classnames'; import styles from './styles.module.scss'; const cx = classNam

Error: Cannot find module 'C:\XXX\XXX/config-overrides'

I have created a sample react/redux/.net core app by using this Tutorial. But when I try to start the application with npm start I get the 'cannot find module e

TypeScript - Removing readonly modifier

In TypeScript, is it possible to remove the readonly modifier from a type? For example: type Writeable<T> = { [P in keyof T]: T[P] }; Usage: interface Fo

How to export a TypeScript project from StackBlitz

Is there a way to export a TypeScrpit project created on StackBlitz using the "TypeScript Blank Project" template and run it anywhere else? If you just downlo

Typescript - "Authorization" does not exist on type HeadersInit

I'm using the node-fetch npm module and have a helper function for making authorized requests to a third party service (basically just middleware for adding in

How to convert React.FC syntax to const x = () => {}?

I have this code below that I tried to convert its syntax (I am using TypeScript, React) from the syntax below to const x = () => {} form. const EntryDetails

Property 'Draw' does not exist on type 'typeof Control'

I'm attempting to implement a map component with leaflet and other leaflet plugins. The issue is other plugins don't work from TypeScript for some reason. For

How can I define a type for a css color in TypeScript?

I have the following example code snippet: type Color = string; interface Props { color: Color; text: string; } function Badge(props: Props) { re

How to set default query params for Route in Angular 7?

In our Angular-7-Application, we use @ngrx and @ngrx/router-store to get the query params into the state. A few components of the application are paginated lis