1
class Book{
    public title : string;
    public year  : number;

    constructor( title :string ,year:number){
        this.title = title;
        this.year  = year ; 


    }
}
var details = new Book("werr",2017);
console.log(details);

I'm a still beginner to Typescript.Any help would be highly appreciated.

  • do u have `tsc ` file? – brk Apr 30 '17 at 04:53
  • 1
    It's unclear what you're asking. Are you trying to run this code and view the result in your command prompt? Have you tried [installing the TypeScript compiler](https://www.typescriptlang.org/#download-links) and using it? – Hydrothermal Apr 30 '17 at 04:57
  • yes i did try . And its compiling fine. But how can i get the out put of that particular code.tsc app1.ts – Janath Vimukthi Don Francisco Apr 30 '17 at 04:59
  • 1
    you can check this link http://stackoverflow.com/questions/33535879/how-to-run-typescript-files-from-command-line – brk Apr 30 '17 at 05:01

1 Answers1

0

The command is

tsc <file_name>.ts && node <file_name>.js

You should have nodeJs installed in your system to run the above command. You can download NodeJs from here https://nodejs.org/en/

Assuming your TypeScript filename is main.ts

Then the command will be

tsc main.ts && node main.js

If you wish then you can run it seperately also.
First Compile using the following command

tsc main.ts

Then use the following command to run

node main.js

Soubhab Pathak
  • 619
  • 7
  • 14