Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript #1632

Merged
merged 4 commits into from
Sep 3, 2024
Merged

TypeScript #1632

merged 4 commits into from
Sep 3, 2024

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Sep 3, 2024

Reboot of #129. Fixes #79.

TODO

  • ```ts fenced code blocks
  • ```tsx fenced code blocks
  • .ts modules
  • .tsx modules
  • TypeScript in inline expressions (not supported)
  • verbatimModuleSyntax to preserve imports
  • documentation
  • tests

Unlike #129, I expressly avoided allowing TypeScript in inline expressions, which allows us to avoid running the esbuild transform on them, and in turn avoids the problem of esbuild converting expressions to expression statements and then losing implicit display. Not also that there is no implicit display in ```ts blocks. I think this is an acceptable tradeoff, at least for now, as you get the primary benefits of TypeScript modules and TypeScript fenced code blocks and only if you explicitly opt-in to using TypeScript.

Also unlike #129, this only allows TypeScript to be imported with the .js, as we do for .jsx. This is the recommended practice because it means the import path doesn’t change after transpilation.

@mbostock mbostock requested a review from Fil September 3, 2024 01:44
@mbostock mbostock enabled auto-merge (squash) September 3, 2024 02:30
docs/javascript.md Show resolved Hide resolved
docs/javascript.md Show resolved Hide resolved
@Fil Fil disabled auto-merge September 3, 2024 05:49
Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels right and elegant. Just adding two suggestions for the documentation

@Fil
Copy link
Contributor

Fil commented Sep 3, 2024

The next release is going to be HUGE!

@Fil Fil merged commit a7b474a into main Sep 3, 2024
4 checks passed
@Fil Fil deleted the mbostock/typescript branch September 3, 2024 07:20
@Fil Fil mentioned this pull request Sep 4, 2024
6 tasks
@mpj
Copy link

mpj commented Sep 20, 2024

oh my

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript
3 participants