Category "typescript"

Creating service in React Typescript using axios

There are two different ways to create a service and call from the required funtional component. 1. export const userProfileService = { ResetPassword: asyn

Differentiating custom Typescript Interfaces that have the same fields

I have a custom interface like this: interface Pointer<T> { id: string } id is a pointer to other data structures, but the id field doesn't contain inf

TypeScript Mapped Type - Convert type properties to instances of type

I am trying to convert an object full of class constructors to a mapped object with properties that are functions that return an instance. For example: // From

What does this mean in angular, what kind of type is this?

I would like to know what this type means: type newtype = (state: EntityState<IEntities>) => IEntities[];

Define an "extends string" type that doesn't allow union of strings

I have this function function something<T extends string>(): void { // ... } I would like to restrict T to be a SINGLE string, and not a union of strin

cls-hooked: AssertionError [ERR_ASSERTION]: context not currently entered; can't exit

I'm currently deploying an express app to Heroku. I'm using cls-hooked to set request ids for each request. This works perfectly on my local machine and inside

What's the ideal way to add set data to a database in Nest.JS when starting the app for the first time?

I have a database with quite a few tables, and some of those tables need to have default information in them - stuff like categories, permissions, roles, tags,

Is there a way to keep type inference in union types from type guards inside a function?

Let's say I have three types (and a union one) type A = { type: 'a' title: string description: string } type B = { type: 'b' title: string

Nested object from an array using lodash in typescript

My Data structure reads this {property: ["a","b"] , value : "somevalue" , comparision : "somecomparison"} I want to create a object out of it like { "propertie

Do these two snippets return the same value?

I'm not sure how to title this question, but it's concerning a pattern where the || operator is used to resolve a sequence of undefined values to the first defi

ESLint rules for no-unused-enums

There's a no-unused-vars eslint rule that can warn/error if a variable is unused: https://eslint.org/docs/rules/no-unused-vars If I want to ensure that there ar

Typescript: deep keyof of a nested object

So I would like to find a way to have all the keys of a nested object. I have a generic type that take a type in parameter. My goal is to get all the keys of

How to add typescript paths to storybook

I have a react application with a custom Webpack configuration. After adding Webpack aliases that matches tsconfig.json file compilerOptions->paths field the

TypeScript: How to replace a particular number in a string (a combination of numerical and non-numerical values), and then update its value?

I asked a similar question here TypeScript: How to replace a particular number in a string, and then update its value? Really appreciate the answers there. It a

Taking and returning structures of `this` type inside class methods

What is the correct writing way of this class? class X { f(): this { return this; } g(): { a: this } { return { a: this }; }

How to rewrite type defination of third party library in vue project created by create-vue

I have a vue project using cesium library, following the update of cesium, some errors occur. My code: camera.setView({ destination, orientation: { heading,

React-Typescript: I don't find the problem why my getCurrentTime Function won't work

I am trying to write a function to display the difference time between current time and e.g. the creation time of a message. Herefore I wrote a function to get

VSCode `typeAcquisition` for browser imports

I want to have .d.ts typings for Lit which will be served from the esm.sh CDN. I want to use VSCode's built-in type acquisition system to get Intellisense for t

Generic Events Emitted from Component in Angular ~13

I'm trying to determine if I'm going down an undesirable path with how I'm approaching generic event management in an Angular application. The question I have i

Error pulling my own TypeScript package from NPM after using direct reference to GitHub branch for debugging

I have two packages that are both held on NPM, we can refer to them as A and B A uses B, so when I PR and merge with B it automatically updates NPM with those d