Questions tagged [typescript]

TypeScript is a typed superset of JavaScript created by Microsoft that adds optional types, classes, interfaces, async/await, and many other features, and compiles to plain JavaScript. This tag is for questions specific to TypeScript. It is not used for general JavaScript questions.

1
vote
1answer
8 views

TypeScript: generic interface as union of other interfaces

I would like to create a generic interface with properties that represent a union of properties from other interfaces. Let's say I have two interfaces interface A { something: string; ...
0
votes
0answers
4 views

Hashicorp vault: unable to write secret with node-vault

I am writing an application which uses Hashicorp vault to store passwords and certificates. Right now I am using the default username/pass method to authenticate my client app. When I try to add a ...
-2
votes
1answer
26 views

In Angular , what is the purpose of subscribing and subscribe and do where should we use in(constructor or ngOnInit)?

I met with a lot of code with subscribe method in Angular, what will we lose if we do not use them? and why all codes that uses subscribe, is being written in constructor instead of ngOnInit? ...
0
votes
1answer
11 views

How to export a React Component without ownProps when using redux with TypeScript?

I am using typescript with react-redux . I have the following component which doesn't take any "OwnProp" from parent but takes a prop from redux state. Redux is giving me error from Parent Component ...
0
votes
0answers
14 views

Unexpected token export in typescript package

I am including a module (from a private git repo) Package.json: "my-module": "git+https://username:[email protected]/username/repo.git" The repo has a typescript file: export class MyClass {} This ...
-1
votes
0answers
11 views

how the fix the CORS error that results in accessing external API from angular 7 app running behind corporate proxy

I am developing an angular 7 app for displaying application statistics. I was trying to access an external api to download some gifs but i am getting error response. The machine that i am using is ...
0
votes
0answers
5 views

How to import TokenExpiredError thrown by jsonwebtoken's verify?

I'd like to check whether the type of an Error is TokenExpiredError throws by the jwt.verify function of the jsonwebtoken library using Typescript's instanceof, e.g. import jwt from "jsonwebtoken"; ...
-1
votes
0answers
18 views

maximum call size exceed - Observable data services in angular 6

I am using angular 6 Observable data services, while i am setting new response in existing get subscribe method i am facing issue of infinite loop GetSummaryDetail() { this.dataService....
0
votes
0answers
14 views

Add white space under rows for dropdown - Ag-Grid

I have a table which allows the user to add rows. On each row, there is a cell which on clicked, contains a dropdown which is 120px below the row. I found an issue where if the user adds too many ...
0
votes
0answers
29 views

How can I import the 'M' variable in angular testing?

I defined a variable 'M' in typings.d.ts, in order to be able to use materialize css. But at testing I get a 'M' is not defined error. I have imported 'typings.d.ts' in tsconfig.json under "typeRoots"...
0
votes
0answers
18 views

Vue cli use es lint with airbnb and prettier for typescript

I noticed that when I create a Vue project with the Vue UI and pick that I want to use a linter I can only select these options: How can I use es lint with airbnb and prettier for typescript?
-1
votes
0answers
16 views

How can I use TypeScript, TSX, and React for the front end of my Express project?

I've been following the Getting Started guide on the Express site, only using Typescript. Hit a couple of hurdles but everything is working like in the sample code. I want to use React instead of Pug ...
0
votes
0answers
22 views

Duplicate string index signature.ts(2374)

Following is the type that I wanted to create with index signature in TypeScript. export interface LoginState { account: { [userName: string]: string; [password: ...
0
votes
0answers
27 views

Order by Count(*) --> Order of SQL-Query is not reflected in User.findAll

I want to display the teammates of an user XY which means: all the other users who participated with user XY in the same events. The teammates should be ordered respective their number of common ...
0
votes
1answer
21 views

TypeScript define interface for “as X”

I have the following code: const [surveyResponses, totalCount]: [SurveyResponse[], number] = await this.someRepo.findByFilters(filter) as [SurveyResponse[], number]; Is it possible to give the as [...
0
votes
1answer
36 views

Add data from a form to array an angular 2+

This is my form When entering a question, I can add as many alternatives as you wish. In action would be the button to edit alternative. I would like my array to have this format: { "Question": "...
0
votes
2answers
33 views

Property 'id' does not exist on type 'Object'

im wondering if you can help. I'm following this course https://www.udemy.com/the-complete-angular-master-class/learn/lecture/7441148#questions I have an error: ERROR in src/app/posts/posts....
0
votes
0answers
11 views

Angular Twilio Video Call not working on safari only

Have been working on Twilio video call project in Angular. Have integrated video call using Example Twilio project I had downloaded from the net but I have lost the link where I had downloaded. I ...
-1
votes
1answer
11 views

How Can I configure TS to not transpile in case of error?

I'd like to configure my tsconfig.json file to block transpile in case of error, but I dont find this flag or configuration in docs. Someone know how Can I do this?
1
vote
3answers
52 views

Why setInterval() with a declaration of a function as an argument works differently than with anonymous function?

I don't understand why using function name in setInterval is not working correctly but passing annonymous function is working just right. not working example (it's console logging NaN and before ...
-1
votes
0answers
13 views

how to create dynamic formcontrolName in angular 7?

i want to create dynamic formcontrolname for input filed and validate that input when ever user touches or try to modify the field. my problem is that for each input we need to have dynamic ...
1
vote
1answer
18 views

TypeScript generic rest parameters to union return type

Currently, TypeScript allows declaring dynamic generic parameters. function bind<U extends any[]>(...args: U); But what if I want my function to return a union of argument types? Something ...
2
votes
2answers
41 views

Is frequent use of BehaviorSubject in Angular services a red flag?

I'm writing an application using Angular and find myself using this pattern constantly: @Injectable(...) export class WidgetRegsitryService { private readonly _widgets: BehaviorSubject<Widget[]&...
1
vote
0answers
33 views

TS + React: Conditionally use interface based on props

I'm building a component that either should receive a prop called text or children - not both nor neither. ✓ Allow <NotificationBar text="Demo"/> <NotificationBar>Demo</...
0
votes
0answers
15 views

How to bind nebular radio with boolean value angular typescript

I have an array in my component : options: Array<Array<{ indoor: boolean, outdoor: boolean, all: boolean }>>; and my radio group : <nb-radio-group *ngFor="let option of options[...
0
votes
0answers
4 views

Getting fragment ids from a dbid

I'm struggling a little with seeming inconsistencies between the type definitions, documentation, and behaviour of the viewer. I've written a simple extension to colour elements (which I can't get to ...
0
votes
0answers
15 views

Importing typescript files in preload script using Electron

I currently have a preload.js script that basically adds variables to the window object for a webview. What I want to do is import a typescript file inside the preload script. The preload only ...
1
vote
3answers
66 views

Sum values of objects in arrays of array

I'm trying to sum values from objects. I have array of arrays of objects. (7) [Array(5), Array(29), Array(32), Array(20), Array(10), Array(1), Array(1)] need to sum "quantity" value from each array'...
-3
votes
2answers
24 views

How do I resolve error “TS2339: Property 'gauge' does not exist on type 'JQuery<HTMLElement>'.”

I am working on an ionic (version 4) application and I want to implement a custom gauge meter. What I am using is jquery as $ and have a file jquery-gauge.min.js file which contains gauge() method ...
1
vote
1answer
28 views

How to handle errors with Express .listen() (in Typescript)?

Currently converting my project to use Typescript. My previously working code to launch Express in Node looks like this: server.listen(port, (error) => { if (error) throw error; console.info(`...
0
votes
0answers
10 views

What is the meaning of UnhandledPromiseRejectionWarning in jest tests?

ant to test the following module index.ts async function theFunctionFail() { return await fail(); } async function theFunctionSucceed() { return await succeed(); } async function fail() { ...
0
votes
1answer
19 views

Can't change Boolean array values with forEach in TypeScript

I realized that when I try to change the values of a boolean array with forEach or map functions, the values don't change. I have to construct a for loop and change elements by index. I want to know ...
1
vote
0answers
14 views

Ngx-Datatable - How to handle a boolean data of a row

I'm definitely missing something but I can't manage the boolean value of a row ... what I want is to make a certain string appear if it is true and another string if it is false. This is what I had ...
0
votes
0answers
18 views

How to count background notification messages, using Angular 7 & FCM (Firebase Cloud Messaging)

I'm currently implementing a counter of notifications, based on received push notifications by firebase-messaging-sw.js & messaging.service.ts. I have counted notifications in messaging.service.ts ...
0
votes
2answers
22 views

How to move Ion-Slides next after every 10 second in Ionic 4?

I'm creating Ionic 4 plus Angular app. In that I'm using Ion-Slides to show number of questions one by one. Now I want move Ion-Slides next after every 10 seconds. Ionic Slides Documentation
0
votes
1answer
19 views

How to call key events internally in Angular

When press Enter key, I want to perform the following operations internally. Enter the 'Space key' Enter the 'Backspace key' editor.on('keydown', function (e) { if (e.keyCode === 13) { ...
0
votes
4answers
37 views

Pass object with routerLink

I wanted to pass one object with routerLink. I found lot but, didn't get any satisfied answer. I am new to angular. user.component.html <button type="button" routerLink="/admin">Add Event</...
0
votes
1answer
15 views

Angular how to fix TypeError: getUnfinishedItemsNumber is not a function?

I am working on an Angular project, and I am currently trying to show some data on the screen with the angular double brackets {{like.this}}. I have a list of lists (that is a class made by me), where ...
0
votes
0answers
20 views

Angular Reactive Form Array inside Form Array : Unable to push element in inner most array

I am new to angular any help would be appreciated. I have nested form array in my angular reactive form application. I have to push my inner most array on (keyup.enter) event. In my html code i can ...
0
votes
4answers
25 views

How to share Angular services in promise chaining?

I'm working on Angular6 (typescript). I'm trying to chaining promise with the following code... public start() { this.p1() .then(this.p2) .then(this.p3) .catch((err) => ...
0
votes
0answers
12 views

Should I add a selectedUser into my ngrx store ? (Usage Question)

I have a question concerning @ngrx/store usage I have a state that looks like this => export interface MyToys{ name: string, id :string, description, } export interface State extends ...
1
vote
2answers
49 views

The count is not updated after changes

I have added a menu item to the default .NET Core SPA template nav-menu.component.html file like this: <li [routerLinkActive]='["link-active"]'> <a [routerLink]='["/fetch-data"]' (click)=...
0
votes
3answers
40 views

Cant get variable in data

I created a function that should set a var equal to a variable in data. export default class App extends Vue{ data() { return { evidence: 0 } } handleFileSelect(evt: any) { ...
0
votes
2answers
63 views

Is it possible to use variable to call a function as parameter javascript

Supposed that there is a need to use conditional which do the same thing but calling a different method. const c = true; // for example sake let b = ''; if (c) { b = 'method1'; } else { b = '...
0
votes
0answers
15 views

npm run build throws error code ELIFECYCLE when copy source to new directory

I'm trying to build a project with npm (I'm not sure if it's NodeJS or ReactJS or anything else. I just want to deploy it). I run 2 following commands: npm install npm run build Everything works ...
1
vote
1answer
26 views

How to write a full property that is nullable

Sorry if it is a duplicate question, I can't find it... I want to write out a property, but still keep it nullable. I want public foo?: string; to be (but nullable) private _foo: string; ...
0
votes
1answer
33 views

how to fetch a webaddress from file in an angular webapp

I have recently been tasked with maintaining an angular typescript web application. In order for my company to release it, it will need a file in which necessary web addresses are specified. A config ...
0
votes
3answers
58 views

Angular 7 loop Json array

I have a JSON file and want to fetch a key and value from it. How do I fetch both key and Value in Angular 7. I want to show in both template and controller class. Example: I want to show "EX" which ...
0
votes
1answer
28 views

Custom Angular Material 2 DataTable table header by object

I have a normal Material 2 DataTable, and I want to custom the table header by object For Example: <mat-form-field style="width:100%"> <input matInput (keyup)="applyFilter($...
0
votes
0answers
17 views

Spy on component method before TestBed.createComponent()

I am using AG-Grid which provides a call-back method for when the table has finished initializing. I need to make sure this method is called when the table has finished initializing but I'm not sure ...