-
Notifications
You must be signed in to change notification settings - Fork 54
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
[jsx] add jsx support to playground #319
Conversation
src/test/playground-ide_test.ts
Outdated
</body> | ||
</script> | ||
<script type="sample/tsx" filename="howdy.tsx"> | ||
const howdy: string = "Howdy TSX!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to verify that this is getting interpreted as TSX, and not regular TS, since there's nothing TSX specific in this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally. i think that's leading to my real question, which is how to mock react
in this playground? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if stuff imports auto-magically like the real playground then we should be good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A script tag that pulls in React from a local node_modules path should define the window.React
global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't typescript emit import ... from "react"
though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since React isn't distributed as modules that doesn't work. You can import type ...
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll give that a shot. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mocked the react api with mock-react.ts
. It adds a text node to the body of the test.
We could use preact if we need more from an integration test.
excellent :) i think this is ready for a review, next up syntax highlighting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Please also update the README and CHANGELOG files.
E.g. here: https://github.com/google/playground-elements/#typescript
CHANGELOG.md
Outdated
@@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
<!-- ## Unreleased --> | |||
|
|||
## [0.17.0] - 2021-08-09 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it under "Unreleased". There's a commented header above that you can uncomment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i did it this time around
CHANGELOG.md
Outdated
@@ -25,6 +25,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
- Added support for compiling `jsx` and `tsx` modules in the playground. | |||
|
|||
### Changed | |||
|
|||
- Updated the tsconfig in `language-service-context.ts` to include `allowJs` and `jsx`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is to be consumed by users, not so much us, so I think this is too much detail. The user only cares that tsx and jsx files are now compiled.
Add JSX support to playground to support the Lit Labs React package.