Category "typescript"

How do I index only the property names from another object, but leave values to be inferred?

I have the following example joi validation schema const joiUser = { firstName: joi.string().required(), // inferred type: joi.BoxStringSchema<joi.Box<

Chakra UI color mode changes on page refresh, because of system color mode

I'm running NextJS with Chakra UI and the problem is when useSystemColorMode is set to true, it ignores the user's choice on page refresh and sets it back to th

How do I check that a switch block is exhaustive in TypeScript?

I have some code: enum Color { Red, Green, Blue } function getColorName(c: Color): string { switch(c) { case Color.Red: re

Angular/Karma unit test error "1 timer(s) still in the queue"

This is hardly first encounter I've had with "1 timer(s) still in the queue", but usually I find some way to use tick() or detectChanges(), etc., to get out of

the syntax requires an imported helper named __spreadArrays

When I'm trying to use spreading in typescript like: .reduce((unique, x) => { unique.some(element => element.machineName === x.machineName) ? unique

How to avoid this kind of notation " | undefinded " in typescript?

It's not essential, but I'm asking out of curiosity. In Object type we can declare optional property by using ?: operator, but is there a similar shorthand when

Limited parallelism with async/await in Typescript/ES7

I've been experimenting a bit with Typescript, but I'm now a bit stuck on how to use async/await effectively. I'm inserting a bunch of records into a database,

Navigate relative with Angular 2 Router (Version 3)

How to navigate relative from /questions/123/step1 to /questions/123/step2 within a component using Router without string concatenation and specifying /question

(Angular) Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached

I'm trying to make a project in angular but when I try to compile it shows me these errors over and over till my IDE closes. Watchpack Error (watcher): Error: E

Typescript: Cannot use import statement outside a module

I have a .ts file in node js (latest version of node.js for 07.10.19) app with importing node-module without default export. I use this construction: import { C

Jest: function that should throw does not pass and test will fail

I want to test a function A that calls multiple other functions inside it which can throw errors. Here is an abstraction of my code: // file A.ts const A = (ar

Jest: function that should throw does not pass and test will fail

I want to test a function A that calls multiple other functions inside it which can throw errors. Here is an abstraction of my code: // file A.ts const A = (ar

How can we create a custom jquery plugin using typescript?

I need to use a jquery custom plugin in my application and how can i create a custom jquery plugin using typescript. I have googled a lot and i just got below l

Test fails with "TypeError: theme.spacing is not a function" after migration from MUI v4 to v5

Have design system created/customized with MUI v4. Decided to update to V5 using this manual. All steps are done (with codemods and manual fixes), except moving

What does the pipe(|) mean in typescript?

While browsing some typescript code of @ng-bootstrap I have found pipe(|) operator. export declare const NGB_PRECOMPILE: (typeof NgbAlert | typeof NgbTooltipW

How can I create an unlimited range for cloud functions?

I'm creating a cloud function to read a google spreadsheets and I want that use an unlimited range. It´s that possible? The idea is read the Google spread

What does the pipe(|) mean in typescript?

While browsing some typescript code of @ng-bootstrap I have found pipe(|) operator. export declare const NGB_PRECOMPILE: (typeof NgbAlert | typeof NgbTooltipW

Filter undefined from RxJS Observable

Is there a specific idiom or utility used to filter undefined from RxJS observables? This code has the behavior I want: obs.pipe(filter(x => x !== undefined)

Filter undefined from RxJS Observable

Is there a specific idiom or utility used to filter undefined from RxJS observables? This code has the behavior I want: obs.pipe(filter(x => x !== undefined)

Understanding TypeScript template literal type with `${any}${any}`

Can someone explain why this: type NotEmpty<T extends string> = T extends `${any}${any}` ? T : never; declare function something<T extends string>(