Questions tagged [typescript1.5]
Used for questions that relate to features or technical changes introduced in TypeScript 1.5
172
questions
1
vote
2
answers
507
views
how to override enum value based on the key in typescript
I have one based enum like BasedColor that I would like to use on other enum as AnotherState. If there is anyway to override the value with the same key. so I do not need to duplicate the key code . I ...
0
votes
2
answers
76
views
Display output and also showing type error in angular?
Actually it is printing the correct output in the UI. But in the console it is displaying a type error?...
How can I resolve this?
<tr>
<th scope="row">IP addrress</th>
&...
4
votes
1
answer
2k
views
How to use optional chaining operator with variable in typescript
I have following code and I would like to pass number from value key of variable object, How can I use variable for optional chaining operator for it to solve the error Element implicitly has an any ...
0
votes
2
answers
321
views
Typescript generic and extend
I am new to Typescript.
I have following 4 interfaces :
export interface MyAction<T = any> {
type: T
}
export interface MyAnyAction extends MyAction {
[extraProps: string]: any
}
export ...
0
votes
2
answers
803
views
Convert a type name to the actual type
Suppose we have the following enum
enum PrimayValType {
"string",
"boolean",
"integer",
"float"
}
Now i want to write a function that inputs a Buffer and a parameter of type PrimaryValType ...
2
votes
1
answer
5k
views
How to use dependency injection in typescript?
I have tried to add dependency injection in typescript code its working fine .but I need to load express application in dependency injection.
Dependencies.ts
import { injectable } from 'inversify';...
1
vote
2
answers
2k
views
How to pass values in constructor using sigleton() in typescript?
I have a doubt about how to pass the value in the constructor using a singleton class in typescript.
mycode .ts
import {singleton} from "tsyringe";
@singleton()
class Foo {
constructor(data:...
0
votes
0
answers
27
views
why is exception thrown when declaring a builtin Set class in TSUN editor?
I have installed TSUN on my centos 7 machine using the command. then i open the typescript interpreter using the command tsun from the terminal . when try to declare a set it is throwing the following ...
1
vote
1
answer
128
views
How to create an object with a vector of objects inside
I using angular 4 to create my website. But I need create a Object with a vecotor of objects inside. This don't work for me. My Code:
Object 1 (disciplinaStatus.module.ts)
export class ...
2
votes
2
answers
8k
views
How to extend the two classes in Typescript
I need to extend the two classes from the same namespace.
for ex:
declare namespace myNameSpace{
class class1{
///some methods will be here
}
class class3 extends class1{
//...
1
vote
0
answers
93
views
In Angular 4 or Angular 2 Typescript how To call in component of methods or variables in another component
suppose i want to call A component {} of variables or methods in B component in Angular 4 or Angular 2
-6
votes
1
answer
217
views
Angular 2 with TypeScript [closed]
I am a Angular 2 newbie. I am familiar with TypeScript and Angular 1.x.
Question 1:
I am looking for free learning resources that can teach me Angular 2 with TypeScript for beginners. Please give me ...
1
vote
1
answer
2k
views
what is the meaning of " = > " in typescript?
I saw many code snippets which has =>
symbol in typescript file. Could any one explain what is the exact meaning and why to use.
1
vote
0
answers
17
views
Getting error can not compile module unless --module flag is provided. so not able to create instance of this class in another ts file
export module FilterBar {
export class Filter {
objData: any;
distinctAreas: string[];
distinctRegions: string[];
distinctSubRegions: string[];
distinctAreasApplied: string[];
...
0
votes
1
answer
47
views
Fail to return a string from in a function from another function
I have this 3 functions that triggers POST api calls, and I want to return a succsess/failure message to whoever calls it (Observable<string>).
So the messages are similar and I didnt wan to ...
1
vote
1
answer
2k
views
TypeScript UMD both 'module' and 'define' are undefined
I transpile my TypeScript using "-m umd" because my project includes server, client and shared code. However, client side code doesn't work in browser. The browser doesn't even display any error and ...
-3
votes
1
answer
77
views
Inheritance in TypeScript
Is that possible inheritance features in Typescript and other features like overloading, overriding etc.
0
votes
4
answers
6k
views
Typescript string | string[] find the array length
I am finding the length of string|string[] , I have variable as a data type of var stepData : string | string[] .
Some times I am getting a single string value , also possible to get the list of ...
9
votes
1
answer
2k
views
Configure Visual Studio 2015 so Typescript Virtual Projects NEVER create 'loose files'
I've been trying to get typescript configured in Visual Studio for months.
I cannot find a definitive, reliable, and complete specification for how to get Typescript installed or configured in ...
2
votes
0
answers
125
views
Unable to see typescript template in Visual Studio 2015
When I click on Add new file in VS I didn't see typescript template in VS2015.
I have installed typescript also externally from Microsoft Link and restarted VS and even system. I can see Typescript ...
1
vote
0
answers
484
views
Implement Theme in Angular 2 App using external CSS
Trying to implement an Angular 2 App in which I am selecting a Theme from drop down list and as soon as I pick new theme- Theme of the whole app should change
I am thinking about storing theme name(...
3
votes
1
answer
75
views
what is proper method to create function with parameter and return value in single line?
I am new is ES6 and typescript. Trying to create function that accepts parameter as array and want to return its length as follows :
getSize = (friendsList : Friends[]) => friendsList.length ;
...
1
vote
1
answer
2k
views
How to do an observable function in Mobx?
I have store with a collection which I want to be read only. I wish to do something like but I don't know if Mobx provides a way to create a reactive function.
class Store{
private _col:Mobx.Map;
...
1
vote
1
answer
519
views
how to pass child id to parent object in Angular 2 using ngFor directive
how to pass child id to parent object in Angular 2 using ngFor directive.
I need to implement dynamic td's and tr's (using Angular 2 beta.17).
I have tried below code, but it is not working.
Error:
...
3
votes
1
answer
2k
views
Build: Failed to parse file 'C:/.../tsconfig.json/tsconfig.json': Invalid character. C:\..\VSTSC
Learning TypeScript and Visual Studio is complaining:
Build: Failed to parse file 'C:/.../tsconfig.json/tsconfig.json': Invalid character. C:..\VSTSC
Strangely, there is no tsconfig.json/...
11
votes
2
answers
2k
views
declare module vs declare namespace typescript
I am a little confused about the difference between declare module and declare namespace in typescript internal modules.
Another point which I am not clear: is it a good idea to have complex ...
1
vote
0
answers
358
views
How to work with external javascript libraries in Angular With TypeScript which donot have definitely typed files
I have been working on a project in angular with typescript where all are ts files , I have to use JqxWidgets which is an external javascript framework which doesn't have definitely typed files .. So ...
0
votes
2
answers
1k
views
How to use $rootScope define in one angular service in another service using typescript
I have declared a $rootScope in a service class (in contstructor) and assigning in a method using this.$rootScope and assigning property to it and when I want to use in another service again in that ...
-1
votes
1
answer
376
views
unable to access $rootscope property declared in one controller in other in angular using typescript
I have declared a rootscope custom property in a ts file like below
module MyApp.Entity{
export interface IRootScope extends ng.IRootScopeService {
userData: any;
clientData: ...
0
votes
1
answer
1k
views
Angular Toaster not working in typescript
I have downloaded angular-toaster.d.ts file from nuget and implemented a notification service no error but it is not working
export class notificationService {
constructor(private toaster: ...
0
votes
0
answers
721
views
Unable to use Toaster in Angular with TypeScript
I have been using angular with typescript but cannot use angular toaster along with typescript any idea??
export class notification {
constructor(private test: ngtoaster.IToasterService) {
...
7
votes
1
answer
7k
views
Call typescript decorator method when the underlying function is executed
As per how typescript design works ,if i write a decorator like,
class foo{
@fooDecorator
public fooMethod(){
}
}
it gives the transpiled javascript as
var __decorate = (this &&...
0
votes
0
answers
198
views
Unable to bind data to scope object after service call using $RESOURCE in typescript AngularJS
I am pulling data from api and trying to bind to variable , I have debugged code getting data from API but it is not getting binded to scope object here is my code
Service:
module application.common ...
0
votes
1
answer
201
views
I need to consume data from a SharePoint 2010 through the REST site
I need to consume data from a SharePoint 2010 through the REST site.
I am calling through a ajax + Jquery request.
My host is localhost and I'm trying to call a host of other domain.
I'm trying to ...
-1
votes
2
answers
527
views
Angularjs 1.x and Typescript and post value to server
I am trying to post header values to the server but values not embedded in request header thats why its give me wrong answer. I know, I am doing something wrong but I can't figure out it. Below is my ...
0
votes
2
answers
138
views
decorators communication in typescript
I am making a nodejs app using typescript, here is how my class looks like
@lib.decorators.routesRegister().version('v1')
export class mediaController extends lib.baseClasses.apiControllerAsyncBase()....
1
vote
0
answers
114
views
How can we use angular1.x.x filter in typescript?
I am working on small application using typescript and angularjs. I am trying to inject filter in typescript but i am not able to filter items. I want to search items on enter click. Writing filter in ...
1
vote
1
answer
325
views
Compilation of projects with different Typescript versions in Visual Studio 2015
VS2015-SP2. In one solution there are two typescript projects, one has version 1.5, the other 1.7. Which compiler will be used for the solution?
2
votes
1
answer
60
views
Implementation of interfaces typescript
interface A {
(obj? : any) : any;
func1() : void;
func2() :void;
}
How do I write a class B that would implement A? How would I implement the parametrized constructor?
2
votes
1
answer
2k
views
Karma/systemjs not looking in node_modules directory when trying to run tests
I'm trying to run tests using karma/jasmine/systemjs with Angular 2 and typescript. I previously had it working without systemjs/typescript using babel.
I also got it working transpiling typescript ...
0
votes
1
answer
1k
views
typescript: angular.d.ts defently typed with ng.IPromise
I'm getting this ts error while I'm trying to chain ng.IPromise function calls:
Error:(101, 23) TS2345: Argument of type 'IPromise<IResult[]>' is not assignable to parameter of type 'IResult[]'....
1
vote
1
answer
1k
views
Can you use TypeScript decorators to add properties to a method call?
Right now while using decorators the javascript seems to work (force compile and method is available), but the types are too strict.
As you can see here the following does not compile:
declare var _:...
28
votes
4
answers
66k
views
How to properly change a variable's type in TypeScript?
Thanks for your patience here, I'm just starting out with TypeScript.
I'm working on an angular 2 app that needs to accept text inputs and then make a bunch of calculations. I (incorrectly?) assumed ...
0
votes
2
answers
126
views
How to acess to my global properties in TypeScript?
I have a few functions in my .ts file, to have an access from a function to other functions and to global variables, I do: var self = this, and then self. - and a I have an access to all my fucntions ...
5
votes
2
answers
2k
views
Using tsconfig.json with Visual Studio 2013? (web project)
I'm using Angular 2 in my web project, and as such need TypeScript to suport experimental decorators such as @View. This can be done in tsconfig.json with "experimentalDecorators": true but I see no ...
48
votes
4
answers
44k
views
LINQ SingleOrDefault() equivalent
In Typescript, I use this pattern often:
class Vegetable {
constructor(public id: number, public name: string) {
}
}
var vegetable_array = new Array<Vegetable>();
vegetable_array.push(...
14
votes
1
answer
12k
views
How to change the result type of a Promise< > in TypeScript
For some Typescript methods I build, often I need the asynchronicity of a promise but I do not require the promise to return a value (conceptually speaking). A simple example might be calling an ...
1
vote
1
answer
336
views
Force derived to class to have constructor with predefined signature
Is it possible in typescript to force all derived classes to have a constructor with a predefined signature?
1
vote
1
answer
386
views
Angular2 - Typescript: viewInjector no more a valid key in Component annotation
I am working through the ng-book 2 and got stuck with viewInjector:
@Component({
selector: 'demo-form-sku-builder',
viewInjector: [FormBuilder]
})
error TS2345:
Argument of type '{ ...
1
vote
1
answer
1k
views
In TypeScript, how do I extend the ambient JQuery interface in an external module?
I'm creating jQuery plugins using external modules in TypeScript. It seems as that if I add the interfaces directly to the modules I cannot add the new methods to the JQuery ambient interface ...