Most voted "typescript" questions
Typescript is a super superset of Javascript created by Microsoft that adds optional types, classes, interfaces and modules and compiles for pure Javascript.
Learn more…1,167 questions
Sort by count of
-
4
votes2
answers459
viewsWhat’s the "Never" type for?
Today I was asked what the guy is for never Typescript, but it got confused for me. It just serves to say that it does not return anything? What’s the difference to the void?…
-
4
votes1
answer770
viewsHow to remove a page from Ionic 2 / 3 navigation
In a hybrid application with Ionic 3 I have 3 pages that are part of the process of buying a product. The process is as follows: The user is in the cart and click on "Choose payment method" In case…
-
4
votes1
answer1332
viewsWhat _: and _
What does _: and _. mean in the definition of functions as in the example below. constructor(){ router.events.subscribe((_:NavigationEnd) => this.currentUrl = _.url); } I have many doubts about.…
-
4
votes1
answer460
viewsHow to install the Typescript Plugin in Sublime Text 3?
I am trying to install the plugin in Sublime Text 3, and for this I did the steps: I installed the GIT I executed the available commands here at the GIT terminal. I pressed Control+Shift+P to see if…
-
4
votes1
answer630
viewsDifference from Angular Production and Development Build
I would like to know the differences between the build of production and the build development in Angular?
-
4
votes2
answers422
viewsOmit passing of parameter
I have the following method that contains the second declared parameter post(path:string, body: Object = {}){ ... } And here the call of the same with the omission of the second parameter…
typescriptasked 5 years, 3 months ago renanvm 3,797 -
4
votes2
answers4395
viewsPost com x-www-form-urlencoded no Angular
Hello, I have a POST request that is content-type: x-www-form-urlencoded. I need to pass some parameters on my Body, this way: I’m doing this way below to add my parameters on the request body:…
-
4
votes2
answers353
viewsWhy does Typescript when compiled convert "Let" to "var" in variables?
If let variavel = "valor"; is also compatible with JavaScript, because in the compilation of Typescript, it turns to var variavel = "valor"? Take the test right here: function foo(){ var x = 1; let…
javascript typescript ecmascript-6 variable-declarationasked 5 years, 10 months ago Ivan Ferrer 12,096 -
4
votes1
answer140
viewsHow to deal with Undefined (or null) union in Typescript?
I am implementing this method below but it is giving me this error: Type 'Task | Undefined' is not Assignable to type 'Task'. Type 'Undefined' is not Assignable to type 'Task'. I can’t fix it. The…
-
4
votes1
answer649
viewsPayment cannot be processed because don’t have Secure Connection.SSL Certificate
I am using Ionic 3 with the plugin of the marketPago and when I will complete the purchase it returns me this error, everything takes into account to be an error caused by the Ionic run on a…
-
4
votes2
answers430
viewsAlert message Response Headers
I’m on a project. NET, in which I create a login page and check the DLL, and in this check, is passed a string of a message that I need to capture with a Typescript to give the alert. This message…
-
4
votes5
answers815
viewsCheck if URL has string
hello, I am making a code using Typescript and I need to do a check to know which page the user is on, I am doing this check as follows: const url = window.location.href; if (url.indexOf("/Menu")) {…
-
4
votes1
answer147
viewsInjection of dependencies into functions and not classes. Is it "wrong"?
It is not new that the concept of dependency injection is almost directly related to classes. Tell me "dependency injection" and I can imagine the following: // services/UserService.ts export…
typescript pattern-design encoding-style dependency-injection iocasked 4 years, 11 months ago Luiz Felipe 32,886 -
4
votes1
answer799
viewsHow to export classes, methods or constants in a Python module
Hello, I’m starting to work with Python and have a good experience with Typescript. In Typescript, I have a habit of creating modules when I need to organize my code, so: <rootDir> domain…
-
4
votes4
answers4308
viewsLoad component only after finishing HTTP requests
My application uses angular-6-json-schema-form to create and manage forms dynamically. Now I would like the select Component, for example have your data coming from some REST source: My attempts:…
-
4
votes0
answers1533
viewsAngular2+ ngx-Mask deleting value in dynamic mask change
I have a document field where the value can be CPF or CNPJ. <label for="cnpj" class="label-control"> <select class="labelSelect" name="tipoDoc" id="tipoDoc" [(ngModel)]="tipoDoc">…
-
4
votes1
answer74
viewsOptional dynamic keys Typescript
I’m trying to create an interface with dynamic keys: type Keys = 'a' | 'b' | 'c'; interface MyInterface { [key: Keys]: string; } In doing so, I get the following error: An index Signature Parameter…
typescriptasked 4 years ago Gabriel Ribeiro 495 -
4
votes1
answer115
viewsHow to type keys (Keys) of objects nested in Typescript?
I need that guy ColumnDefinitionType accept the object keys IUser, as well as accept the keys of objects nested to the IUser. export interface IUser { userId: number; username: string; name: string;…
-
4
votes2
answers64
viewsIs it possible to perform an overload (Overload) with Arrow functions?
I have a function where the return type depends on the parameter type. I was able to declare this overload with function, but not with Arrow Function, because I get the error: Cannot redeclare…
-
4
votes1
answer58
viewsHow do I make Typescript accept the "useRef" value in React?
export const Test = (): JSX.Element => { const wrapperRef = useRef(null); useEffect(() => { function handleClickOutside(event: MouseEvent) { if (wrapperRef.current &&…
-
4
votes1
answer52
viewsHow to use interpolation in declaring a property of a type?
I’m trying to declare a guy who accepts different properties with a number, for example: prop1, prop2 ... propN. The point is, I’m having a hard time getting it to behave the way I expected it to,…
typescriptasked 2 years, 10 months ago Rafael Tavares 4,528 -
3
votes1
answer1135
viewsIonic2 add element in view
I need to create a click event that when pressed creates an input in the view. How can I do that? Thank you Ps: ionic2 typescript use HTML <ion-navbar *navbar> <ion-title> POSimplex…
-
3
votes2
answers981
viewsAngular2 ngFor help with loop
I have a file nvi.json that is this way: [ { "abbrev": "gn", "book": "Gênesis", "chapters": [ { "1": { "1": "...", "2": "..." } }, { "2": { "1": "...", "2": "..." } }, { "3": { "1": "...", "2":…
-
3
votes1
answer649
viewsaccessing class data in a function in the global scope with typescript
I’m developing an Angular 2 application and I’m using the Youtube API. The Youtube API requires me to implement some functions in the global scope, so I did the following: export class MyClass {…
-
3
votes0
answers817
viewsVariable me returning Undefined which is assigned inside subscribe
In the code below, the variable date is returning me Undefined, now if I put console.log(this.data); inside subscribe returns me with the correct value. import { Component, OnInit } from…
-
3
votes1
answer413
viewsIs it possible to create an object/class/interface that represents a Function signature?
Everything already works as expected in my code. What I want is to make it more verbose, making the signatures of the method more self-explanatory (I know I can use Docs comments for this, but I…
-
3
votes1
answer183
viewsNavigation by Id Ionic 2
hello. I am developing an application with Ionic 2 and I am with the following situation. I have 2 tables, 'stores' and 'publications'. My question is, how to do from the 'store' listing to open…
-
3
votes1
answer2946
viewsAngular with Typescript or Javascript?
Researching a little about Angular (v 2+) saw that in many places it is commented that Angular has support for Typescript and that its use is more common than pure Javascript, so what are the…
-
3
votes1
answer464
viewsIonic - save latitude and longitude on firebase
I created a project on Ionic and I would like that when the user clicked on "save location", the position from where he left the marker was saved in his user profile in firebase, however, I have no…
-
3
votes2
answers4339
viewsDifference between start date and end date with Moment js
I need to inform how much time I have of a certain chronometer, I have the date of the moment at which I started the event. I’m developing with angular 4 typescript and use plugin Moment js In my…
-
3
votes1
answer868
viewsAngular Interceptor 5 is not triggered
Follows my code: app module.: import { APP_BASE_HREF } from '@angular/common'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from…
-
3
votes2
answers472
viewsHow to read a JSON file dynamically? (ANGULAR 2)
For example when starting I want my program to load all messages previously stored in a JSON file (message.json) ngOnInit() { this.emissor = 'Victor';…
-
3
votes2
answers1305
viewsParent component receiving child component data
It’s kind of confusing what I want more come on I have my parent component that contains some buttons and a search field, and I have my kids components, I want to implement the function of the…
-
3
votes1
answer8960
viewsValidate CPF at Angular 5
Dear, I would like to know how I can validate CPF in angular 5, I have done several searches but so far nothing. I’ve already been able to perform the e-mail validation. Could you help me?
-
3
votes1
answer434
viewsHow are modifiers implemented in Typescript?
Typescript supports all functionality present in Javascript (proper Ecmascript 6), and has modifiers such as: private, protected and abstract. However, in ES6 there are no such modifiers. To…
-
3
votes0
answers55
viewsAccess modifiers in Typescript
In an application that uses Typescript, what is the need to use access modifiers? Because at runtime modifiers do not make sense for Javascript.
-
3
votes2
answers784
viewsRecursive Function in Typescript Returning Array with Dynamic Objects
I am beginner in Typescript and tb in Javascript, so I confess not to have much knowledge of the language, therefore, I will describe my problem. I have the following table in a Postgres database:…
-
3
votes1
answer1234
viewsIonic-Native/http emits error "Nullinjectorerror: No Provider for HTTP!"
I’m starting at the Ionic 3.2 angled, as documented https://ionicframework.com/docs/native/http/ I installed the module in the project @ionic-native/http with the following commands via CMD: ionic…
-
3
votes2
answers1134
viewsHow to get an Observable from an array item?
Working with Observable and Rxjs, I came across the following problem. At a certain point in the code, my access to the bank is done as follows: getExemplo(id: number):Observable<Exemplo>{…
-
3
votes2
answers84
viewsConvert string.match() result to string?
How can I convert the return method match() string? For example: var value:string = ">>>> Ola" var result:string = value.match(/\w+/g) The above example gives error in variable result.…
-
3
votes1
answer216
viewsWhy do we use the type "Static" in a function in Typescript?
Why do we use the word static in a function in Typescript/Angular? Is she a type or just a reserved word? How can we refer to her? Example: export class ClasseExemplo{ static fazerAcaoComponent() {}…
-
3
votes1
answer41
viewsHow to define the possible values of a string in an iterface from an object?
I have that class Item: class Item { nome: string; idade: number; } And that interface ConfItem: interface ConfItem<TypeItem> { titulo: string; } How do I make for the title in ConfItem…
-
3
votes1
answer835
viewsHow to add days to a date with Moment.js?
I’m trying to calculate the deadline of my site in days, IE, I put "14 days" and it turns into 00/00/0000. I’m doing it this way, but she’s taking the full date and turning it into days, I want to…
-
3
votes2
answers5045
viewsClose modal when you click the button
Hello, I have this following modal, whenever I click on the button "Refused sale" it opens, however I wanted to close this same modal every time he clicked on the button "Send", that in the case is…
-
3
votes1
answer3965
viewsCannot find control with unspecified name attribute Angular
I’m trying to make a simple component using Reactive Forms in the input, but this giving error that until now had not seen Input.components.ts import { Component, OnInit, Input } from…
-
3
votes1
answer210
viewsReturn a function to be executed - Typescript
I’m in a situation where I would like to generate an engine that runs an async function and that runs a successful callback on Ry and a catch error, and the responsibility of these callbacks is to…
-
3
votes1
answer1482
viewsTurn String into Localdatetime
I created this Edit Fields button, to change the data of these users I created, the name, name and document are working, without the date of birth is updated, but when I try to edit the Date of…
-
3
votes1
answer45
viewsjQuery code for Typescript
I am passing a code I had done in jQuery for Typescript, and am having a problem with this function, because of the .filter(), that actually, from what I understand, does not exist in Typescript,…
-
3
votes1
answer222
viewsHelp to get decimal value of mask input (Ionic 3 + br Masker)
I am having a hard time with a problem that I believe is very easy to solve, but I am struggling hard enough to reach such a solution. I have a simple input that format using the brmasker library…
-
3
votes1
answer341
viewsExpress with Typescript: "Element implicitly has an 'any' type"
I’m trying to dynamically generate my application routes with the Express.router() using Typescript and Node, but it doesn’t work and I’m not able to understand why. If anyone please knows what is…