Coder Social home page Coder Social logo

typescript-api-shim's Introduction

TS API Shim

Provides a single API layer to any version of TypeScript. Right now the goal is to first just handle a generic "TS -> JS" conversion.

The goal is:

const ts = require("typescript")
const {createTSShim} = require("typescript-api-shim")
const shim = createTSShim(ts)

const code = `const hello: string = "world"`
const js = shim.toJS(code)

With any version of TypeScript. I'd like to also get consistent error messages, line numbers etc.

Contribute

git clone https://github.com/orta/typescript-api-shim
pnpm i

node test

typescript-api-shim's People

Contributors

johnnyreilly avatar orta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

typescript-api-shim's Issues

module.exports might be an issue in versions of TypeScript pre v1.4

Heya!

Just had a quick play with this. From the looks of it, node test fails with all versions prior to TS 1.4 with an error like this:

Running tests
Version: ts-08
/home/john/code/github/typescript-api-shim/test.js:26
    console.log(Object.keys(ts).length)
                       ^

TypeError: Cannot convert undefined or null to object

I think this may be because TS 1.4 was the first version of TypeScript which featured a module.exports = ts; statement. Consider TS 1.4:

https://unpkg.com/[email protected]

as compared to

I'm guessing the lack of module.exports = ts; will be the reason it chokes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.