Questions tagged [typescript1.8]

Use this tag for questions specific to new features in TypeScript 1.8. For general TypeScript questions, the correct tag is TypeScript.

Use this tag for questions specific to new features in TypeScript 1.8. For general TypeScript questions, the correct tag is .

TypeScript 1.8 documentation

321 questions
235
votes
28 answers

Property 'map' does not exist on type 'Observable'

I am trying to call an API from Angular but am getting this error: Property 'map' does not exist on type 'Observable' The answers from this similar question didn't solve my issue: Angular 2 beta.17: Property 'map' does not exist on type…
Malik Kashmiri
  • 5,099
  • 11
  • 38
  • 72
127
votes
7 answers

Obtaining the return type of a function

I have the following function: function test(): number { return 42; } I can obtain the type of the function by using typeof: type t = typeof test; Here, t will be () => number. Is there a way to obtain the return type of the function? I would…
rid
  • 54,159
  • 26
  • 138
  • 178
112
votes
7 answers

Inheritance and dependency 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…
maxhb
  • 7,819
  • 9
  • 25
  • 50
97
votes
1 answer

How to configure custom global interfaces (.d.ts files) for TypeScript?

I'm currently working on a ReactJS project which uses Webpack2 and TypeScript. Everything works perfectly apart from one thing - I can't a find a way to move interfaces that I've written myself into separate files so that they are visible to the…
Andris
  • 4,543
  • 2
  • 24
  • 34
92
votes
5 answers

How to declare and import typescript 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…
snort
  • 1,728
  • 2
  • 15
  • 20
75
votes
14 answers

New Typescript 1.8.4 build error: " Build: Property 'result' does not exist on type 'EventTarget'. "

I am New to typescript. In my Durandal application I migrated to VS-2012 to VS-2015 means typescript 0.9 to typescript 1.8.4. After migrated I got so many build errors. I resolved all those except one. I am getting below build error on types of…
Rayudu
  • 1,678
  • 1
  • 11
  • 31
65
votes
5 answers

How can I convert a Set to an Array in TypeScript

How can I convert a Set (eg, {2,4,6}) to an Array [2, 4, 6] in TypeScript without writing a loop explicitly ? I have tried those following ways, all of them work in JavaScript but none of them work on TypeScript [...set] // ERR: "Type 'Set<{}>' is…
thanhpk
  • 2,910
  • 2
  • 23
  • 35
57
votes
2 answers

TypeScript Compile Options: module vs target

Trying to have some basic understanding about module and target. I would like to know the difference between module and target compile options in a typical tsconfig.json { "compilerOptions": { "module": "es6", "sourceMap":…
user203687
  • 6,223
  • 10
  • 46
  • 78
52
votes
3 answers

How to install older version of Typescript?

I recently installed Typescript 1.8 and found too many breaking issues. So for the time being I would like to install 1.7. Where can I get a link to down this?
AlvinfromDiaspar
  • 5,868
  • 13
  • 63
  • 120
45
votes
3 answers

'this' is undefined inside the foreach loop

I am writing some typescript code and iterating an array. Inside the loop, I am trying to access 'this' object to do some processing as: console.log('before iterate, this = ' +this); myarray.days.forEach(function(obj, index) { …
user1892775
  • 1,533
  • 2
  • 28
  • 41
43
votes
5 answers

Ionic 2 - Disabling 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…
naiveai
  • 235
  • 1
  • 12
  • 31
40
votes
6 answers

Getting error TS2304: Cannot find name 'Buffer'

I am trying to do base64 encode in NodeJS using TypeScript. Following code working fine in JavaScript. When I am writing same thing in TypeScript and compiling, I am getting Buffer is not find error. var base64Policy = new Buffer(stringPolicy,…
ayyappa maddi
  • 607
  • 2
  • 9
  • 17
35
votes
3 answers

Directory structure for TypeScript projects

What would be an idiomatic directory structure for a TypeScript project? I would like the following features in such a structure: Separate directories for TypeScript source code and transpiled JavaScript Separate directories for project source…
codematix
  • 1,095
  • 1
  • 14
  • 28
33
votes
3 answers

TypeScript: How to define custom typings for installed npm package?

I like to use rx-node within TypeScript import RxNode from 'rx-node'; I installed rx-node using npm $ npm install rx-node --save I searched for type definitions, but without any result $ typings search rx-node No results found for search How can…
maiermic
  • 3,790
  • 6
  • 28
  • 57
32
votes
1 answer

Typescript 1.8 modules: import all files from folder

I am building a big library with Typescript with like 100 separate ts files. Previously I used export module XXX (renamed to export namespace XXX later) for all my classes, but as books say, this is not a recommended way, I should use import…
zeroin
  • 5,477
  • 6
  • 26
  • 39
1
2 3
21 22