Category "typescript"

TypeScript `extend` produces ESLint error when extending a template string?

I want to implement a type TrimStart like this: type TrimStart<T extends string> = T extends ` ${infer Rest}` ? TrimStart<Rest> : T; type TT = Trim

TypeError: L.Control.Draw is not a constructor

I wanted to draw a polygon in the leaflet map in my ionic2 app, for that I found leaflet-draw pluggin, but I am getting this error TypeError: L.Control.Draw is

What is reason to use is operator in TypeScript?

What is reason to use is operator in TypeScript in this case? type Species = "cat" | "dog"; interface Pet { species: Species } interface Cat extends Pet

Typescript file-naming conventions

I'm looking for the Typescript file-naming conventions, specifically for a file which stores only types and interfaces. Now, I've found a couple of Typescript

Disable PrimeNG Calendar month selection in Typescript

I am using PrimeNg Calendar in my angular 7 project, wanted to disable month navigator on some conditions at the component level. Ex: Current Month is February

animateChild() for nested Angular child animation not working

I would like to fire two animations at the same time on click. The animation triggers use the same state, one is placed on an outer parent div and the other is

How to generically map over values of object in TypeScript (where object keys are a string union)?

Suppose I have two types: type Credentials = { Username: string; Password: string; }; type XmlCredentials = { [k in keyof Credentials]: { _text: string } }

How can I make dynamic url to external site in angular5?

When I'm trying to make link like this: <a [href]="getUrl()">click me</a> getUrl() { return this.domSanitizer.bypassSecurityTrustUrl

How to omit an union type depending on field value

I have this type (come from third party library): type StackActionType = { type: 'REPLACE'; payload: { name: string; key?: string | unde

Config route in react-router-dom v6

I am using react-router-dom with typescript. I create a config file like below: export interface RouteComponent { path?: string; element?: React.ComponentTy

Ant design sort table code not working on the react typescript

I used following ant design sort table code in react type script, its not working correctly anyone know how to do that correctly My code here import

How do I configure prettier to format tsx file which use styled component?

Here is what is expected after formatting my file : export const StyledDiv = styled.div<StyledDivProps>` width: 56px; height: 30px; `; And this i

class-validator validate union type

I have a mongoose discriminator schema, which mean the data will be different according to one of the attributes. class Feature { name: string option: Colo

How to watch and reload ts-node when TypeScript files change

I'm trying to run a dev server with TypeScript and an Angular application without transpiling ts files every time. What I found is that I can run .ts files with

How can we achieve browser zoom in and zoom out in playwright?

Need to find a way to zoom browser in and out during an e2e test run. Below code does not work. await page.keyboard.down('Control'); for (let i = 0; i < 7;

How to use TypeScript with Sequelize

I already have my server application written in Node, PostgreSQL, Sequelize using Fastify. Now I would like to use TypeScript. Can anyone tell me how to begin

Handle null with localecompare typescript

I have the following sort: let sortedCon = this.con.sort((a, b) => a.lastname.localeCompare(b.lastname)); I am trying to get it to handle nulls and mainta

How to create new event for unit testing in Angular 2?

Hi I am writing unit test case for my angular code. I am trying to update textbox in gridview. Below is my gridview code. <input *ngIf="editing[rowIndex + '

Module not found: Error: Can't resolve 'path'

I have an Angular CLI project which I just upgraded to Angular 6. Now when I try to build my app, I get the following errors: ERROR in ./node_modules/postcss/

Module parse failed? I need help setting up Babel

I'm writing my first JavaScript library and I'm testing it locally with a React project. I'm not seeing any Typescript errors when I'm writing my code but when