Generic TypeScript interface with mixed member types

For several HTML forms, I want to configure inputs and deal with their values. My types have the following structure (you may copy it to TypeScript Playground http://www.typescriptlang.org/play to see it in action): interface InputConfig { readonly i

Declare a type in TypeScript that denotes the empty set

I know a little about TypeScript which I've learned this month in a university course. Can this denote the empty set? type emptySet=0&1; because when I try to assign this to any value, i.e. (boolean, number, string) I get type error. I'm not sure wha

Search with removable entries / tags (Ionic 2)

I am creating a recipe app where I have a search and the user can search by the ingredient. I want the functionality to be when they touch the spacebar to type the next input for it to appear as a label below with a X next to it, therefore deselectin

Manage the network connection

I have an Ionic 2 app, and I need to know if there is internet connection (in general, any type) and it's not working. If I do: if (Network.connection) { this.af.auth.subscribe(user => { if (user) { this.hasSession = true; } else { this.hasSession =

Load the data before initializing the component - angular 2

My App.component which calls a init method in my user service. ngOnInit(){ this.init(true).then(data => { console.log("OnInit Called") }) } User.service returns a promise which in turn calls the account.init init = (isRegistered) => { retu

Angular 2 trying to implement observables in services

Im trying to send data from one component to other using observable. Here I'm implementing observable in service like this... import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/RX' @Injectable() export class SelectedItemServ

Could not find module error '@ angular / core'

I am working on a basic Angular2 sample using NodeJS , and the editor i am using is atom. I have npm installed angular2(2.0.0-beta.17) and typescript npm install angular2 npm install -g typescript In my main.ts am importing import { Component } from

How to add SockJS in the Angular 2 project?

I use angular-cli to generate a new project. Now I want to add socketJs to the project, but keep getting errors in browser console: GET http://localhost:4200/url-parse 404 (Not Found) GET http://localhost:4200/inherits 404 (Not Found) Unhandled Promi

Skip entries to the nested component in Angular 2

How can the attributes be transparently translated from wrapper component to nested component? Considering that there is const FIRST_PARTY_OWN_INPUTS = [...]; const FIRST_PARTY_PASSTHROUGH_INPUTS = ['all', 'attrs', 'are', 'passed']; @Component({ sele

TypeScript inheritance and circular dependencies in SystemJS

I'm using TypeScript with --module system (SystemJS) in a very large project. SystemJS supports cyclic dependencies, and most of the time it works fine. However, when TypeScript inheritance gets involved, things begin to break. For example, if a clas

Add to a painting by Parsing Json

Trying to retrieve the Json string from localStorage and append a new dish to it. It is not working as it should, can someone please help me. Am using TypeScript. interface Dish { id: number; name: string; desc: string; price: number; }; export class

Typescript `enum` of the JSON string

Is there any way to have a TypeScript enum compatible with strings from JSON? For example: enum Type { NEW, OLD } interface Thing { type: Type } let thing:Thing = JSON.parse('{"type": "NEW"}'); alert(thing.type == Type.NEW); // false I

how to define require function in typescript

this is my ts code: import AddToCartBtn from "./AddToCartBtn"; import * as React from "react"; import * as ReactDOM from "react-dom"; declare var document:Document; var _handler : __React.MouseEventHandler; ReactDOM.render(&l

Scripting compilation causing dependency errors

I am compiling multiple TypeScript files into a single JavaScript file. Say for example they are called: A.ts // depends on C.ts B.ts // depends on C.ts C.ts When I checked the JavaScript output, I found a problem: TypeScript's __extends function fai

Typescript with polymer

I know that there have been other questions on this topic but none of the answers have been particularly helpful and some are out of date so I thought I would ask again. Has anyone had any luck with getting Polymer and Typescript to play nice? It see

Reference to the static class in Typescript

I have the following situation. I want to be able to define a static method on a base class (register) which uses references to other static properties, which should be overridden. For example: class Base { constructor() { } public static name = "Ove

View js output files of type text in VS 2012

I've installed TypeScript and Web Essential for Visual Studio 2012. In a new TypeScript Project were created 3 files: default.html app.css app.ts In all tutorials, VS 2012 automatically create dropdown for app.ts file in explorer, where is hidden app

Can not Compile TypeScript Files in Visual Studio 2012

I downloaded and installed TypeScript extension for VS 2012, I got my first sample compiles by manually dragging the ts file onto the tsc.exe file! because no other way to compile the file will work. I don't want to manually do this everytime I want

How to create an enum type in TypeScript?

I'm working on a definitions file for the Google maps API for TypeScript. And I need to define an enum like type eg. google.maps.Animation which contains two properties: BOUNCE and DROP. How should this be done in TypeScript?TypeScript 0.9+ has a spe