With #13229 we got the proper infrastructure to present our demos both in JavaScript and TypeScript. We want to continue this effort with the goal to have all demos available in TypeScript.
If you want to make contributions to this repository and know a bit of TypeScript we would appreciate you helping us.
TL;DR: Use #14739, #14485 or #14535 as example workflows.
./docs/src/pages/demos/lists/lists.md
and find the section. You're looking for a {{ "demo": "some-path" }}
block: {{"demo": "pages/demos/lists/NestedList.js"}}
^^^ Name of the demo file in `./docs/src/pages/demos/lists/`
.tsx
yarn docs:typescript:check
to verify your workIf you're stuck at any point and the type checker will not let your code pass you can still submit the PR. A maintainer will take a look and provide guidance.
It's important that you don't change any behavior. To verify this you can run yarn docs:typescript:formatted
. This will transpile the typescript demos to JavaScript. This _should_ not cause changes in any JavaScript file. It is possible, however, that this will uncover a bug, at which point a change to the JavaScript version is more than welcome. You may encounter some changes in whitespace (mainly added or removed lines). Changes to the JavaScript file are perfectly fine in this case.
components/steppers:
done
components/app-bar:
components/autocomplete:
components/avatars #14954:
components/badges:
components/bottom-navigation #14979:
components/breadcrumbs #15139:
components/buttons:
components/cards:
components/checkboxes:
components/chips:
components/click-away-listener:
components/container #16322:
components/dialogs:
components/dividers #15037:
components/drawers:
components/expansion-panels #15162:
components/grid-list #15118:
components/grid:
components/hidden:
components/icons:
components/links:
components/lists:
components/menus:
components/modal:
components/no-ssr:
components/paper:
components/pickers #15103:
components/popover #16322:
components/popper:
components/portal:
components/progress:
components/radio-buttons:
components/rating:
components/selects #15288:
components/skeleton:
components/slider:
components/snackbars #15087:
components/speed-dial:
components/steppers:
components/switches:
components/tables:
components/tabs #15053:
components/text-fields:
components/textarea-autosize:
components/toggle-button:
components/tooltips #15061:
components/transfer-list:
components/transitions #16003:
components/tree-view:
components/typography:
components/use-media-query:
css-in-js/basics:
customization/breakpoints:
customization/components:
customization/globals #17785:
customization/palette:
customization/theming:
customization/typography:
guides/composition:
guides/interoperability:
guides/right-to-left:
styles/advanced:
styles/basics:
system/basics:
system/borders:
system/display #16334:
system/flexbox #16334:
system/palette #16334:
system/positions #16334:
system/shadows #16334:
system/sizing #16334:
system/spacing #16334:
system/typography:
What if we re-wrote all of the examples in TypeScript and then compiled them to JavaScript?
That way we if we write a hooks TypeScript + classes TypeScript we could (in theory) do any combination of TypeScript, JavaScript, and hooks.
馃
Just a fun thought. 馃嵀 I haven't fully assessed whether doing so makes sense.
@ricokahler I believe that is the plan in the future :)
What if we re-wrote all of the examples in TypeScript and then compiled them to JavaScript?
This is what we're essentially already doing right now. Just that we put the transpiled demos into version control. This way can allow JS-only contributions that a maintainer has to backport to TS if the TS/JS versions became out of sync.
I think we will keep this approach since the JS versions are displayed in our docs. If we remove them from version control we cannot automatically detect ugly transpilation artifacts (mainly whitespace related).
Which ones are missing? For example bottom-navigation is already done in next channel.
Which ones are missing? For example bottom-navigation is already done in next channel.
Thanks for letting me know, I've gone through and updated the list.
Hi, I am having trouble to type Button
with Link
fromreact-router
v5, as seen in https://next.material-ui.com/demos/buttons/#third-party-routing-library, maybe some one could add the ts version of this example.
tried:
<Button component={({ ref, ...props }) => <Link to="/about" {...props} ref={ref} />}>
about
</Button>
No issue in the editor.
but warning from material-ui
Warning: Failed prop type: Invalid prop `component` supplied to `ButtonBase`. Expected an element type that can hold a ref.
followed by warning from react
Warning: component: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop.
using typescrupt:3.3.4000, react:latest, material-ui: next(latest)
Just noticed there are few TypeScript demos that are done but not checked off above. All of the Dividers were done in #15037 , and CheckboxListSecondary, InsetList, and PinnedSubheaderList done in #15323 .
Just in time for the upcoming 4.0 release the effort of adding __192__ demos in TypeScript has been completed thanks to __44__ pull requests merged from the following __16__ authors: @VincentLanglet, @vitkon, @cojennin, @jasondashwang, @Dudrie, @rahmatrhd, @eluchsinger, @sperry94, @cahilfoley, @Adherentman, @donigianrp, @bh1505, @JarkEMones, @lksilva, @nareshbhatia and @merceyz
Huge thanks to all of you :+1:
I expanded the scope to every code demo not just component demos by adding around 120 new demos that are missing a TypeScript version. The list in the initial post has been updated accordingly.
Hi there, I want to contribute to this repo, can you guide me on how to do that.
Maybe this will be my first open source contribution.
Hi there, I want to contribute to this repo, can you guide me on how to do that.
Maybe this will be my first open source contribution.
Try to take a look in this
https://github.com/mui-org/material-ui/blob/master/CONTRIBUTING.md
These are already done but not checked:
Same goes for all demos in system/typography
@oliviertassinari How up-to-date is this? I was just looking at the docs and noticed that components/slider
has Typescript source.
@tgrowden A maintainer has to update it manually. Thanks for letting me know.
I'll take DynamicCSS
and DynamicCSSVariables
How do you guys want to handle with third party libraries that don't have types like material-popup-state
and react-swipeable-views-utils
?
@eps1lon Should we consider the effort completed? The demos we miss depend on third-party libraries, It unlikely they will be solved anytime soon (at least I have abandoned react-swipeable-views, and css-mediaquery hasn't changed since 2014).
Since the last PRs to complete this effort are opened I'd like to thank @cvanem, @dan8f, @rogerclotet, @limatgans, @oliviertassinari, @ganes1410, @burtyish, @schapka and @netochaves for completing the effort (these are the authors that opened a PR after the 4.0 release and weren't mentioned previously).
380 demos are now available in TypeScript!
@eps1lon Great effort, well done!
Most helpful comment
Just in time for the upcoming 4.0 release the effort of adding __192__ demos in TypeScript has been completed thanks to __44__ pull requests merged from the following __16__ authors: @VincentLanglet, @vitkon, @cojennin, @jasondashwang, @Dudrie, @rahmatrhd, @eluchsinger, @sperry94, @cahilfoley, @Adherentman, @donigianrp, @bh1505, @JarkEMones, @lksilva, @nareshbhatia and @merceyz
Huge thanks to all of you :+1:
I expanded the scope to every code demo not just component demos by adding around 120 new demos that are missing a TypeScript version. The list in the initial post has been updated accordingly.