fable-compiler / Fable

F# to JavaScript, TypeScript, Python, Rust and Dart Compiler
http://fable.io/
MIT License
2.93k stars 300 forks source link

ts2fable fails for material-ui.d.ts #430

Closed rascala closed 7 years ago

rascala commented 8 years ago

Description

ts2fable fails with ERROR: TypeError: Cannot read property 'forEach' of undefined when run on material-ui.d.ts

Repro steps

Please provide the steps required to reproduce the problem

  1. Download material-ui.d.ts: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/material-ui/material-ui.d.ts
  2. run ts2fable material-ui.d.ts

    Expected behavior

Generate a fable to js interface file

Actual behavior

Fails with ERROR: TypeError: Cannot read property 'forEach' of undefined

-- At line 739 of ts2fable. Looks like node.body.statements is undefined.

Known workarounds

Comment out the "declare namespace __MaterialUI.Styles " block starting on line 7319 in the .d.ts file. Works then.

This .d.ts file seems to have some archaic syntax not commonly seen in typescript files.

Still unable to figure out how to use the generated components from the .fs file in fable-elmish example. Any tips would be appreciated!!

Related information

alfonsogarciacaro commented 8 years ago

Thanks for the report. The ts2fable needs an overwrite but I'll have a look at the issue. There's an example of using material-ui components dynamically (without bindings) here, but I'm not sure if it applies to your use case.

rascala commented 8 years ago

Thanks for the link. I had looked at it but didn't want to go the dynamic way. For now, I plan to manually write the signatures for the components I want. Hopefully, I can bring it to parity with the .ts file as time goes and port some of the sample projects to material-ui.

alfonsogarciacaro commented 8 years ago

I haven't used fable-elmish that much myself, but to instantiate a React imported component I think you can use Fable.Helpers.React.from.