Category "typescript"

How can I get data from service in Angular interceptor?

I want to add my authentication token in the request header in my auth.interceptor.ts and I'm keeping the authentication token value in my auth.service.ts. Here

how to set up cors() in typescript express

In one of my projects, simply this worked: import cors from "cors"; server.use(cors()); but currently I am having this lovely typescript warning message in my

Typescript issue during compilation around `webpack/HashedModuleIdsPlugin`

I am getting compilation issue around HashedModuleIdsPlugin and typescript :( When compiling a TS project that allow JS, requires HashedModuleIdsPlugin and expo

Replacement of deprecated MediaQueryList.addListener() event in Angular 8

As the mozilla developers docs says MediaQueryList addListener is deprecated. I'm using it in my Angular 8. Though it's working it's linting warning in VS Code

Ionic 4 ion-input allow number only, restrict alphabet and special character

I am creating an app in ionic4, I have a functionality where user can enter the only integer number (0-9), so I want to restrict any other character i.e alphabe

Why are function parameters not treated as compulsory when implementing an interface?

I have recently noticed that I was able to implement a function from an interface and remove the parameters and that worked fine. I have some sample code below

Why I got empty object on Angular route?

Why I got empty object from ActivatedRoute params and how to fix that? routeId$ = this.route.params.pipe( tap((params) => console.log(params)), // <

How to write typescript interface for Window object ethereum that has a request method being called

I am running the following function import { ethers } from "ethers"; async function requestAccount() { await window.ethereum.request({ method: "eth_reques

InversifyJS + TypeScript + Ejected CRA: issues with importing files with interfaces

Code available here: https://github.com/rtrocca/test-inversify-cra I created a simple React application with CRA and the TypeScript template and ejected the app

Why use triple-equal (===) in TypeScript?

In JavaScript, it's commonly seen as best practice to use === instead of ==, for obvious and well-known reasons. In TypeScript, which is one to be preferred? I

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

Testcafe request with cookies

I am trying to find a method in testcafes API similar to Cypress' request. Cypress' request will attach any cookies to the request that already exist in the b

Typescript Node MODULE_NOT_FOUND

When I run yarn start (ts-node src/index.ts), I get MODULE_NOT_FOUND Error: Cannot find module 'src/isAuth'. It use to work before I added that new file isAuth.

Share types between client and server

I'm working on a project with a Node.js, Express.js & TypeScript backend (REST API) and a React, Redux & TypeScript frontend. In the backend I have crea

In typescript, why do the | and & operators flip their meaning when used on function types?

In this code, example1 and example2 are confusing me: type F1 = (a: string, b:string) => void; type F2 = (a: number, b:number) => void; // re: example

Cannot invoke an object which is possibly 'undefined'.ts(2722)

I have a button component. I simply pass it just one onClick prop out of many optional props I've defined: const Button = (props: ButtonProps) => { const

Typescript configure mapping for compiled import path

I have an aws amplify project which is using yarn workspaces. My project has a lambda function and a layer. When the lambda function runs in aws it needs to imp

how can i give type in getServerSideProps of Nextjs with typescript?

I'm using NextJs + TypeScript to make a little clone project, but I got a problem with type in getServerSideProps. As you can see, in getServerSideProps, I am f

How to check 2 conditions in angular ngif

I am little stuck trying to get this *ngIf to work correctly. What I am trying to do is show the div if it is empty only if the user viewing is owner. If the us

Props typing in Vue.js 3 with TypeScript

I'm trying to type hint my props in a Vue 3 component, with composition API. So, I'm doing this: <script lang="ts"> import FlashInterface from '@/interfac