FAQ Database Discussion Community


ng-click not calling to type Script function

angularjs,typescript
I am trying to implement my angular js code with Type script but my ng click is not working. It's my controller code:- module CustomerSearch.controllers { export class CustomerCtrl { static $inject = ['$scope', '$http', '$templateCache']; constructor(protected $scope: ICustomerScope, protected $http: ng.IHttpService, protected $templateCache: ng.ITemplateCacheService) { $scope.search = this.search; }...

8K command line restriction when publish typescript from VisualStudio

typescript,tsc
I have a typescript project in Visual Studio that compiles and runs well from the IDE. When I try to publish it in Azure, VS launches tsc and puts all files to compile in one command line. I have about 130 .ts files. Having average file length about 85 (full...

ng-switch in Angular2

typescript,angular2,ng-switch
I am playing around with angular 2 (currently with version alpha 26). ng-for and ng-if for example are working fine. I do however have problems with ng-switch. I just can't get it to work, i.e. nothing is printed. It seems as if the whole template is ignored. This is the...

TypeScript 1.5 doesn't produce output

typescript
Using typescript 1.5 beta. I have the following problem: if there are errors (from typescript point of view) in .ts files, the output .js files aren't produced and previous output (if any) is erased. Is it a 1.5 beta limitation or didn't I understand the right way the phrase from...

How to declare knockout component in typescript?

javascript,knockout.js,typescript
I am trying to follow example to create a component in knockout. http://knockoutjs.com/documentation/component-overview.html But I have to write a code in typescript. So how can I register component in knockout using typescript? What should I write in .ts file to convert it in something-like below. ko.components.register('like-widget', { viewModel: function(params) {...

How to do dynamic objects in TypeScript

typescript
Is there any way to define a dynamic object type in TypeScript? In the following example, I would like to define a type for "My Complex Type" by saying: Objects of type "My Complex Type" are objects having "any number of properties" but the values of those properties must be...

Implement function without name in Typescript

typescript,typescript1.5
I'm trying to implement a function without name like this: interface I { (name: string): void; } class C implements I { (name: string):void { } } I want to use C like this, but it doesn't work: C("test"); I can write it in javascript and use the interface declaration:...

How are the definitions files loaded in typescript

typescript
in the past, d.ts files in typescript were only loaded when specifically required with a ///<reference path="... statement. However, it's my understanding that this has changed recently and the compiler is now able to automatically load some local definition files. I have tried to find the rules for this by...

How to angularjs app.service and $q in typescript

angularjs,typescript,angular-material
I am Very new to typescript and angular Js . I have am not able to find correct answer , my code is given below: export class SidenavController { static $inject = ['$scope', '$mdSidenav']; constructor(private $scope: any,private $mdSidenav: any) { } toggleSidenav(name: string) { this.$mdSidenav(name).toggle(); } loadHelpInfo() { this.helpService.loadAll() .then(function(help)...

Typescript union type not working

types,typescript,typescript1.4
I have the following classes: export interface ISimpleUser { id: number; full_name: string; } export interface IMember extends ng.resource.IResource<IMember> { id: number; project: number; user: number|ISimpleUser; skills: ISkill[]; about: string; accepted: Boolean; updated: Date; created: Date; } At some point I want to iterate over an arroy of members like...

Mocking Angular $window in unit test cases

javascript,angularjs,unit-testing,typescript,jasmine
I have been trying to unit test my angular custom service written in Typescript. The service reads a global variable defined on the Window object. I have made it promise, so that in future I can make a AJAX call to get this information. Here is my stripped down service:...

tsc --out weird behavior when using 'import' in my files

typescript,tsc
I have two typescript files, app.ts, and `angular2.d.ts' (which contains type definitions for angular2) my tsconfig.json file looks like so: { "compilerOptions": { "module": "commonjs", "out": "public/all.js", "sourceMap": true, "watch": true, "target": "ES5" }, "files": [ "typings/angular2/angular2.d.ts", "src/app.ts" ]} Expected result - public/all.js would contain the compiled ts file. Actual...

Update Knockout Observable string in refresh function

javascript,knockout.js,typescript
The code is in typescript and I am trying to show current date time on page load and update that date time on refresh click. In .ts file string that shows date time is declared like this. asOfString: KnockoutObservable<string>; In the constructor it is being set like this, this.asOfString =...

Center of chart(pieChart)

javascript,css,charts,highcharts,typescript
I want to set title of pieChart in the middle of circle like this http://jsfiddle.net/NVX3S/1036/ . title: { text: 'aSD<br>500 ASD.', align: 'center', verticalAlign: 'middle', } But: title.align is the option of the svg container, not the chart align! (Imagine what will happen if left of chart will be legend...

How to implement a parameter decorator in TypeScript?

annotations,typescript,decorator
I've been trying to use a parameter decorator @logParameter: class Person { public name: string; public surname: string; constructor(name : string, surname : string) { this.name = name; this.surname = surname; } public saySomethingAsync(something: string, @logParameter cb: (said : string) => void) { cb(this.name + " " + this.surname +...

Deleting namespace in Socket IO

node.js,namespaces,socket.io,typescript
This question has been asked before here, but I've implemented the answer and the problem has persisted. I'm working in typescript and I have a Room class that encapsulates a namespace (among other things), and a RoomManager class that maintains a list of rooms. I recently added functionality where a...

TypeScript does not detect union type with an && operator

typescript
In the below example x is actually a union type of 'boolean | string' but TypeScript considers it a string. Is this a bug or am I missing something? var x:string = false && "foo"; ...

Firebug does not display my JavaScript files

typescript,firebug
I am building a web application with AngularJS en typescript in VS2012. These TypeScript files are all compiled into JavaScript files and send to the client using Bundles (all options turned off, thus I'm sending all files individually). In Firebug HTML view I can see all my JavaScript files, but...

Typescript js.map files loaded by the browser using a wrong path

javascript,typescript
I don't understand why my browser is trying to load my js.map files using a wrong path. Here is what I have in my <head> HTML part: Here is what it tries to load: What's wrong is that it tries to load the file inside the folder assets, which doesn't...

How to Add AngularJS 1.4 in Visual Studio 2015 RC Cordova TypeScript Project

angularjs,cordova,typescript,visual-studio-2015,visual-studio-cordova
I have a Visual Studio 2015 RC and create a TypeScript Cordova project. I want to use AngularJS in this project, but after search for a long time, there's no such step by step guide telling me how to apply AngularJS 1.4 in VS2015RC TypeScript Cordova project. Could someone share...

How to pass an arugment to a typescript module?

typescript
Is it possible to pass a variable to typescript modules ? when using a class, we can pass arguments to the constructor : class validator { constructor(public regex: RegExp) { } ok = (s: string) => this.regex.test(s); } But, How to pass the same argument to a module ? module...

JavaScript map(), undefined property of object from the collection

javascript,typescript
I have a collection of filter objects which is this.selectedFilters. I use the JS map method to select only the field property of the filter object. console.log(this.selectedFilters.map((val) => { console.log(val); console.log(val.field); console.log(val['field']); return val.field; })); The result is: Can somebody tell me why does val.field gives an undefined value? :(...

is it possible to use TypeScript and Babel together

javascript,typescript,babeljs
I am new to both TypeScript and Babel. I have researched both and found they have features the other does not have. I'd like get the best of both world by using TypeScript to organize my code then use babels ES6 features like asyc/await and others. Is this possible.

Cross Domain Request with TypeScript and Angular $http Service

javascript,angularjs,typescript
I am new to TypeScript and I am trying to set up cross domain requests with the $http service. In the past with JavaScript I was able to something like this: $httpProvider.defaults.useXDomain = true; $httpProvider.defaults.withCredentials = true; When I look at the IRequestConfig options of the DefinitivelyTyped class required to...

Injecting/Acquiring internal modules in PlatypusTS

angularjs,typescript
Using angular, I can retrieve object instances or load modules using the $injector like so: export class BaseService { protected $http: angular.IHttpService; protected _injector: angular.auto.IInjectorService = angular.injector(['ng']).get('$injector'); constructor() { this.$http = this._injector.get('$http'); } ... ... } I am attempting to do the same thing in the PlatypusTS framework to import...

Uncaught ReferenceError: angular is not defined using type script

angularjs,angularjs-scope,typescript,typescript1.4,typescript1.5
I am working with Type Script and Angular js I have implemented a Controller which names as quick search and from that i am trying to perform search opeartions .I which i am getting the search term in a text box from my aspx and than on ng click it...

How to generate correct ordering of files with typescript?

typescript
Consider two typescript files: File a.ts: module SomeModule { export class AClass { } } File b.ts: module SomeModule { export var aValue = new AClass(); } If you compile them using tsc -out out.js b.ts a.ts, it compiles without error and out.js has the contents: var SomeModule; (function (SomeModule)...

`this` in callback points to wrong object

typescript
I have this viewModel: import app = require("durandal/app"); import appViewModel = require("appViewModel"); import dataService = require("dataService"); class Home{ section = ko.observable<string>(); activeScreen = ko.observable<string>("nativeLanguage/selectNativeLanguage"); constructor() { app.on('home:activateView').then(this.activateView); } activateView(view) { this.activeScreen(view); } activate() { return this.getSection(); } getSection() { return dataService.getSection('HOME_PAGE').then((data) => {...

how to do something when data from service is ready in angular?

angularjs,typescript
I create service like this : export class MDCurrencyService implements IMDCurrencyService { httpService: ng.IHttpService; handlerUrl: string; constructor($http: ng.IHttpService) { this.httpService = $http; this.handlerUrl = '/Master/'; } get(): MDCurrency[]{ var result: MDCurrency[] = []; var resp: ng.IPromise<any> = this.httpService.get(this.handlerUrl +'GetAllCurrency') .then((response: any): ng.IPromise<any> => this.handlerResponded(response, null)); resp.then((data) => { if (data.is_success)...

Why Chrome shows \ufeff symbol and gray lines in TypeScript?

javascript,visual-studio,google-chrome,typescript,google-chrome-devtools
When I open my TypeScript in Chrome debugger I see strange red dot at the first line. I believe it corresponds to unrendered symbol \ufeff (as popover says). There is no such symbol in the TS file when I open it in editor (e. g., Notepad++ with "show all...

Cannot find external module 'angular2/angular2' - Angular2 w/ Typescript

angularjs,typescript,angular2
I am going through the step by step tutorial on angular.io (Angular 2). I am using typescript. I get the following error when trying to compile: Cannot find external module 'angular2/angular2' using the watch command. main.ts import {Component, View, bootstrap} from 'angular2/angular2'; @Component({ selector: 'my-app' }) @View({ template: '<h1>My first...

How can this be undefined in the constructor of an Angular config class?

angularjs,constructor,typescript,undefined,this
I've found some examples online, where people create TypeScript config classes and pass them on to Angular. When I've tried it, I got the weird exception, that this was undefined. A closer look to the other implementations revealed, they only use the constructor, so, are those examples actually inherently wrong...

Looping through an enum, TypeScript and JQuery

jquery,enums,typescript,ienumerable,enumeration
Hello im trying t develop a straight forward todo app using TypeScript and JQuery. I have an enum that lists task types: export enum TaskType { FrontEnd, BackEnd, Designer }; However looping through the emum using jquery.each or for loop, i get the following result, (values then indexes): FrontEnd, BackEnd,...

Sublime 3 JS Snippets to Typescript

javascript,typescript,sublimetext3,code-snippets
I have a lot of useful snippets on JS. Like cl for console.log(); or fn for function methodName (arguments) { // body... } However I can't use them on *.ts files. How can manage the snippets and complation for js to ts also. Thanks...

How do I make an Angular service using typescript?

angularjs,typescript
I have a service code using typescript and AngularJS like this : /// <reference path='../_all.ts' /> module bankApp { 'use strict'; export class MDCurrencyService implements IMDCurrencyService { httpService: ng.IHttpService; promise: ng.IPromise<void>; constructor($http: ng.IHttpService, $q : ng.IQService) { this.httpService = $http; } get(): MDCurrency[] { var promise = this.httpService.get('/Master/CurrencyGetAll').then(function (res) {...

What is the use case for supporting “both types of index” (numeric and string) in TypeScript?

javascript,typescript
I'v start using typescript and came into the following statement(taken from Interfaces#array-types): It is possible to support both types of index, with the restriction that the type returned from the numeric index must be a subtype of the type returned from the string index. I can think of few ways...

Compiling TypeScript with filter() thisArg

javascript,node.js,typescript
I'm working on an application in Node, written in TypeScript, and I'd like to use filter() to filter an array of objects based on an attribute. I have a public method (getValidObjects()) that accepts an object (preferred) that has properties I'd like to match against. In my current setup, I'm...

When Using Typescript+angularjs the api result is not displaying in html

angularjs,typescript
Below are my controller and html: When my make api call in controller i am storing the result in result variable, Now,that result variable when i am trying to print in html it is not printing anything, i have used one more variable name in controller that is printing in...

Using TypeScript type definitions with Webstorm 10 [duplicate]

node.js,typescript,webstorm
This question already has an answer here: intellisense and code complete for DefinitelyTyped (TypeScript type definitions) on WebStorm IDE 2 answers I am trying to use Webstorm 10's new built-in TypeScript compiler. When compiling a simple Node.js file such as below, it gives a TS compilation error of "Error:(1,...

Method Put not Allowed in IIS 7.5 using Type Script + Angular Js + Web API Status 405

angularjs,http,typescript,iis-7.5,typescript1.4
I have implemented a code using Type Script and Angular Js and used http.put and passing some data to my web API than get the response from my Web API and fill it into the grid. But now the problem is i am getting error of 405 Method Not Allowed...

Namespace keyword in TypeScript

c#,namespaces,typescript,keyword
Trying to find out what does namespace keyword mean in TypeScript? Here's some reshuffle they've done recently to use namespace instead of module: https://github.com/Microsoft/TypeScript/commit/224e7630ea17c4547e97f85634f446b877955a67 In the absence of namespace spec, it looks like a rather pointless rename to make the language look C#-like. Or is there an obscure little difference...

Use TypeScript lib.core.d.ts instead of lib.d.ts

javascript,node.js,typescript,typescript1.4
It seems the TypeScript compiler always includes lib.d.ts or lib.es6.d.ts (depending on the compiler target). In our application we have a WebSocket class that is already defined in lib.d.ts. We're running our application under Node.js and not in a web browser, so we actually don't need all of the definitions...

Fill Grid Using Type Script Controller

angularjs,typescript,typescript1.4,typescript1.5
I have implemented a controller using typescript and angular js and getting data in response as well but there is some problem when i am trying to bind that data with my grid.I have used ng-repeater for it. I have declared my controller on html page as :- ng-controller="CustomerCtrl as...

Why doesn't this code cause a TypeScript type error?

angularjs,typescript,typescript1.5
With interfaces defined like so: interface IRemoteService { createRecord(record: RecordType): ng.IPromise<ICreateResponse<string>>; } interface ICreateResponse<T> { createdId: T; } Why doesn't the following code cause a Typescript compilation error? class RemoteServiceMock implements IRemoteService { public static $inject = ["$q"]; constructor(private $q: ng.IQService){ } createRecord(record: RecordType): ng.IPromise<ICreateResponse<string>> { return this.$q.when({}); } }...

AngularJS how to use $q in Typescript

javascript,angularjs,typescript,q
I am new at AngularJs and very new at Typescript. I included Typescript in my AngularJs project but couldn't handle a service where i return a $q(function(){...}) my code looks like: function foo(request, monitor, currentMonitorPropertys) { var currentChart; return $q(function (resolve) { $http(request).success(function (chartResponse) { ... resolve(monitor); }).error(function(response){ ... });...

Angular 2/Typescript: require not found

typescript,gulp,angular2
I am trying to get the angular 2 example running with a gulp typescript compiler. The gulp-script compiles import {Component, View, bootstrap} from 'angular2/angular2'; to var angular2_1 = require("angular2/angular2") which does not run in the browser. What is wrong with this? As far as I know, this kind of implementation...

Why is public property not visible after importing it?

typescript
I have this typescript file: /// <reference path="../scripts/typings/requirejs/require.d.ts" /> /// <reference path="../scripts/typings/knockout/knockout.d.ts" /> /// <reference path="../scripts/typings/durandal/durandal.d.ts" /> import app = require("durandal/app"); class AppViewModel { currentCourseId = ko.observable(); currentNativeLanguageId = ko.observable(); currentLanguageId = ko.observable(); currentLevelId = ko.observable(); currentLessonId = ko.observable(); setMessage(message) { app.trigger('message:new',...

How to format the values of a model in Marionette Backbone View before rendering?

view,formatting,typescript,rendering,marionette
If you implement the onBeforeRender method the is no way to access the model values in order to format them temporarily Ideally you would want to format the values just before rendering without changing the model values of course! How to do it?...

Using Angular 2 with older browsers thanks to TypeScript?

javascript,internet-explorer-8,internet-explorer-7,typescript,angular2
Since the Angular 2 team is using Typescript for it's build, would it be a feasible assumption that they could compile a version of Angular 2 that would work on older browsers? Thoughts?

View is not a constructor for Backbone under Typescript

javascript,backbone.js,typescript
I am trying to create a Backbone.js view in Typescript. I get the following error: TypeError: ExampleView is not a constructor in http://localhost:57258/Tests/spec/ExampleViewTest.js (line 17) My view is instantiated like this: var view = new ExampleView(); The view is declared like this: ///<reference path="../Scripts/typings/backbone/backbone.d.ts"/> class ExampleView extends Backbone.View { constructor(options?:...

Exception with type definition for random-string module

node.js,module,typescript
I am trying to write a .d.ts for random-string. I have this code: declare module "random-string" { export function randomString(opts?: Object): string; } I am able to import the module no problem then with: import randomString = require('random-string'); and invoke: console.log(randomString); // --> [Function: randomString] However, this doesn't work with...

How to implement custom sort for koGrid?

javascript,sorting,knockout.js,typescript,kogrid
Data: 16.00 hours 19.99 hours 210.46 hours 262.54 hours 303.19 hours 55.95 hours 60.07 hours 64.07 hours 7.95 hours What I want: I need to allow sorting for this king of data in koGrid (default feature by clicking grid header, asc or desc sort). Problem: The data is string so...

Module '“angular2/angular2”' has no exported member 'For'

angularjs,typescript,angular2,typescript1.5
hi I am following the tutorial on the official Angular2 website. https://angular.io/docs/js/latest/guide/displaying-data.html Here is my ts file /// <reference path="typings/angular2/angular2.d.ts" /> import {Component, View, bootstrap, For} from 'angular2/angular2'; @Component({ selector: 'display' }) @View({ template: '<p>name: {{myName}}</p>' + '<p>Friends:</p>' + '<ul>'+ '<li *for="#name of names">'+ '{{name}}'+ '<li>'+ '<ul>', directives: [For] })...

What is the type of an object literal key as defined in TypeScript?

javascript,enums,typescript,webstorm,object-literal
I'm not using TypeScript as the primary language for this application, but as the type-hinting assist for JetBrains' WebStorm alongside JSDocs. I'm also using the keyMirror utility to create quasi-enum object literals. Given the following: //enums.js var keyMirror = require('keyMirror'); module.exports = { CRUDVerbs: keyMirror({ //keymirror mirrors the key to...

How do I access the service provider when registering using typescript class

angularjs,configuration,typescript,service-provider,typescript1.5
The following service provider registers successfully. Other controllers can use the service without trouble. My question is how to access the provider in order to configure it before the service is instantiated by the $injector service? module apiService{ export interface IBaseService{ leagueID: number; } export interface IApiBaseServiceProvider extends ng.IServiceProvider{ setLeagueID(leagueID:...

RequireJS and TypeScript Class - Cannot call function externally

javascript,requirejs,typescript
I am having a tough figuring out how to mix RequireJs and TypeScript. I am compiling TypeScript with the AMD option. The problem is, the function declared within an exported class is classified as "prototype". Is this normal? ModalHelper.ts: export class ModalHelper { saySomething = (something: String) => { alert(something);...

d.ts declaration for R.js framework

typescript,typescript1.5
I need help to create the declaration file of https://github.com/keithamus/R.js I don't know how to solve R('item') problem. I need the .d.ts file to be an external commonjs module to be able to use like this: import R = require("/i18n/R"); R('item'); // my problem R.setLocale("en"); ...

Create type with two possible variants in Typescript

typescript
Is there a way in Typescript to declare a variable which can be Int16Array or Uint16Array and nothing more?

Visual Studio 2015 RC + RequireJS + jQuery

jquery,requirejs,typescript,visual-studio-cordova
I'm using Visual Studio 2015RC + Cordova CLI 5.1.1 + TypeScript + RequireJS + jQuery . I'd like to change the location of my jquery.js file from the scripts folder to scripts/lib. I added a requirejs.config and changed the jQuery location. requirejs.config({ baseUrl: 'scripts/lib', paths: { jquery: 'jquery' } });...

Typescript - is there a way to specify a global reference?

javascript,node.js,typescript
I'm developing a node.js script using typescript and in order to tsc not to complain about non-browser-js code like require or module.exports, I have to include /// <reference path="lib/node.d.ts" /> in every file. To make things worse, the location to that file needs to be relative to the code file,...

Angular directive dependency injection - TypeScript

angularjs,typescript
There seem to be a number of ways to create Angular directives in TypeScript. The neatest I've seen is to use a static factory function: module app { export class myDirective implements ng.IDirective { restrict: string = "E"; replace: boolean = true; templateUrl: string = "my-directive.html"; link: ng.IDirectiveLinkFn = (scope:...

Node.d.ts issues errors using typescript compiler, how do I fix?

node.js,visual-studio,typescript,jasmine,protractor
I have a project that's a NODE console application project using Visual Studio 2013. When I compile the solution I'm getting typescript errors as follows: Typescript wants a semicolon after export interface ReadableStream extends EventEmitter { readable: boolean; read(size?: number): string|Buffer; //Like this ----> read(size?: number): string;|Buffer; Which means I...

TypeScript: Lambdas and using 'this'

lambda,typescript,this
JavaScript frameworks often call callbacks using apply(). TypeScript's arrow notation, however, doesn't seem to allow me to access the 'this' pointer. How's it done? If it isn't, is there a place to down-vote the current 'this' handling on Lambdas?...

TypeScript project organization, compile into a single JS file?

javascript,oop,typescript
Recently I started working with TypeScript, using WebStorm IDE. Coming from a strong AS3 background I found TS a really good way to write JS, most of the concepts feel really familiar and convenient, but, when it comes to splitting classes,modules into separate files things starting to get really confusing....

How to expose TypeScript modules in NodeJS?

javascript,node.js,typescript
I have a library that I'm building in TypeScript. I'd like to include this library in both TypeScript and JavaScript Node projects. What is the general strategy to do this? Should I compile and have two versions or is there some other strategy I should be using?

What is the correct tasks.json config for compiling typescript in Visual Studio Code?

typescript,vscode
Using Ctrl+Shift+B I added a default tasks.json file and uncommented the second task runner block. I have a typescript file in the root of the directory and a tsconfig.json. Everytime I compile I get 'error TS5023: Unknown compiler option 'p'. What is the correct definition to allow me to compile...

Pros & Cons of using requirejs (-m amd) for typescript+angular projects

javascript,angularjs,typescript,require,amd
For an angular 1.x project that uses typescript, what are the Pros and Cons of using AMD? Meaning, running tsc with the params -m amd and using requirejs, versus simply using the /// <reference path="..." /> for internal modules as well and wrapping in module(s). Which- Makes more sense for...

Auto-Build TypeScript Project in Visual Studios Code 2015

visual-studio,visual-studio-2013,typescript
I am just starting out in Type Script, and am using the new Visual Studios Code IDE. I am currently facing an issue where I can either use the visual studios type script plug-in, and run the javascript files using node. However it won't build the js file automatically when...

Angularjs+Typescript directive implementing $compile

angularjs,angularjs-directive,typescript
I am having issues injecting $compile in the following directive. export class Element { public link(scope:dirScopeInterface, element:any, attrs:ng.IAttributes, formCtrl:ng.IFormController) { var attr = this.arrayJoiner(scope.standard, scope.attrs || {}, scope.ignore || {}); element.html(this.compiler(attr)); $compile(element.contents())(scope); } } At the moment it is throwing an $compile is undefined error. I have tried using static...

Import external module ts1.5

typescript
Does anybody know how to import an external module using Ts1.5 ? The documentation is not really clear about that and it seem that : import { Reflector } from '../node_modules/reflect-metadata/Reflect'; Doesn't work. (Reflect-metadata exposes Reflector.ts and a d.ts file) I dont know how to process to import external module,...

C# Rest API returns string with double quotes

angularjs,rest,typescript,umbraco7
I have this silly problem, which I hope someone could help me enlighten. I am building an extension for Umbraco7's backoffice, for that I need to receive a simple string. My problem is the string return from the REST api contain double quotes and then AngularJS wont model bind. Here's...

TypeScript: workaround for relative reference path?

module,typescript,tsd
My goal is to refer to .d.ts files that I've installed with tsd. The tsd definitions GitHub repository has examples using paths relative to the source file's location: /// <reference path="../typings/tsd.d.ts" /> I find that a potential maintenance issue - if I want to reorganize how my project is organized,...

TypeScript export imported interface

typescript
I use AMD modules and I want to hide a complex interface behind one file that loads several other files and chooses what to expose and how. It works, I use this solution but it feels kinda ugly, mostly with the interfaces. import Types = require('./message-types'); import MessageBaseImport = require('./message-base');...

Unable to concat typescript modules (.ts) files into single output(.js) using --out Comment: Getting Error

javascript,typescript,typescript1.5
I am new to Typescript. I've been trying to concatenate typescript modules by using the tsc --out command. But I'm getting some error. There is no information about the error. Below is the process, I've tired. .ts files I have: Validation.ts: module Validation { export interface StringValidator { isAcceptable(s: string):...

How to load System.js modules with TypeScript?

javascript,typescript,aurelia,systemjs
I'm trying to get TypeScript working with the default Aurelia skeleton, which is based on System.JS as a loader. I'm having trouble getting TypeScript to accept module imports. I renamed one of the skeleton files, "nav-bar.js" to "nav-bar.ts" to see if I could convert the example into TypeScript. The code...

All TypeScript to Single js File - How to tell page which module to execute

asp.net,visual-studio,visual-studio-2013,typescript
I just started using the feature that allows you to compile all TypeScript to a single .js file. The problem I ran into, as you'd expect, is that the entire .js file is executed, and not just the module(s) that I need my page to execute. Are there any built...

Use translateProvider.useLoader with Typescript

typescript,angular-translate
I am new to AngularJs and Typescript. I am trying to implement I18n. My resource bundles are lying in a remote server. I use $translateProvider.useLoader('TranlationFilesLoader',{}) where TranlationFilesLoader is a custom loader class. TranlationFilesLoader class looks as follows: export class TranlationFilesLoader { public static $inject = ['$http', '$q' ]; constructor( $http:...

How to pass optional parameters in TypeScript while omitting some other optional parameters?

typescript
Given the following signature: export interface INotificationService { error(message: string, title?: string, autoHideAfter? : number); } How can I call the function error() not specifying the title parameter, but setting autoHideAfter to say 1000?...

Mismatched anonymous define() in Chrome extension content script

google-chrome-extension,requirejs,typescript
I'm trying to build a Chrome extension with TypeScript. The setup is quite simple: In manifest.json { "permissions": [ "webRequest", "webRequestBlocking", "tabs", "storage", "http://*/", "https://*/*" ], "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], "js": [ "scripts/require.js", "scripts/require-cs.js", "scripts/main.js", "scripts/contentscript.js" ], "run_at": "document_end", "all_frames": true }], } In model.ts: export...

Typescript client side socket not connecting with server

node.js,sockets,typescript
I am attempting to recreate this tutorial using typescript, routing, and jade. My code compiles and runs as expected, the jade file is served correctly, but there doesn't seem to be a connection between the client side socket and server side socket. For reference, the code from the tutorial is...

“Variable 'X' can be made constant”, what does 'constant' mean?

typescript,resharper,ecmascript-6
VStudio or ReSharper is giving me the suggestion below: What does constant mean in this scenario? If it's a constant in the current method scope, what's the purpose? Methods tend to be small and therefore it shouldn't give any advantage compared to be a regular var? Please enligten me...

Typescript file exporting interfaces comes up 404 using JSPM

typescript,typescript1.5,jspm,systemjs
I'm using Typescript 1.5. I started using jspm. I have a few files that just consist of interface exports. In my tsconfig the module is set to 'system'. It seems to not like files that are just exporting interfaces. It's giving me 404 errors, looking for them in the dist/app...

Typescript definition for existing jQuery plugin with nested function

typescript
I am converting a large JS file that has a lot of jQuery plugins to use TypeScript so I need to also create the necessary TS definition files. I have run into a plugin that I can't figure out the definition file for. Example of the plugin: (function ($) {...

How to stop visual studio generate typescript js and js.map files while publishing

visual-studio-2013,configuration,typescript,publishing
I set up my project that combine javascript output into file to $(ProjectDir)dist\output.js and uncheck generate source maps. Tools -> Options -> Text Editor -> Typescript -> Project -> Automatically compile Typescript files which are not part of a project is unchecked as well. While building and running project from...

TypeScript + JavaScript: Is not a function at x?

javascript,angularjs,typescript
I am new to TypeScript and I'm running into a bug within my AngularJS + TypeScript/JavaScript app. I have a service that looks a little like this: module myApp { 'use strict'; export interface IActionItem { name: String; link?: String; icon: String; action?: any; className: String; order: Number; } export...

Setting dynamic properties with key from a private collection in TypeScript

typescript
Running this in the http://www.typescriptlang.org/Playground ... interface TestObj { name:String; } class Test { test; private myCollection:TestObj[] = []; private anyCollection:any[] = []; constructor() { var obj:any = {}; var refObj = {name:'prop'}; obj[refObj.name] = "This works!"; var collection:any[] = []; collection.push(refObj); this.test[collection[0].name] = "This works!"; this.myCollection.push(refObj); obj[this.anyCollection[0].name] = "This...

How to type JSON results

typescript
I would like to convert this js to ts: class foo{ getSection() { return dataService.getSection('HOME_PAGE').then(data => { this.section(data.results[0]); //Error Here }); } } The compile time error message is: Property 'results' does not exist on type 'void'. data is a JSON result set, and results[0] is simple the first record....

Getting Error of Angular is not defined & Uncaught Error:No Module in type Script Angular Js

angularjs,typescript
I have implemented a code where i stuck with this problem. Problem 1:- Uncaught ReferenceError: angular is not defined Problem 2:-Uncaught Error: No module: CustomerSearch I have written my code:- and here is my view page <view> <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QuickSearch.ascx.cs" Inherits="CustomerSearch.QuickSearch1" %> <!DOCTYPE html> <%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement"...

Test if an object conforms to an interface in TypeScript

testing,typescript
If I have a plain-old JavaScript object and a TypeScript interface, how can I write a test that asserts object conforming to my interface? interface Person { name: string age?: number } describe('Person interface check', () => { it ('should conform to "Person" interface', () => { let obj1 =...

Angular with Typescript: HTTP Injector Factory vs. Service

angularjs,typescript,angular-http-interceptors
I have created a Typescript Class (see code...) that I want to use as an HTTP injector. It is being added to the Angular module as a service (not a factory). I have noticed a few issues. When the class defines the 'request' and 'response' functions with capital letters, the...

Getting Error in Angular js + Type Script in http put status 400 using DNN7

angularjs,angularjs-scope,typescript,dotnetnuke-7,typescript1.4
I have implememnted a controller using angular js and type script using dot net nuke 7.and trying to call my web api method using http.put but getting error in status as 400. Here is my controller code:- var customerapp = angular.module('CustomerSearch'); module CustomerSearch.controllers { export class CustomerCtrl { static $inject...

Extending an interface from a third party definition file

typescript,sequelize.js
I'm using this definition file in my Typescript code. The problem is that, according to Sequelize documentation to set the length of a string column, I should define its type as: Sequelize.STRING(20) and the current definition file doesn't allow this. It allows only Sequelize.STRING (which makes a default column length...

Typescript 1.5 - 'Duplicate identifier' errors

typescript,typescript1.5
I created a very simplistic project with Typescript 1.5.0 beta and included threejs/three typings with tsd. When compiling, tsc outputs 128 errors regarding Duplicate Identifier 'identifier'. I'm not sure if 128 is just where tsc starts truncating errors, so there could be more... I started the project by creating a...

How to compile TypeScript without using any references whatsoever

javascript,angularjs,typescript,tsd
Forgive me if I misunderstand, but I thought that if I used a tsconfig.json file at my project root, then I would no longer need to use any ///<reference path="..." /> tags in order to make my code compile. Am I wrong? For example, I'm using AngularJS. My App.ts file...

Trying to implement an object-oriented design model for a simple navbar using TypeScript

javascript,jquery,typescript
Greetings fellow Earthicans, The following code is used on my website: brianjenkins94.me in order to handle baseline navigation functionality and while it was working previously I decided to leverage the class-based approach provided by the TypeScript Language in order to structure my code in a more readable fashion. In doing...

How to update the view after changing the model in Angular2

javascript,typescript,angular2
How do I let angular2 propagate the changes i did to the model. In angularjs 1.x this would be really easy, but i cannot seem to get it working in angular2. I know the entire change detection system and view propagation is changed entirely. Somehow, i need to inform angular...

How to detect overflow HTML elements

javascript,jquery,html,css,typescript
I have created a navigation bar with div(s) within it. When i zoom-in, I hide the div's moving out of navigation bar through css [overflow:hidden]. My goal is to create a java-script variable which will tell me what all div's are out of navigation Bar( hidden because of overflow), as...

Writing an Angular directive with a TypeScript class

javascript,angularjs,typescript,angular-directive
I may just be attempting to combine too many "new-to-me" concepts at once, but I am trying to write a custom Angular directive using a TypeScript class. At the moment, I'm not trying to do anything terribly useful, just a POC. I have a TypeScript file that looks like this:...

Putting Lambdas in OR statement

typescript
Can someone explain why the second example does not work: var thisWorks = true || function () {}; var thisBreaks = true || () => {}; ...

Inject dependency to the angularjs directive using typescript

angularjs,angularjs-directive,typescript
Lets say I have a simple angular directive that looks like this: app.directive('setFocus', ['$timeout', function($timeout) { return { restrict: 'AC', link: function(_scope, _element) { $timeout(function() { _element[0].focus(); }, 0); } }; }]); How can I write this using Typescript and get the $timeout accesible within the link function? My example...