Category "typescript"

Styling mat-select in Angular Material

How to style mat-select's panel component. From the docs I get that I need to provide panelClass so I make it like this: <mat-form-field> <mat-sele

Why I can't access properties of base abstract class?

Why I've got an error "Abstract property 'field0' in class 'SuperAbstractClass' cannot be accessed in the constructor", although if we look into the transpiled

Infer subclass property type from base class generic in typescript

class A<T> { some: { [K in keyof T]: (x: T[K]) => T[K] } } interface IB { b: number } class B<T extends IB> extends A<T> { co

Angular 12 breaks absolute paths for templateUrl and styleUrls

I am using Angular 13, upgraded from Angular 11 but after upgrading to Angular 12, the absolute paths stopped working for templateUrl and styleUrls. When I was

How jasmine spyOn a generic method

I try to make a spy on a generic method in typescript, but cannot get Jasmine to recognise it. I have code http: HttpClient <- Not proper code, just showin

Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop with antd pro

Today when I add the Form fields reset code in antd pro: import React, { useEffect } from 'react'; import { ProFormText, ProFormTextArea, ModalForm, Pro

React and TypeScript—which types for an Axios response?

I am trying to present a simple user list from an API which returns this: [{"UserID":2,"FirstName":"User2"},{"UserID":1,"FirstName":"User1"}] I do not understa

How to get enum key by value in Typescript?

I have an enum like this: export enum Colors { RED = "RED COLOR", BLUE = "BLUE COLOR", GREEN = "GREEN COLOR" } Could you let me know how to get e

TypeScript: problems with type system

I'm just testing typescript in VisualStudio 2012 and have a problem with its type system. My html site has a canvas tag with the id "mycanvas". I'm trying to dr

Enforcing the type of the indexed members of a Typescript object?

I would like to store a mapping of string -> string in a Typescript object, and enforce that all of the keys map to strings. For example: var stuff = {}; s

Using Typescript generics for React Functional Components with eslint props validation

I want to create a functional component in React using Typescript, and I have already set it up according to this Q&A: export interface CustomProps<T ex

Type discrimination based on *any* element of an array (not *all* elements)

I would like to create a union type in TypeScript that can use an array as a discriminant, but have a specific type match if any element of the array meets some

TypeScript static classes

I wanted to move to TypeScript from traditional JS because I like the C#-like syntax. My problem is that I can't find out how to declare static classes in TypeS

Is there a less verbose way to write DynamoDB update params?

I am new to Dynamo and I created a simple todo API with Serverless Framework and TypeScript To update an Item I have to do this huge params const const params =

Detect and warn users about caps lock is on

How to implement to detecting and warning users when caps lock is on with (or not) tooltip style in typescript (angular 4.2.2)?? Maybe with some keyup events, o

Angular Material Menu module: Export of name 'matMenu' not found

I have a little issue with Angular Material Menu module. I have this code in my app.module.ts: import { SharedModule } from './shared/shared.module'; @NgModu

Why my enum type wont work in Next.js project

I getting this error "Type 'string' is not assignable to type '"left" | "right"'." Project running on Next.js Here is my type definiton export interface TwoColu

Looping through Angular QueryList

So I want to get all the images in my component in an array, so I am using Angular's @ViewChildren which returns a QueryList of ElementRef: @ViewChildren('img

React-typescript: Object is of type 'unknown'. TS2571

I am using React-TypeScript for my project. For state management, I am using React-redux, for function handling I am using redux-saga. For gluing the redux stor

Passing array and got: ERROR Error: NG0900: Error trying to diff '[object Object]'. Only arrays and iterables are allowed

I'm developing the front-end of a crud application on angular, and i got this error when passing an array: ERROR Error: NG0900: Error trying to diff '[object O