Skip to content

lurdan/ob-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ob-typescript

http://melpa.org/packages/ob-typescript-badge.svg

This org-mode babel extension enables you to execute typescript code blocks.

Install

Requirement

You need to install node.js and typescript to use this extension.

MELPA

With setting up MELPA, use M-x package-install ob-typescript .

Manually

Add ob-typescript.el to your load-path and require.

(add-to-list 'load-path "/path/to/ob-typescript.el")
(require 'ob-typescript)

Configure

(org-babel-do-load-languages
 'org-babel-load-languages
 '((typescript . t)
   ))

The default command used to run the typescript compiler is defined in org-babel-command:typescript. You may configure this to do things like use a sandboxed version of the typescript compiler without having to install it globally

(setq org-babel-command:typescript "npx -p typescript -- tsc")

Examples

Execute with node.js

module Greeting {
    export class Hello {
        constructor(private text : string) {
        }
        say() :void{
            console.log(`${this.text}, ${x}, ${y}`);
        }
    }
}

var hello : Greeting.Hello = new Greeting.Hello("Hello, World!");
hello.say();

Transpile

You can see transpile results by specifying “:wrap src js” header argument.

module Greeting {
    export class Hello {
        constructor(private text : string) {
        }
        say() :void{
            console.log(this.text);
        }
    }
}

var hello : Greeting.Hello = new Greeting.Hello("Hello, World!");
hello.say();

About

Emacs org-mode babel support for typescript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •