Category "typescript"

enforce property order in a typescript interface

I am building a typescript interface to an API that I do not control. The API is xml based and expects properties in a particular order. These properties are no

Compile tailwindcss + typescript

I have a very simple app with some html, css, and ts files. I use swc to compile the typescript and copy over the html/css/assets. Now, I'm looking to add tailw

How to make one object type which will contain properties of all objects of union type, but values will are intersections

How can I make a type which will make a one object type from unions of objects, which will contain properties of all objects of union type, but values will inte

TypeScript error in directory/node_modules/@antv/g6-core/lib/types/index.d.ts(24,37): Type expected. TS1110

After cloning the repo from GitHub and installing packages by running yarn install, when I'm run the project getting this error. I tried to update react script

How to Compress JSON data in angular 4 app using gzip compression & send it to server using Http post?

I am using pako library for compression: var binaryString = pako.gzip(data); At server side (.net core) i am using middleware to decomopress the zipped stri

Check if a component is an instance of React.ReactElement<any> in a child map

I have a component that loops through children and wraps them in a div. I am trying to add an exclusion to that, but running into an issue where I can't check i

Why ngOnChanges() does not trigger when @Input() update the data Angular 8?

parent.component.html <parent-comp [data]="mydata"> </parent-comp> parent.component.ts this.service.abc$ .takeUntil(this.ngUnsubscribe.asOb

Using a function on stylesheet typescript react native

I try to use some variables inside my StyleSheet file. The UI is working fine. But the type is error. Any idea how to solve this? type buttonStyle = (height: nu

Vue 3 refs is undefined in render function

I have a simple Vue component with root element as ref="divRef". However, in onMounted function, divRef.value returns undefined. Any help will be appreciated. i

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