Git Product home page Git Product logo

ts-babel's Introduction

Example project showing how to use babel with TS with pipelines. Here TypeScript is just used for typechecking. Since we need to run a babel pass before the code is ready for TypeScript, it won't work in the editor, just on the command line.

npm run build does a normal build (and no type-checking).

npm run check does a babel compile that just removes pipelines (and optional chaining and throw expressions).

npm run check-watch does the same using --watch for both babel and TypeScript.

npm run check-and-build-watch does both the TS typechecking and full builds using babel.

How it works

There are two different configurations for babel.

babel.config.for_typescript.js is just for removing things that TypeScript can't handle, like pipelines. That is then compiled to ts_check/src_from_babel. Then we run tsc --project ts_check/tsconfig.json, which has "noEmit": true, so nothing happens but typechecking.

babel.config.for_web.js does a normal build and no type-checking.

npm run check-and-build-watch will be running three processes in parallel:

  • One babel process from src to ts_check/src_from_babel, translating only syntax TS can't handle.
  • One TypeScript process looking at ts_check/src_from_babel and reporting type errors when the first process writes changes to it.
  • One babel process from src to lib, doing a full translation.

ts-babel's People

Contributors

andy-hanson avatar

Watchers

 avatar  avatar

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.