Category "typescript"

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

Sequelize filter the included tables by where

I am trying to findAll records included nested tables, but did not understand how could I filter included tables by where clause. Here are the words: const play

Type for useRef when used with setInterval/clearInterval [react-typescript]

I am setting up a useRef object to hold a NodeJS.Timeout component, the return type of setInterval(). When I use that later in clearInterval, I get an error (sh

How to mock only one typescript class from a module, but leave other classes/functions as is, using the jest framework

I have a typescript module with a function that I'm trying to test with jest. The function I'm trying to test uses a typescript class that's defined in the same

How to write typescript with constructor function/new keyword?

This is an example from MDN docs for the usage of new keyword function Car(make, model, year) { this.make = make; this.model = model; this.year = year; }

Import a JavaScript module or library into TypeScript

Over many years I've struggled with this same issue. I cannot seem to work out how to use a JavaScript library from TypeScript, reliably. I seem to get it worki

TypeScript errors for ReactNode after migration to Create React App v5

After migrating to Create React App version 5, I have errors like the one below: TS2786: 'OutsideClickHandler' cannot be used as a JSX component. Its instance

Typescript: Type 'Promise<void>' is not assignable to type 'void | Destructor'

The editor is showing Type 'Promise' is not assignable to type 'void | Destructor'. for the checkUserLoggedIn() call in useEffect. I can get rid of it by doin

How to make scripts just run one time when app start?

I try to use facebook API for chat plugin.but it just work when i put the script in component like this FacebookPlugin.tsx import Script from "next/script"; imp

TypeScript Disallow Unecessary optional chain expression

Is there an es lint rule or typescript config to disallow the following ? let s: string; s = 'a'; s?.toLocaleLowerCase(); In my opinion, s is not nullable so n

Type is not assignable to type 'IntrinsicAttributes & MoralisProviderProps'

I am new to typescript and I really want my initialize on mount to be set to true, Does anyone know why it will only let me set it to false? Here is the error:

Angular federated module can not be loaded when route would be activated

I am trying to achieve a very simple module federation with shell (host) and travel (remote). Whenever I try do dynamically load the AbcModule from travel I get

In angular Typescript, when logging a structure it looks correct, but when logging a member in it, it gets undefined

I have the following "prod" structure (from log): cat_id: "1" category: "2" description: "The Nike Zoom Pegasus Turbo 2 is updated with a feather-light upper, w

How to use TypeScript and forwardRef in ReactJS?

I'm having a problem when using forwardRef with TypeScript. What I want? pass a typed ref to the child component. What am I getting value of console.log - child

Save Proto Timestamp as a string instead of object in Typescript

I currently have a birthday field in my proto definition defined as google.protobuf.Timestamp birthday = 1; When data is saved in the database its saved as an

Invalid document reference. Document references must have an even number of segments, but cities/SF/landmarks has 3

Hello I am following the firestore tutorial here https://firebase.google.com/docs/firestore/query-data/queries#web-version-9_14 First they instruct me to seed t

Using boolean variable in Serverless (TypeScript) config

I’m trying to use a boolean variable in a Typescript serverless config, but I can’t seem to get the syntax right. From the docs, I think I’m s

how to mock slack web api for jest

i have an app that's using the @slack/web-api package through the named import WebClient. i want to test one of the controllers that uses a model that in turns

Problem with styled-components running React 18 and Next.js. Module not found: Can't resolve 'process'

I have to use React 18 for Suspense in a three.js/next/ts project (I have tried using next/dynamic and it does not work). So I installed it and updated everythi

Jest: to check if a function is called by a specific instance of class in JavaScript/Typescript

I am testing some express middlewares with jest. it("should throw 400 error if request.body.id is null", () => { const req = { body: { id: null } } as an