Import a module from the root path into TypeScript

Let's suppose I've a project, and its main source directory is: C:\product\src Based on this directory, every import path would be relative to it. I.e., suppose: // Current script: C:\product\src\com\name\product\blah.ts import { thing } from '/com/n

Various interfaces implementing Iterator & lt; T & gt;

I am trying to understand if this is possible... export interface ISomething { ... } export interface ISomethingElse implements Iterator<ISomething> { ... doSomeJob(): void; ... } The idea is that when i declare my class, ClassA i can do something l

Typography - including third-party code in published code

Having a simple Typescript project I'm using Gulp to build individual JS files from my TS files (I'm doing this as I have multiple HTML files which are to remain separate). var tsResult = gulp.src('./src/ts/**/*.ts') .pipe(ts(tsProject)); return merg

Inheritage and addiction injection

I have a set of angular2 components that should all get some service injected. My first thought was that it would be best to create a super class and inject the service there. Any of my components would then extend that superclass but this approach d

how to call a function in typewriting

I am trying to call function through my template click event but the error is "get is not a function". Can someone find where the issue is? My template: <button class="btn btn-primary" (click)="get()">sign-up</button

Creating a class instance based on ClassName: string

Before anyone marks this as duplicate please read below, My scenario doesn't just involve TypeScript but also Angular2. Objective I need a method in app.component.ts which takes a string(Class Name) and creates a instance of that. The classes exist i

Twinning classes with types

How do you include a class in a class in Typescript? I am trying to model the android APIs, to use in nativescript, so I need to declare a class ina class in a module, as shown below: export module myModule { export class MasterClass { static myVaria

TypeScript: static properties and succession

I'm quite new to TypeScript (1.8) and I have a small issue with inheritance and static properties. Please find below the test code I'm currently running: class A { public static Items = { FOO: 'A' }; public show() { alert(this.constructor.Items.FOO);

Angular 1.5.6, $ postLink and typescript

I am trying to use $postLink in my directive (using typescript and ng 1.5.6) Unfortunately, I really do not understand where to use this. Should it be a public function named "$postLink" within the body of the directive's class ? The following i

Packaging Observable methods

Can't seem to wrap my head around chaining / wrapping observables. I am using Angular2 rc1 with RxJs in Typescript in Visual Studio 2015. I have a servicemethod 'saveProduct' in the ProductService class: public saveProduct(product: Product): Observab

Ionic 2 - Disabling the back button for a specific view

So I'm messing around a bit with Ionic 2, and I want to know how to disable the back button for a specific view. What I'm doing is this.nav.push(SomePage); It works, but the NavController automatically puts a back button there for me. How do I disabl

Can not assign value to dictionary typist

I created a typescript dictionary. When I assign value to it, I am getting the following error. TypeError: Cannot set property 'v1/items/someItemType/someItemId/EVENT/some DataTypeId' of undefined at MainClass.subscribe (G:\Projects\src\main\MainClas

How to declare and import type interfaces in a separate file

I want to define several interfaces in their own file in my typescript-based project, from which I'll implement classes for production as well as mocks for testing. However, I can't figure out what the correct syntax is. I've found plenty of tutorial

TypeScript import syntax with multiple files

I'm trying to create a large angular app in TypeScript and I want my app layed out with the following folder structure: ./App --- Controllers --- --- HomeController.ts --- --- SomeOtherController.ts --- Directives --- --- MyDirective.ts --- app.ts I

array with interface as type (polymorphism with interfaces)

I'm trying to create an array of objects, where all objects implement the interface Foo. Here is a simplified example to demonstrate the problem: interface Foo { fooAction(): any; } class Bar implements Foo { public fooAction() { return "nothing impo

How to distinguish between a class and a function

Is there a way to distinguish between a class (not its instance!) and a function in TypeScript during runtime. Normally classes in typescript are transpiled to javascript functions and during runtime I could not find a nice way to check whether an id

TypeScript Constructor

i tried to create a class with two constructors and find out that TypeScript are not allowing that, but it allow overloading of constructor, well I tried it to and get an error : Build: Overload signature is not compatible with function implementatio