Category "typescript"

typescript: Cannot find module 'react'

I don't understand why it can't find it. $ cat tsconfig.json { "compilerOptions": { "sourceMap": true, "target": "es6", "jsx": "react", "typ

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

How to infer types from an imported file in Typescript

I have a tricky Typescript problem I can't seem to solve. I would like to infer values based on a generic. However, the catch is the inferred types needs to com

How to import a single-spa in-browser utility module into a TypeScript parcel project

I have 3 TypeScript projects below: root-config parcel, let us call it my-app in-browser utility module, let us call it api All the projects above were generate

Using JavaScript need to group elements

I am looking for efficient method to modify my object list which looks something like this: const pets = [ {type:"Dog", name:"Spot"}, {type:"Cat"

How to watch file changes with ts and js build

I have a project with fastify, apollo server fastify and nx. I want to add a script to build my code and run the js files. the problem is that if I make any cha

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 define types of the auth properties in socket.io-client

Question I am using socket.io-client with typescript. When creating a socket instance, I set a token property in the auth of the Socket options, but an type err

Error starting TypeScript language service in WebStorm 2018

I'm new to using WebStorm (v2018.2 on Windows 7) and trying to work with TypeScript. And I am getting following error, despite trying many combinations of the T

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

Typescript paths not resolving when running jest?

Attempting to convert this project over to jest using these instructions. I have everything working except for the files that use the paths configuration: "pa

Angular 2 Animation - boolean trigger?

I'm trying to trigger a transition bound to a boolean property, but this doesn't seem to fire. Here is a cut down version of my animation trigger trigger( '

Module build failed: UnhandledSchemeError: Reading from "alias:/path" is not handled by plugins (Unhandled scheme)

I am creating a new react app and trying to configure webpack compiler from scratch. The issue happens when running the build command with webpack -c config/web

Use async await with Array.map

Given the following code: var arr = [1,2,3,4,5]; var results: number[] = await arr.map(async (item): Promise<number> => { await callAsynchron

Add dynamic loading messages with APP_INITIALIZER

I have an app which do some backend calls before initializing. I have a loading screen for this, which tells the user that something is currently loading. The p

How to mock interface with Jest without creating an instance

I know we can do it in Kotlin but I did not find it with Jest. I have complex interfaces and array of those interfaces and I do not want to specify all values o

What is "not assignable to parameter of type never" error in TypeScript?

Code is: const foo = (foo: string) => { const result = [] result.push(foo) } I get the following TS error: [ts] Argument of type 'string' is not a

contextBridge.exposeInMainWorld and IPC with Typescript in Electron app: Cannot read property 'send' of undefined

I defined contextBridge ( https://www.electronjs.org/docs/all#contextbridge ) in preload.js as follows: const { contextBridge, ipcRenderer } = require("elec

How to make the date input mask in angular?

I am trying to make the input date of birth mask in angular and format of date is dd/mm/yyyy ,but it not set and return the input according to our requirement

Angular FormArray display validation errors

I have Angular form that is built with help of FormBuilder. Form contains a FormArray which has as many fields as user wants. I've set validator for fields this