The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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
1answer
13 views

data fetch pattern for json string

I'm saving settings of a page in the local storage. Works just fine. const settings = [amount, hours] localStorage.setItem('settings', JSON.stringify(settings)); Now, the same service class should ...
0
votes
1answer
25 views

How to disable typechecking when using a logical operator or when the final result is allowed to be undefined

I'm trying to use an object as possibly undefined. Although typescript won't let me, because it cannot access the "undefined" property. So Imagine I have a type called StackOverflowUser and another ...
0
votes
0answers
9 views

Web-Bluetooth: custom typings for navigator

I'm writing an browser application for my device which will communicate via bluetooth. Can someone help me with typescript typings? I'm trying to access bluetooth property in navigator object: let ...
-1
votes
0answers
19 views

how to create a single effect from six effect

I wanted to create a single effect from bunch of effects in the effect class. each effect is making api and on success of it is calling a success action. I wanted to create single action which would ...
0
votes
0answers
17 views

Can't use @type/node with typescript 3.2

I can't use any type of @type/node with typescript 3.2 My tsconfig : { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, ...
0
votes
1answer
20 views

v-model to dynamically added input fields are set to undefined

The user is requested to add columns giving a name and other information associated to the new column. My current issue is that i could see the new columns added into an array but they are undefined. ...
0
votes
0answers
10 views

How to grow a modal from a link (button) or icon, to full size, then when close, shrink back to origin

I have a question. Is there a way this codepen I forked: https://codepen.io/pborregg/pen/zXzYKb can be incorporated into magnific popup? Here's the HTML: <div class="container" id="app"> &...
1
vote
1answer
21 views

Angular 7. Iterate indefinitely among 3 states when clicking (to order a table)

I want to order a table in Angular 7, and when I click on the header I want to change between 3 states (asc, desc, disabled). What is the best way to iterate between these 3 states indefinitely in ...
0
votes
1answer
16 views

“Throwing” in the type system and validating types

I sometimes create a type to do some sort of validation on input that I expect to be passed. // Library code type Validate<T> = T extends Something ? T : never // User code type MySpecificType ...
0
votes
1answer
9 views

No namespace support after upgrading Babel in React Native?

I created a project using 'react-native init --typescript', upgraded react-native to 0.59.5, babel using npx babel-upgrade, installed and configured metro-react-native-babel-preset. However, now the ...
0
votes
0answers
29 views

Using Two-Dimensional Array to retrieve file information

Is it possible to use 2-Dimensional arrays to capture a file's name and its base64 content (assuming it was converted beforehand)? How would one go about doing this? I would assume that this would ...
-6
votes
1answer
41 views

Async in angular? [duplicate]

I'm using Angular 6 in my project, the problem has shown below: getPersonData() : personData { this.user = { username : getUsername() } console.log('Inside getPersonData() method'); } ...
1
vote
0answers
26 views

HTML Editor for Angular7

I'm looking for an HTML-editor to embed in an Angular7 project. The user of the editor will be creating very simple web pages or making small edits to more complex pages. I originally thought a ...
0
votes
1answer
13 views

How to pass the login user session data into php file using angular7

I created authentication service,login component, SuperAdmin/header component. Using authentication service i'm matching user entered values to the Mysql Database. and fetching Below User Data into $...
1
vote
0answers
36 views

Angular 7 - How to retry an http request on certain response status codes?

I'm trying to catch http request's errors from an Angular interceptor and handle 401 as logout while retrying a 503 and 504 responses n times. This is my http interceptor: intercept(req: HttpRequest&...
0
votes
1answer
17 views

How to check if user didn't put a past hours and minutes in diff inputs for both prop?

I've stuck on the as it seems to be a simple problem, I got 2 inputs next to each other, one for the hours and 2nd for the minutes, what I want to achive is to get allowed user to type in a current ...
-1
votes
1answer
14 views

How to know timelaps that user spend on Angular page?

I have a questionnaire Angular app and would like to capture time spent on each question page by the user and aggregate time user spends on questionnaire from start to end using Angular?
1
vote
0answers
41 views

Why does my create-react-app project output thousands of lines of warnings about types while compiling?

I'm taking over a legacy project. I'm mostly a backend programmer and not up on the latest JS build tools. I'm trying to figure out how the project is put together. The project uses react-app-rewired. ...
2
votes
0answers
21 views

Computed key, as interface key, from enum member

I am trying to set up an object property by selecting its key using a computed key, through an enum, like in the following snippet of code. For some reason, solution 1, and 2 don't work. Those are ...
0
votes
0answers
16 views

cant get angular-user-idle to start watching

I'm trying to implement a time out for my angular app, I've chosen the angular-user-idle library https://www.npmjs.com/package/angular-user-idle but I can't seem to get it started, also I can't add ...
0
votes
0answers
11 views

Ng-Chart ocultar dataset

Estou utilizando o ng2-charts, com type script porém não estou conseguindo utilizar a rotina indicada na documentação para ocultar algum item do dataset. Ao tentar utilizar o método isDatasetHidden(1)...
0
votes
1answer
24 views

How to create a custom form validator to accept only valid JSON in Angular

In my Angular app, I have a reactive form which for simplicity I will assume to have only one control called configJson which is represented by a <textarea> in the DOM. I need to validate this ...
0
votes
1answer
20 views

Extending Classes with Index signature

I am trying to make an abstract class but things aren't working as i would like them to and i fear my knowledge of typescript is what is limiting as i think this is a fairly generic use case. I have ...
1
vote
1answer
14 views

How can I configure tsc to compile test specs from a specific folder?

I'm implementing e2e tests into an Angular project. It wasn't started with @angular-cli, so I'm configuring most of it manually. What I'm trying to do now is to define a script in package.json to ...
0
votes
1answer
16 views

I have an import problem with D3 and typescript in intelliJ

Errors in browsers' console when I use d3.select() in typescript code. I've tried other methods like d3-timer.now() and had the same problem. I'm new to typescript. I'm using intelliJ Ultimate 2019....
0
votes
2answers
16 views

TypeScript Shared codebase with two output directories

I faced a problem :/ I want the shared codebase "shared" to be in both directories. Is this possible with typescript itself or do I need some extra build-tasks? Is there a better solution? Important: ...
0
votes
1answer
18 views

How to declare typescript module to prevent “implicitly has an 'any' type” error?

I'm importing a relative module in my typescript code: import * as NGLViewer from '../../ngl/build/js/ngl.esm' (It's at https://github.com/arose/ngl) That module is built with typescript and has ...
1
vote
1answer
28 views

Angular6: Unable to access js variable in template getting async data

I am trying to print the list of banks given by razorpay on the template I get all the bank lists Object in response and save it in a variable banks, but this variable does nothing in the template i.e....
0
votes
1answer
13 views

Vuex and vue-property-decorator reactivity with $store

i'm trying to use vuex $store on my @Component. But its not be reactive :/ Exemple : import { Component, Vue } from 'vue-property-decorator'; @Component export default class Internationalize ...
0
votes
0answers
17 views

Do I publish tsconfig.json to NPM or not?

TSC has recently started generation tsconfig.tsbuildinfo files. I'm now adding those to .npmignore to prevent me from publishing them to NPM, because they're artifacts to keep track of local builds. ...
-1
votes
1answer
27 views

Understanding complex Type Script Type declaration

When using Angular HttpClient, I want to pass the httpHeaders with my own Typed Object, I couldn't understand how to define an object of type [header: string]: string | string[]; Please help me to ...
0
votes
1answer
10 views

How to fix “Error: StaticInjectorError(AppModule)[NgbDropdown -> ChangeDetectorRef]”

I'm trying to create a webapp using Angular, the project is compiled without errors. When it is executed the browser shows a blank page and returns this error: ERROR Error: Uncaught(in promise): ...
0
votes
0answers
14 views

How do I fix MatSort clicking on a header issue where nothing happens

I am trying to sort via the table headers using MatSort however I see the arrows changing to ascending and descending but the data doesnt change like expected. I have tried various things eg imported ...
0
votes
0answers
12 views

Using vue-cli-service with typescript

I have a vuejs project that I created with the vue cli and I now want to enable typescript on the project. I took a look at this guide but it recommends adding a webpack config and replacing vue-cli-...
0
votes
0answers
15 views

problem with nested objects in json server

I have the following object on a JSON server on an Angular 6 project and I would like to make crud calls. I need to be able to delete the contents of "examsToBeDone" by id, but I can't figure out ...
0
votes
1answer
30 views

UseState is not rerendering page after onClick event

I have problem to re-render page after setting state via useState hook. State value changes, but page isn't re-rendering. export function langauge(props: Props) { const [languageChange, ...
0
votes
1answer
31 views

(ngModelChange) delete last symbol (Angular)

I have 2 inputs where I enter value and concat it into new one Here is code from HTML <div class="form-group"> <label>{{l("FirstName")}}</label> ...
0
votes
1answer
14 views

How to delete a sub collection item in Google Cloud Firestore

I' am working on an angular project with Google Cloud Firestore. Then I have a question. How delete a sub collection item. For Example I want to delete address in follow. I'm using the ng2-smart-table ...
0
votes
3answers
37 views

Angular 2+ how to get focus to modal inputs on opening the modal?

In a custom modal component that i have built, i want to get the input in the modal focused whenever the modal is opened basically i tried to approaches, 1) is using ViewChild and ElementRef, then ...
0
votes
1answer
14 views

How do I set argument names and types for a function argument in TypeScript?

In TypeScript you can set argument types, like this: function x(y: string[], z?: Function) How do you set types for the arguments of a function argument? For example, here is what I'd imagine it'd ...
3
votes
1answer
39 views

How to use java-script npm packages in type-script IDE?

I have created an empty react-native project but using type-script (like react-native init MyApp --template typescript), then installed on that react-navigation-tabs package, and the problem which I ...
0
votes
0answers
16 views

Link click works in browser, but not in android webview - IONIC

I'm trying to download blob files from my rest api. The code works when running in browser, but when i try to use in android app, the code does nothing. And dont show any errors. See the code below: ...
1
vote
1answer
35 views

Cannot find a differ supporting object. NgFor only supports binding to Iterables such as Arrays

I've inadvertently changed some code somewhere and now my posts are no longer being pulled through, can anyone spot the mistake? Service: posts: AngularFirestoreCollection<any[]>; ...
0
votes
1answer
8 views

Create type with values from a certain property from objects in array?

I have objects in an array. All objects have the property code. export const languageCodeToLanguageOption = [ { code: 'cs', displayOrder: 1, text: 'Česky' }, { code: 'zhhans', displayOrder: 2,...
-5
votes
1answer
31 views

typescript method returning undefined?

Hi I have an angular 5 application. I have a service method that returns undefined . here is what i am trying to do . i have a function named cloneFlight. i am making a call to flightsService....
1
vote
0answers
10 views

Typescript Unit Test Unexpected token

I'm newbie in both typescript and jest. And follow this tutorial but not sure why it prompt error for this simple code when i try, anyone could give some advise? Unexpected token, expected "," (1:...
0
votes
1answer
12 views

Create a type with the keys from a Map?

How can I create a type with the keys from a Map? export const languageOptionsMap = new Map<string, ILanguageOption>([ [ 'cs', { value: 'cs', order: ...
-1
votes
1answer
17 views

Subscribe is not working for observables in angular 6

Console screenshot LoginServices LoginComponent I'm trying to make a website using angular 6, In the login component whenever i try to subscribe the observable nothing happens. I've tried almost all ...
0
votes
0answers
15 views

Vscode API: when 'case' show contribution

I am trying to set the context menu in a TreeView on a ftp extension that I am writing. In the package.json I can add a "when" case in which I am trying to check if the viewItem is a directory or a ...
3
votes
5answers
50 views

How to stop Interval?

I'm trying to create a button that will stop a method running a setInterval. I'm using clearInterval to do so, but it won't let me target the setInterval variable for some reason. class Helpers { ...