Newest 'typescript' Questions - Stack Overflow

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.

0
votes
0answers
4 views

I'm unable to manipulate data stored in an array from firebase

I'm getting data from firebase with the following compound query: filterItineraries(filters: any): any { this.allItineraries = []; this.filteredItineraries = []; for ( let i = ...
-1
votes
1answer
36 views

How can I merge the result of 2 http calls

I have 2 different webservices that I need to call. The first returns information about a city (id, name, state, population, and other statistics). The second service returns a list of hotels by city (...
0
votes
0answers
12 views

Cannot manipulate data from axios get request

I want to use data from the axios response. I know it returns a promise object, but how do I manipulate the data in .then, and make it accessible? Do I need to add a callback function to my getData ...
0
votes
0answers
7 views

TypeScript + Mocha + Express - TypeError: app.address is not a function

In converting an API from ES6 to TypeScript, I'm running into this issue when trying to run unit tests against the Express REST Endpoints: TypeError: Cannot read property 'address' of undefined I've ...
0
votes
1answer
11 views

In Pulumi, exist a equivalent to pulumi.Output.apply, but to transform pulumi.Input values?

I'm developing a Pulumi ComponentResource named CopyPostgresql in Typescript. CopyPostgreSql is a Kubernetes job that copy in streaming the content of a source Postgresql database to a target ...
0
votes
0answers
16 views

Listening for events fired by data-dismiss in typescript

I am trying to listen for the data-dismiss event when an ng-bootstrap modal is closed function(modal) { modal.element.on('hidden.bs.modal', function () { console.log('closed'); ...
0
votes
1answer
10 views

TypeScript: 'as const' combined with type?

I want to combine both having a type for a constant, and using it "as const" to get the literal types as the type... how do I do this? type MyType = {name: string}; const x:MyType = { name: '...
-1
votes
2answers
30 views

Remove ’ on string using regex

I have a word like this What’s On. How to remove space and ’? I can remove space like so data.caption.replace(/ +/g, "") How to do the other part?
0
votes
0answers
21 views

convert JSON object to html table format in typescript

I am trying to convert JSON object to html table format in typescript and send using window.location.href = "mailto:?subject=subject&body="+JSON.stringify(this.Notes); Any recommendations here [ ...
1
vote
1answer
16 views

ts-sinon: Property 'returns' does not exist on type

I am writing an application using Typescript, and want to create unit tests with ts-sinon. In their README, they state that you can stub methods like this: import * as sinon from 'ts-sinon' class ...
0
votes
1answer
22 views

Modal Closes When Clicked On

I have a modal that closes when I click on certain areas of it. This is mostly around the top, bottom and sides. This is my modal: <modal data-backdrop="static" id="editAcc"> <div class=...
0
votes
0answers
28 views

How to create a method that runs before router method in NodeJS

Loopback 4 Framework is used. How to I create @authentication_control() method to use before router method. If it returns true then we get router's answer. If it return false then we get HTTP 401. ...
0
votes
0answers
28 views

Automatically detect by payload if POST, PUT or PATCH is needed

I have a frontend TypeScript app that uses a RESTful api. I have following domains there: interface Foo { id: string; prop: string; anotherProp: string; } interface Bar { id: string; ...
0
votes
1answer
7 views

When using Socket.io-client, Node JS express, and Webpack I am getting “require is not defined” error in the browser

I have an Node JS Express Application running. I am trying to integrate Socket.io with the server to connect to it on the Client. My server.ts file: import express from "express"; import { ...
0
votes
0answers
7 views

In IBM loopback 4, can I use getter and setter for a model property?

When I generate a model with loopback cli (lb4 model) I get a model with some properties. I am specifically trying to make a setter to hash a user entity password. Initially, I get the following code ...
0
votes
1answer
26 views

Create String Literal Types dynamically

I have defined the following type: type UserConfigCategories = 'tables-config' | 'link-config' | 'general-config'; however this type can grow and I do not want to have to update it. Is it possible ...
0
votes
0answers
7 views

Configuration to support .jsx and .ts in one project

My react components are build up on .jsx but now i am migrating them one-by-one on typescript. Facing babel configuration issue to support both ts and jsx. Also my webpack is not giving proper linting ...
0
votes
1answer
16 views

Destructuring fails on type depending on generic

I have these 2 interfaces: export interface Converter<T> { decode?: Decoder<T>; encode?: Encoder<T>; notify?: Notifier<T>; type?: T; } export interface Api { state: ...
0
votes
0answers
6 views

How to toggle office-ui-fabric detailslist row selection using the entire row as a toggle instead of just using the small tiny checkbox

I'm using Office UI Fabric React components and i'm trying to improve change the default selection behavior for a DetailsList. By default, there is a difference between clicking a row and clicking the ...
1
vote
1answer
10 views

Simplifying repeated usage of typings pattern

I have these 2 interfaces: export interface Converter<T> { decode?: Decoder<T>; encode?: Encoder<T>; notify?: Notifier<T>; type?: T; } export interface Api { state: ...
0
votes
2answers
32 views

Input type date is not working with some values angular 6

I have a date input of html5,where I am using date picker,but my value contains some extra characters like "2019-01-01T23-00-11" which is not appearing first time with text box,Here is the code below ...
0
votes
0answers
7 views

how to use Angular6+ *ng-For on pipe filter for slider range

Angular6+ *ng-For on pipe filter for slider range example 1 to 10 , how the filter data arrayList any sorting and show list, following fork link problem https://stackblitz.com/edit/angular-vpmkvu?...
1
vote
0answers
10 views

How to opt-in to TypeScript's strictPropertyInitialization on a per-file basis?

Is it possible to opt-in to TypeScript's strictPropertyInitialization on a per-file basis?
0
votes
2answers
35 views

How return name of image from FormControl in ReactivForms

I want to get the name from FormControl of the image in Angular ReactivForms. I got the full path of the image like file = "C:\fakepath\Screenshot (1).png" but I want only Screenshot (1).png. I using ...
0
votes
1answer
29 views

ID of DOM element gets set but can't mounted on

I want to implement a component which sets the ID of a particular element in the DOM tree dynamically, given @Input parameter. Using a client library, in particular the Stripe Client (stripe.js), I ...
1
vote
1answer
37 views

[] + []; { } +[]; [] + {}; {} + {}; Why only 2 errors in Typescript 3.6?

TypeScript will try to protect you from portions of JavaScript that never worked (Basarat - Typescript Deep Dive) [] + [];// TS error { } +[];// OK, why? [] + {};// TS error {} + {};// OK, why?...
0
votes
1answer
12 views

Delcare index 0 on type property

I would like to create a type for the following: categories.categories[0].category.map((c: CategoryObject) => ({ category: c.name[0]._text[0], Is it possible to declare the index 0? like: ...
0
votes
1answer
16 views

Extend child component props into wrapper component

I want to create a wrapper component that picks the partial of some props of an inner component and adds some custome defined props. The problem with this is that pick will create a type not an ...
2
votes
1answer
27 views

Flatten nested array with type inference

I am trying to create a function that can flatten nested arrays in typescript. So far I have this: function flattenArrayByKey<T, TProp extends keyof T>(array: T[], prop: TProp): T[TProp] { ...
0
votes
0answers
9 views

Resolve 'Conflicting definitions for node' TS4090 error in VS 2017

I have a TypeScript project that builds and runs, but I have a ton of build errors that all seem to stem from one error: TS4090: (TS) Conflicting definitions for 'node' found at 'C:/[projectpath]/...
0
votes
2answers
21 views

Property 'catch' does not exist on type 'Observable<IEmployee[]>'.ts(2339) Error is not resolved by adding import 'rxjs/add/operator/catch';

When I hover over .catch(this.errorHandler), I get a the error message Property 'catch' does not exist on type 'Observable'.ts(2339) I can not import the catch function into angular typescript. ...
0
votes
1answer
35 views

X button not closing bootstrap error alert

I have an error div that displays errors: <div *ngIf="isScreenError" class="alert alert-danger alert-dismissible"> <button class="close" type="button" data-dismiss="alert" (click)='...
0
votes
2answers
16 views

How do I inject an event listener to html generated via v-html

I have some html content in the form of a string variable log.htmlContent. I pass it into a div to be displayed via v-html. This div in particular only displays if log.htmlContent contains an img tag (...
-2
votes
0answers
22 views

Ngx-Bootstrap-Datepicker gives value of selected date as different format. need it as “DD/MM/YYYY” format

Ngx-Bootstrap-Datepicker gives me a different date format. I need it like "DD/MM/YYYY". I have set the 'bsConfig' dateInputFormat as 'MM/DD/YYYY' which gives me proper format in textbox but not in ...
0
votes
1answer
19 views

How to use a module when it could not find a declaration file

I have a typescript project using node.js. There is a module i want to use npm package country-code-lookup. The problem is it does not have a supporting types declaration for it. However, i'd still ...
1
vote
1answer
14 views

How do I add ESNext Array functions to an existing nested array interface?

I'm getting this error: TS2339: Property 'flat' does not exist on type 'ContentfulImageAsset[][]'. I want to add .flat() to ContentfulImageAsset[][]. I tried adding it to my interface and got: ...
0
votes
1answer
31 views

NodeJs Express generate get request from an array

I have a folder that has some json files in it, so I want to access them through my backend dynamically without the hassle to hard code changing data. The Code works except one thing localhost/Foo....
0
votes
0answers
59 views

Get id of first element from array (Angular)

I have a generic method to get data from back-end and pass it to an array Here is the code of the method, where I pass method for getting data, array and default value, where I need to write the ...
1
vote
1answer
16 views

Object is possibly undefined on jquery methods

I am trying to add a method for when the user gets to the bottom of the window, but typescript is stopping me and saying the object is possibly undefined on window.scrollTop(), height(), and document....
1
vote
1answer
36 views

Navigating to other component and back does not trigger ngFor again

I have an Angular app with two components I can navigate to via the navbar. Both components represent their own view and have a periodic http request to an API. When I navigate forth-and-back between ...
0
votes
0answers
14 views

set text for edit in ng-Quill Editor

I am using ng-quill editor in my form. I need to set the value of my reactive form from the component but I don’t know how. I tried following the documentation but am still unable to set the value. ...
3
votes
1answer
37 views

A way to disable “type argument inference” in generics?

I was hoping that giving a default value to a generic will take precedence over type inference, but it doesn't: // placeholder for a real express response.send const sendResponse = (x) => console....
0
votes
0answers
14 views

Cannot bring front PrimeNG Dialog window

I use PrimeNG dialog in my Angular project as shown below and when opening dialog the horizontal line is still visible. Although I tried to set different baseZIndex and autoZIndex values, the result ...
0
votes
0answers
6 views

Problem with connecting to colyseus server in facebook instant game

I want to create fb instant game using phaser with colyseus server but i have problem with connecting. Everything is working great when I test it local, but when i upload package to facebook i got ...
1
vote
0answers
31 views

How to convert .service tag to TypeScript command

I'm trying to convert my AngularJS program to Angular, which means my code needs to be converted to TypeScript. I'm having problems with the .service part of my code. I've already tried to just ...
-1
votes
1answer
21 views

Typescript prevent assertions to a super type

Is there a Typescript compiler flag such that the following code would not compile? interface A { key: number } var B = {} as A; For any cases where the type of A extends B. Such that for ...
0
votes
2answers
53 views

Why is my variable always being mutated inside this function (if the the function doesn't even touch it)?

I retrieve an object from my api, save it in a variable an it's suposed to not being modified anymore but it's being modified unexpectedly I checked the entire component, all the functions and the ...
0
votes
2answers
25 views

How to set “onPress” 's Switch Toggle library in React Native with typescript

I need to use a switch toggle in my App (library git: dooboolab/react-native-switch-toggle). I'm using typescript in react-native. I get an error when I set the function for the onPress ...
1
vote
2answers
34 views

Value parsed to observable before being subscribed to

I have a service (data.service.ts) and a component (page.component.ts). In this data.service.ts service there is an observable called changes$ When I load my page it successfully gets the data from ...
0
votes
1answer
17 views

Typescript Protractor : Unable to right-click on element

I am using TypeScript in protractor. I am able to click on the element but am unable to right-click. It does not show any error message when attempting to right-click the element. let roleList = ...