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
-
63
votes2
answers5844
viewsCoffeescript, Typescript and Javascript
Among Javascript studies, I found in some places many people suggesting the use of Coffeescript or Typescript to accelerate the development process. If I understand correctly, both are like a…
-
16
votes1
answer1733
viewsWhat are the main differences between Dart and Typescript?
We already had a question comparing two languages that run on top of Javascript. I think it was necessary to compare two languages created for the purpose of creating applications for browsers and…
-
13
votes2
answers455
viewsWhat is the new Javascript Temporal object?
I recently discovered that you have a proposal on stage 3 a new object to work with dates. This is called Temporal. I analyzed an example code in a post from Linkedin that uses this new API:…
-
12
votes2
answers231
viewsWhat does " | " mean in Typescript?
I have the following code: export type Teste = Observable<'exemplo' | any>; What the bar means | within the generic argument? Is some kind of comparison any and the string for example?…
-
12
votes2
answers623
viewsHow to publish a Typescript library on NPM?
I set up the package.json with the properties main and types: { "name": "idb2promise", "version": "0.0.5", "description": "TypeScript library to manage IndexedDB Storage", "main": "./dist/index.js",…
-
11
votes2
answers469
viewsWhat are the logical assignment operators ||=, &&= and ??= in Javascript?
I recently came across a code snippet like the one shown below: let alias = req.body.alias; alias = (alias ||= alias = 'generic'); I’ve never seen that operator before ||=, but after a brief search,…
javascript typescript characteristic-language operatorsasked 4 years, 2 months ago Cmte Cardeal 5,299 -
10
votes2
answers1644
viewsWhy use the Angularjs?
I have done a lot of research, but I can’t understand why I use Angularjs, using pages .php then bank returns, CRUD and etc. I deal directly on the pages .php, lists of bank records, insertion and…
-
10
votes2
answers219
viewsWhy do we use a "get" before declaring a function in Angular?
Why do we use a get before declaring a function in Angular or Javascript? That’s an Angular practice? get funcaoExemplo() { return this.exemplo.length === (this.exemplo2 + 1); }…
-
10
votes1
answer177
viewsWhat is Type Annotation?
I’m reading a book about Typescript and I came across something that caught my attention which is the Type Annotation. Take the example: function foo(): { a: number, b?: number } { if (this.a <=…
-
9
votes3
answers2573
viewsHow to use constructor overload in Typescript?
In languages with C#, for example, it is possible to use constructor overload as shown below: public class Teste{ public Teste(bool a, int b, string c){ } public Teste(bool a, int b){ } public…
-
9
votes2
answers113
viewsUse of@in variables
I see in some languages that compile for javascript, such as Typescript and Coffeescript, the use of @ variables, as well as cases where it is not used. For example: w = 10; @v = 11; After all, what…
-
9
votes1
answer812
viewsWhat does "Tree-Shaking" mean?
I closely follow the entire development of the Angular. I know the third generation of the rendering engine (the Ivy, code name for Render 3) will be released soon. Overall, the objectives for this…
-
9
votes1
answer1353
viewsHow to overload methods in Typescript?
I’m having trouble overloading methods in Typescript. The method to be overloaded is a Object Factory rect() one signature has four numerical parameters and the other signature has only one…
-
8
votes2
answers2209
viewsHow to Extend/Inherit Angular2 Component?
Doubt I would like to create extensions for some components already implemented in Angular 2, without having to rewrite them almost completely, because the base component could undergo changes and I…
-
8
votes2
answers115
viewsHow to know which parole is giving true?
For example, I have the following if: if(!condicao1 || !condicao2 || !condicao3){ retorno erro com a condiçao que nao existe } When he gets into that if i wonder which of the parameters is missing…
-
8
votes3
answers6191
viewsThe operand of a 'delete' Operator must be optional
I’m having trouble understanding why it is not possible to apply delete user.password in the code below Terminal return: The operand of a 'delete' Operator must be optional. My code: import {…
typescriptasked 4 years, 3 months ago Bruno Ferreira 129 -
7
votes1
answer6590
viewsFunction "change" with <ion-select><ion-option>
all right? I’m struggling, I hope you can help me... I’m studying Ionic 2 a little while and thought I’d make a simple application. In Javascript I managed to do it quietly, but with Ionic does not…
-
7
votes2
answers97
viewsHow to see the implementation of the Typescript code?
In several programming languages that I have worked or currently work with, I can see the implementation of the developed codes. In Dart or Java for example, I can go to the source code and analyze…
-
7
votes1
answer850
viewsHow does the "infer" of Typescript work?
I know it was introduced in language version 2.8 (see here), but even though I read these release notes, I still can’t understand the workings of infer. How it works? What is your real goal?…
-
7
votes1
answer295
viewsDifference between using Generics and "any" in Typescript?
When I know it’s better to use Generics or any in Typescript?
-
7
votes1
answer146
viewsWhat is the purpose of the keyword "export"?
I created a angular design to start my learning and I am currently using Typescript to do the App. However, a question arose regarding the keyword export (if it really is a keyword). I used it to…
-
7
votes3
answers15990
viewsMascara CPF/CNPJ ANGULAR 8 NG-MASK
I have a Component where I need the input to have the mask for Cpf or cnpj according to the data entry. I am using ng-Mask, but my validation for the mask is only working for the first validation.…
-
7
votes1
answer118
viewsHow to adapt a function that only accepts callback to the promise interface in Javascript?
I’m using an external library function to acquire the token of a user, it is the following: export default function GetGraphToken( email: string, password: string, callback: (graphClient: Client,…
-
6
votes2
answers1862
viewsGroupby in Javascript
I’m getting the following result from a query: [ { "disciplina":"Portugues", "periodo":"1º Bimestre", "tipo":"1ª avaliacao", "valor":9.5 }, { "disciplina":"Matematica", "periodo":"1º Bimestre",…
-
6
votes1
answer133
viewsWhy do we use "<>" in Typescript?
Why do we use <> in Typescript? Example: funcaoExemplo(x: X<any>, x: X): Observable<X<any>>
-
6
votes4
answers729
viewsHow to get the month formatted with zero left in Typescript
I’m trying to get the month in Typescript with Node.js, I’m trying to get it like this: const today = new Date(); var todayMonth = today.getMonth() + 1 if(todayMonth < 10) { todayMonth = '0' +…
-
6
votes1
answer404
viewsHow does type "Unknown" work in Typescript?
The guy unknown is a Feature a little more recent language, and is said as a any, only that type safe. So I was left with some doubts: What is your difference from any? It is safe to use it for type…
-
6
votes2
answers398
viewsWhat are the differences between a type and interface alias in Typescript?
Typescript allows us to create aliases for types. For example: type State = 'inactive' | 'active' | 'banned'; The type allows to also create types for objects, such as: type User = { username:…
-
6
votes1
answer745
viewsWhat is the usefulness of the exclamation (non null assertion Operator) in Typescript?
I recently discovered that in Typescript we can use the operator of non null assertion simply putting a ! where you want to check. When I saw it, I thought it was like in C#, that we have the ?,…
javascript typescript characteristic-language operators nullableasked 5 years, 11 months ago Francisco 7,472 -
6
votes2
answers479
viewsTypescript build does not support Commonjs from Node.js
Let’s say I have a module alert.ts: export default function alert(message: string): void { console.log('Alerta: ' + message) } When performing the build using the tsc, and try to use the code…
-
6
votes2
answers191
viewsTypescript - Incorrect code output - Date
Why the output from that code is: Pessoa { Id: 1, Name: 'Maicon Gabriel Friedel', DateOfBirth: 1997-02-22T03:00:00.000Z } Code: import pessoa from './pessoa' pessoa.Id = 1; pessoa.Name = 'Maicon…
-
6
votes1
answer71
viewsRecursive Problems - Too Much Memory - Angular 9 - Settimeout()
Guys, I’m building an API and I need to make requests every three seconds on the server. Follows the code: countAcess() { if (this.menuExa && this.appService.requestValid()) {…
-
6
votes2
answers47
viewsIs it possible to discriminate unstructured values of an object with union type in Typescript?
I realized that by performing the breakdown in the signature of the function (funcao({ a, b }: Objeto)), I end up losing a certain consistency of the types. In the specific case where I realized…
-
5
votes2
answers1709
viewsHow do I implement the Groupby method in Typescript?
I have an array: interface IFoo { IDCidade: number; Nome: string } var arr = [ { IDCidade: 10, Nome: "Foo" }, { IDCidade: 10, Nome: "Bar" }, { IDCidade: 20, Nome: "Foo" }, { IDCidade: 20, Nome:…
-
5
votes1
answer370
viewsTypescript syntax
I am studying Typescript but do not understand what this example means: interface Person { firstname: string; lastname: string; } function greeter(person : Person) { return "Hello, " +…
-
5
votes2
answers1846
viewsHow to create a static method in a public class?
I would like to create a static method in a public class with a ToastController so that I can access this method in several classes. I tried to do this way below but it didn’t work: export class…
-
5
votes2
answers1047
viewsDifference of ' ' and ` `
I am reading ng-book 2 on Angular 2 and in one of the exercises a doubt arose. When setting up my component first code does not display the values title and link on the console, but the second works…
-
5
votes1
answer326
viewsBring id on route
I’m doing a user management. At the moment, I’m creating the put to edit. But, I don’t know how to bring the id on the route. There is a list of users and also an insert. When the client clicks on…
-
5
votes1
answer500
viewsWhat is npm @types and how do they work?
I’m starting a project with NodeJS and TypeScript and the instructor told to install the @types/node, beyond the npm package TypeScript. He quickly quoted that the @types/node creates types in the…
-
5
votes3
answers775
viewsWhat are the ".d.ts" files?
Studying Typescript I noticed that there are files .d.ts and that it is possible to declare the guys there, but: What is the actual usefulness of files .d.ts? If I already declare the guys in the…
-
5
votes1
answer241
viewsHow to test Exports of a package?
I have a file index.ts which is responsible for exporting all components as follows: export * from './components/com1' export * from './components/com2' export * from './components/com3' export *…
-
5
votes2
answers470
viewsHow to apply mock in "new date()" using Jest?
Please someone knows how to apply mock in the new Date() using the Jest? I tried to do so, but it did not work. The date remains current: jest.spyOn(Date, 'now').mockImplementation(() => { return…
-
5
votes3
answers126
viewsWhy does type "any" exist in Typescript?
I’m studying Typescript and I got to the part about the guy any. What I understand is that the any is used when the type of the value that the variable will have. But if that’s the case, the two…
-
5
votes1
answer109
viewsDoubt about generic types in Typescript
I am currently studying Typeorm, and wanted to create a generic controller, as it will always be the same CRUD operations. I know I can solve with native Typeorm solutions, such as getRepository(),…
-
5
votes1
answer820
viewsElement has the type any implicitly when trying to access a property of a module namespace (object)
Works: import * as Icons from 'react-icons/fa'; ... const teste = 'FaAddressBook'; const Icon = Icons[teste]; Doesn’t work: import * as Icons from 'react-icons/fa'; ... const teste:string =…
-
5
votes1
answer509
viewsPolymorphism in Typescript
I am creating my application with the following structure: An abstract class Person, and inheriting from Person, the classes PessoaFisica and PessoaJuridica, And finally, a class Cliente receiving…
-
4
votes2
answers141
viewsTypescript - Error: Debug Failure. False Expression:
I am trying to create a module definition Node.js. I have the file poolredis.ts, but when I add the line: import { RedisClient } from 'redis'; The Typescript compiler gives me the error: Error:…
-
4
votes3
answers8500
viewsAngular + ASP.NET MVC: Does it make sense?
I’m starting to study Angular2. As I am working a lot with . NET I decided to do a project with ASP.NET MVC 4 and Angular2. Giving a read on hello world of Angular I noticed that Angular has its own…
-
4
votes1
answer334
viewsHow to disable XHR messages finished loading in production
I have a system developed in the Angular language in version 4. The system that generates build of the application in production is the webpack. This being used as the basis the following tarter:…
-
4
votes1
answer660
viewsHow to convert an object vector to another object?
I wanted to know if there is any simple way to convert a vector of objects A to a vector of objects of type B, which follow the second structure: Object A { aId: number; aNome: string; aDesc:…
typescriptasked 7 years, 3 months ago Felipe Avelar 9,507