Top "Typescript" questions

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

Angular and Typescript: Can't find names - Error: cannot find name

I am using Angular (version 2) with TypeScript (version 1.6) and when I compile the code I get these errors: Error TS2304: …

angular typescript
Casting a number to a string in TypeScript

Which is the the best way (if there is one) to cast from number to string in Typescript? var page_…

javascript casting typescript
How do I convert a string to enum in TypeScript?

I have defined the following enum in TypeScript: enum Color{ Red, Green } Now in my function I receive color as …

typescript
How to declare a type as nullable in TypeScript?

I have an interface in TypeScript. interface Employee{ id: number; name: string; salary: number; } I would like to make salary …

typescript nullable
Angular 2 - Setting selected value on dropdown list

I have run into an issue in pre-selecting values on a dropdown list in Angular 2. I set an array of …

typescript angular angular2-forms
How to suppress "error TS2533: Object is possibly 'null' or 'undefined'"?

I have a type: type tSelectProtected = { handleSelector?: string, data?: tSelectDataItem[], wrapperEle?: HTMLElement, inputEle?: HTMLElement, listEle?: HTMLElement, resultEle?: HTMLElement, maxVisibleListItems?: number } …

typescript
How to pass optional parameters while omitting some other optional parameters?

Given the following signature: export interface INotificationService { error(message: string, title?: string, autoHideAfter?: number); } How can I call the function …

typescript
How to generate components in a specific folder with angular-cli?

I am using angualr4 with angular-cli and I am able to create new component with the following command. E:\HiddenWords&…

angular typescript angular-cli
TypeScript Objects as Dictionary types as in C#

I have some JavaScript code that uses objects as dictionaries; for example a 'person' object will hold a some personal …

arrays object dictionary typescript
Typescript: How to define type for a function callback (as any function type, not universal any) used in a method parameter

Currently I have type definition as: interface Param { title: string; callback: any; } I need something like: interface Param { title: string; …

javascript typescript