-1

I've read: How to setup Material-UI for React with Typescript?

I'm completely new to typescript and thought that typescript is a superset of normal javascript. If so why do I have to do: typings install dt~material-ui --global --save in order to work with material-ui? Why does my materila-ui modules do not load without?

ERROR in ./source/scripts/components/app.tsx (4,20): error TS2307: Cannot find module 'material-ui/AppBar'.

Community
  • 1
  • 1
velop
  • 3,102
  • 1
  • 27
  • 30
  • Typescript is needed because the library is written in Typescript...? It has to be compiled to Javascript – OneCricketeer Aug 05 '16 at 14:54
  • 1
    maybe you should spend some time reading about Typescript? :) – toskv Aug 05 '16 at 15:01
  • also, if your react project doesn't use typescript already you're not going to need it. – toskv Aug 05 '16 at 15:04
  • @cricket_007 I do not think that material-ui is written in typescript – velop Aug 05 '16 at 15:25
  • @toskv Your first comment is not really helpfull. Well your seconds also not, sry ;) Do you have any sources I could dig into regarding typings? – velop Aug 05 '16 at 15:30
  • 1
    Are you writing your project in TypeScript? If so and you're using the material-ui then you need to install (or write your own) type declarations (or typings) for every Javascript library you're using in order for the typescript compiler to perform type checking. I suggest you read [the typescript docs](http://typescriptlang.com). – jebar8 Aug 05 '16 at 15:34
  • @jebar8 But can't I use a module without type checking. Like a normal javascript module? – velop Aug 05 '16 at 15:38
  • @velop see my answer below. – jebar8 Aug 05 '16 at 15:45

1 Answers1

0

Are you writing your project in TypeScript? If so and you're using the material-ui then you need to install (or write your own) type declarations (or typings) for every Javascript library you're using in order for the typescript compiler to perform type checking. I suggest you read the typescript docs.

Every module must have type declarations. If you really don't want to install them then one you can write your own and use the any keyword to skip type checking.

jebar8
  • 2,113
  • 3
  • 21
  • 31
  • It's not that I don't like them. But that all following modules I installed via npm (like https://github.com/taoyuan/reactee) do not have any type declarations yet. And writting them all would be really tedious. – velop Aug 05 '16 at 15:54
  • @velop if you use the `any` keyword then your typings will basically be one line per module. I would show you an example but I'm away from my computer. – jebar8 Aug 05 '16 at 15:56
  • 2
    @velop This might be relevant for you: http://stackoverflow.com/questions/36834121/typescript-what-to-do-if-a-typings-or-tsd-is-not-available – Alex Aug 05 '16 at 16:06