Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How Does the TypeScript Team Try to Avoid Negative Effects on the JS Ecosystem

Orta
March 22, 2021

How Does the TypeScript Team Try to Avoid Negative Effects on the JS Ecosystem

Orta

March 22, 2021
Tweet

More Decks by Orta

Other Decks in Programming

Transcript

  1. How Does the TypeScript Team Try to Avoid Negative Effects

    on the JS Ecosystem By @Orta at devX SAP
  2. This talk TypeScript is big enough to affect the whole

    JS ecosystem What constraints does the team put on TypeScript to avoid harming JavaScript
  3. Operating Principles Open Source and Open Development Closely track ECMAScript

    standard Innovate in type system Best of breed tooling Continually Lower barrier to entry Community, community, community
  4. Design Goals Statically identify constructs that are likely to be

    errors. Provide a structuring mechanism for larger pieces of code. Impose no runtime overhead on emitted programs. Emit clean, idiomatic, recognizable JavaScript code. Produce a language that is composable and easy to reason about. Align with current and future ECMAScript proposals. Preserve runtime behavior of all JavaScript code. Avoid adding expression-level syntax. Use a consistent, fully erasable, structural type system. Be a cross-platform development tool. Do not cause substantial breaking changes from TypeScript 1.0. https://github.com/microsoft/TypeScript-wiki/blob/master/TypeScript-Design-Goals.md#goals
  5. Design Goals - For JavaScript Impose no runtime overhead on

    emitted programs. Align with current and future ECMAScript proposals. Preserve runtime behavior of all JavaScript code. Avoid adding expression-level syntax. Use a consistent, fully erasable, structural type system. https://github.com/microsoft/TypeScript-wiki/blob/master/TypeScript-Design-Goals.md#goals
  6. Design Goals - For Types Statically identify constructs that are

    likely to be errors. Provide a structuring mechanism for larger pieces of code. Produce a language that is composable and easy to reason about. Use a consistent, fully erasable, structural type system. https://github.com/microsoft/TypeScript-wiki/blob/master/TypeScript-Design-Goals.md#goals
  7. Big Title There’s a constant set of new learners to

    the language Lots of people are learning TypeScript as their first language Big enough
  8. TC-39 has to represent many voices JS Engines Browsers Node

    Dev Tools Web Devs Language Enthusiasts Beginners to JavaScript
  9. Can’t charge money Can’t go closed source Have to embrace,

    extend & extinguish JavaScript MalevolenTypeScript
  10. Extinguishing JavaScript Make TypeScript a native browser language Tricky, Microsoft

    doesn’t “own” a browser or engine Could try pitch a pre-parse types removal like babel plugin Web not like deno, no one time cost for TS
  11. Extinguishing JavaScript Make TypeScript differ from JavaScript TC-39 would get

    annoyed Users would get annoyed Someone would start a typescriptium fork
  12. Extinguishing JavaScript Make TypeScript differ from JavaScript TC-39 would get

    annoyed Users would get annoyed Someone would start a typescriptium fork
  13. Extinguishing JavaScript Make TypeScript differ from JavaScript TC-39 would get

    annoyed Users would get annoyed Someone would start a typescriptium fork
  14. One of TypeScript’s primary jobs is to help you migrate

    from TypeScript source code to plain JavaScript. Turn it to ESNext, run the compiler, delete your ts files and you’re done.
  15. Flow isn’t going anywhere (to my knowledge) so you can

    keep JS + types. People will write TypeScript to Flow tools. Hegel has TypeScript d.ts compatibility today
  16. Loosing JS Semantics Want to make it easy to keep

    supporting JavaScript users The further the distance between a compile to JS language and JS, the more additional work happens at runtime
  17. ?.

  18. Needs to: - add to AST - emit correct JS

    125 lines of code in a plugin Anyone can do it Optional chaining in Babel
  19. Needs to handle: - New Syntax in AST - New

    Emitter - Specialized error messages - Code flow analysis - Type narrowing support - Editor integration - Quick Fixes Many follow on PRs Thousands of lines of code Many many test files Not everyone can do it Optional chaining in TypeScript
  20. So Design Constraints Prefer working with TC39 Little incentive to

    break JS Can use TS to remove TS De-isolated tooling