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

Add TypeScript documentation, fixes #503 #703

Merged
merged 13 commits into from Nov 12, 2020
Merged

Conversation

@ddprrt
Copy link
Contributor

@ddprrt ddprrt commented Nov 4, 2020

Hi all 👋

This is the a draft addressing #503

The content is mostly adapted from my TypeScript + React guide I published two years ago, without the fluff and rephrased to suit proper documentation. It can be seen as an accompanying guide to the regular documentation, focusing on how to properly type so the compiler doesn't complain (which can be ... a lot!).

Things done:

  • Documenting types for functional and class components
  • Proper types for refs and events
  • A section on hooks
  • Proper typings for context

Things to do:

  • A section with exposed types. I currently browse through index.d.ts to get a feeling for all types used and work on scenarios on how to use them in consumer's code.
  • Re-check examples if there is a more up to date version. I also want to prevent people and SE crawlers to mistake this as a duplication of my original guide
  • If ok, I want to add a section with further reading to Component type design patterns (e.g. https://fettblog.eu/typescript-react-component-patterns/)

Note: For proper syntax highlighting I had to add tsx and typescript to Prism.js. I used the link in the prism.js comment to get the original configuration, and added two more languages (the new link is again in prism.js)

@developit
Copy link
Member

@developit developit commented Nov 4, 2020

I haven't finished reading through yet, but what I've read so far looks awesome!

Not sure what happened to travis, but ignore the build failure.

content/en/guide/v10/typescript.md Outdated Show resolved Hide resolved
content/en/guide/v10/typescript.md Outdated Show resolved Hide resolved
content/en/guide/v10/typescript.md Outdated Show resolved Hide resolved
src/config.json Outdated Show resolved Hide resolved
ddprrt and others added 4 commits Nov 9, 2020
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
typo
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
@ddprrt
Copy link
Contributor Author

@ddprrt ddprrt commented Nov 9, 2020

Suggestions committed 🙌

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Sweet, let's do this! And again thank you so much for the fantastic PR 🙌

@marvinhagemeister marvinhagemeister merged commit d43d92a into preactjs:master Nov 12, 2020
5 of 6 checks passed
5 of 6 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
Pages changed - preactjs 53 new files uploaded
Details
Header rules - preactjs 11 header rules processed
Details
Mixed content - preactjs No mixed content detected
Details
Redirect rules - preactjs 13 redirect rules processed
Details
netlify/preactjs/deploy-preview Deploy preview ready!
Details
@38elements
Copy link
Contributor

@38elements 38elements commented Dec 18, 2020

@marvinhagemeister
I think this change includes many repeating, incorrect, unnecessary things.
I think it is incorrect to merge this pull request.

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

Successfully merging this pull request may close these issues.

None yet

4 participants