Skip to content

Instantly share code, notes, and snippets.

@ngmaloney
Last active January 8, 2020 04:15
Show Gist options
  • Save ngmaloney/60adcccce772e71d3b73cc4e80eaa240 to your computer and use it in GitHub Desktop.
Save ngmaloney/60adcccce772e71d3b73cc4e80eaa240 to your computer and use it in GitHub Desktop.
typescript.cr
require "duktape"
class Typescript
TYPESCRIPT_PATH = "deps/libs/ts/typescriptServices.js"
def initialize(ts_file : String)
@ts_file = ts_file
@ctx = Duktape::Sandbox.new
@ctx.eval!("ts = require('typescript')")
end
def transpile!
@ctx.eval!("ts.transpile(@ts_file)")
end
def self.transpile!(ts_file : String)
self.new(ts_file).transpile!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment