mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.87k stars 32.26k forks source link

Errors with component demos #10253

Closed enugentdt closed 6 years ago

enugentdt commented 6 years ago

Expected Behavior

I am trying to use the third AppBar demo on the material-ui-next component demos. Upon insert into my site, it should not error out, as this is a component demo

Current Behavior

Errors occur in multiple locations - mainly lacking a default for import React from 'react'; on the first line, which needs to be changed to import * as React from 'react';. Additionally, on line 33 among others, the following error occurs: (33,21): Parameter 'event' implicitly has an 'any' type.

Steps to Reproduce

  1. Download create-react-apps-with-typescript demo from the repo
  2. npm install
  3. Copy the code from the third AppBar demo into components/appbar.tsx
  4. Add <AppBar> component to pages/index.tsx
  5. yarn start

Context

This issue is entirely blocking, as I am unable to begin development on my own sites if the components I should learn from do not work themselves.

Your Environment

Tech Version
Material-UI beta 33
React latest
browser Chrome
OS MacOS High Sierra
oliviertassinari commented 6 years ago

@enugentdt I have just tried the typescript example instructions. It's working. I'm not sure you are looking at the right project.

mainly lacking a default for import React from 'react'; on the first line, which needs to be changed to import * as React from 'react';

https://github.com/mui-org/material-ui/blob/a81e5f9e54fdcc4648ffe6bdc08eaa596fb0a9bc/examples/create-react-app-with-typescript/src/index.tsx#L1

enugentdt commented 6 years ago

Apologies, I wasn't entirely clear in my wording. In the AppBar demo code, it needs to have import React from 'react'; changed to work properly on my system (sans the 'any' type errors). In the create-react-app-with-typescript project, it is correct.

oliviertassinari commented 6 years ago

Oh yes, the demos are written in ES2015. They are as simple as possible. I think that using import * as React from 'react'; will confuse beginner.

enugentdt commented 6 years ago

Would there be a possibility in updating them so they work with the latest beta, that way newcomers like myself are able to get a test site up and running quickly? I.e. fixing 'any' type errors, as I've had

oliviertassinari commented 6 years ago

@enugentdt If you mean writing our demo in TypeScript, the answer is no. While TypeScript popularity is quickly growing, it's still low compared to raw JS.