Category "typescript-typings"

work with d.ts with a different folder for js (pdfjs-dist)

Currently pdfjs-dist https://github.com/mozilla/pdfjs-dist/tree/bd2a6cd87f9e0c3a9b3197d5d27acfb99886629b contains the d.ts and js files in separate folders: htt

Type 'Dispatch<SetStateAction<any[]>>' is not assignable to type '(values?: string) => void'

I'm very new to typescipt and trying to make a basic pin-input page. Sandbox link for my code . Although it is working, I'm getting this error for onChange func

Where a function is required, typescript allows me to pass an object with an incompatible `apply` property

Currently using typescript 3.4.5 with strict mode enabled... Backstory I just ran into a situation where typescript failed to protect me from my own mistakes

How to strongly type jest mocks

I would like to strongly type my jest mocks. To a certain extent, I can make it work but when a class has private properties I'm stuck. An additional question,

TypeScript: Interface cannot simultaneously extends two types

I'm writing a React app using TypeScript. I use material-ui for my components. I'm writing a custom wrapper for material-ui's Button component. It looks like th

Typescript: Evaluate type of generic function

Is there any trick to "evaluate" the type of a generic fuction? Consider the following: type Arr = <A>() => A[] type Ev<G, A> = ??? Question: I

Define an empty object type in TypeScript

I'm looking for ways to define an empty object type that can't hold any values. type EmptyObject = {} const MyObject: EmptyObject = { thisShouldNotWork: {},

`as const` alternative to narrow an array literal tuple, to avoid `readonly` modifiers

We use as const to narrow the types: [ {foo: 'foo' }, { bar: 'bar' } ] as const but this also adds readonly modifiers for all props and values. As of const thi

How to make some fields in object required

I need an interface for making some fields of other interface as required. For example: I have IUserInterface: interface IUser { name: string; role?: str

function declaration for a generic function return wrapper

How to declare the function wraps that takes any function and returns a version of it that differs only in returning an object that wraps the original return ty

Typescript input onchange event.target.value

In my react and typescript app, I use: onChange={(e) => data.motto = (e.target as any).value} How do I correctly define the typings for the class, so I woul

TypeScript typings give me "index.d.ts is not a module"

I am getting File node_modules/@types/webrtc/index.d.ts is not a module with this code: import * as webrtc from "webrtc"; const peerConnection1 = new RTCPeerCo

How to override a property to be non-nullable in Typescript

The DefinitelyTyped definition of the Node built-in IncomingMessage (the type of req in the (req, res, next) arguments) has defined url to be nullable. Here's t

error TS2306: '...index.d.ts' is not a module

I'm trying to write a lib in Typescript that I want to use in various other typescript or JS projects. All of the those other projects run in browsers. My Type

.filter() does not affect type of array in TypeScript?

check this snippet: interface Foo { id: string; } const fooFunc = (arr: Foo[]): Foo[] => arr .map((item: Foo): Foo | null => { const so

NPM package cannot be used as a JSX Component - Type errors

Ive been getting these strange type errors on my typescript project for certain packages. Ex: 'TimeAgo' cannot be used as a JSX component. Its instance type '

How to update an older version of a type

I have a project that runs AngularJS 1.5.x, and it uses type declarations from DefinitelyTyped: @types/[email protected]. This is the last 1.5.x version, and it wa