-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: add links ts playground #155
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
Conversation
@@ -910,7 +930,7 @@ export function App() { | |||
); | |||
} | |||
export function Component() { | |||
const { state, update } = React.useContext(TextProvider); | |||
const { state, update } = React.useContext(TextContext); |
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.
TypeScript actually caught this in the Playground 😄
**Type Guarding**: Sometimes Union Types solve a problem in one area but create another downstream. If `A` and `B` are both object types, `A | B` isn't "either A or B", it is "A or B or both at once", which causes some confusion if you expected it to be the former. Learn how to write checks, guards, and assertions (also see the Conditional Rendering section below). For example: | ||
|
||
```ts | ||
interface Admin { | ||
role: string: | ||
role: string; |
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.
TypeScript caught this one too 💯
This is a great first step. TypeScript playground with automatic type aquisition will help a lot. I would like the default options to be as strict as possible though. No I'm a bit concerned about the maintenance this requires. We would need to check that the playground is updated properly when someone edits a snippet, right? I guess we'll see if this becomes a problem and then try to improve. |
@eps1lon Thanks for the feedback! Good point on the default options.
I don't think so. I mean, I wouldn't expect the playground to have breaking changes when it updates, but I'd say let's give it a shot and see how it works. Besides checking In addition to updating all the links, I think I should also update the |
But we do have to update the contents and therefore the link, no?
The default options when visiting http://www.typescriptlang.org/play/index.html: |
Oh, I misunderstood what you meant the first time. Yeah, you're right. But hopefully that shouldn't be too much of a hassle. Guess we'll have to give it a shot like you said. Cool! I'll update the Playground links and use those options! |
@eps1lon Okay, I think it's ready for a second look |
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.
Nice, thanks!
This PR resolves #134
Changes: