Category "typescript"

Using rotate for images leads to blank pdf with pdfkit

I have asked the question on the repository directly, but in my experience SO is more reactive. Hey there, I am trying to create a pdf from photos using pdfk

Define rules for the access control using CASL

I read the article from link and understand there are 3 ways to define abilities. But I have no clue to combine them together. For example, In the three struct

SPFx: Add a new item to existing List Folder (using pnp)

Does anyone know how to add a new item to a List Folder in Sharepoint Framework? In this way I can add the item to the list MyList: let list = pnp.sp.web.lis

Making Prettier understend TS "as" operator when it is working with eslint

I'am tring to use Prettier with ESLint for TS. But it's fails with an error SyntaxError: Unexpected identifier, expected the token `)` (17:55) On line with

How to ignore typescript errors when compile by webpack production mode

environment webpack 4.41.2 typescript 3.7.2 problem When I compile files by webpack development mode, there is no problem. But when I compile by production

NestJS enable cors in production

I've enabled CORS in my NestJS app following the official tutorial, so my main.ts looks like the following: import { FastifyAdapter, NestFactory } from '@nestj

event.preventDefault() or event.stopPropagation() not working with keyUp event

Directive file: I am trying to do that if my counter goes above two it should stop event or keyUp to reflect but is it not working. Can someone help me on this?

Build a complex type from Union type

I'm trying to build a type with two layers from a flat union type Here's my code: type TextVariants = | { size: 'tiny' // available variants for t

Restricting object key type with const

I am able to define an object key type from a union like: type Action = 'foo' | 'bar' | 'baz'; type UserStates = 'active' | 'deleted' | 'dishonoured'; type Pe

Object is of type 'unknown' typescript generics

I have a simple function that takes a function as it's argument and returns a new function. I get Object is of type 'unknown' when calling the returned function

Cant download on iOS with expo-file-system

Im trying to download using Expo-File-System on an expo project with react native. The download option works on Expo-Go during testing but wont work when i push

How to redirect to external url onClick? in React

I'm using react-router which means i'm storing routes in app.tsx file. I have cards components that need to redirect to an external url onClick. So my question

Correctly declare interface or type for functions params

How to correctly declare type for param cardsByStatus inside function addCardsToStatus? It works for cardsByStatus: any, but it doesn't make sense for me. Error

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: {},

How to inject service to validator constraint interface in nestjs using class-validator?

I'm trying to inject my users service into my validator constraint interface but it doesn't seem to work: import { ValidatorConstraintInterface, ValidatorConst

Koa + TypeScript: Property 'body' does not exist on type Request

I wanted to use koa & koa-bodyparser with TypeScript but whenever I access ctx.request.body I get an error that body doesn't exist on type Request import Ko

Why is typescript trying to load the wrong type definitions?

When I try to run typescript on my project I get the following: # ./node_modules/typescript/bin/tsc --project tsconfig.json node_modules/@types/webpack/index.d

emotion use css prop with custom components

In my application I have a component that I want to style with the css prop from outside. function Component({css}:{css?: React.CSSProperties}) { // some stuf

How to test form controls avoiding bracket notation to preserve type checking and maintainability

The Problem My unit tests on a form break when I refactor an object's member because I can only access the formcontrols on a fromgroup by using bracket notation

How do I not allow special characters and space in react hook using yup

Here's the code: { label: "Name", name: "name", placeholder: 'Name', type: "text", rule: yup.string() .required('Name is a r