-
Notifications
You must be signed in to change notification settings - Fork 254
Typescript support #266
Comments
I'm not a typescript user, but indeed it would be great having the typescript description file for all the typescript users out there :) For the conf table in the doc, it's manually, but I like the idea of scanning the component and generating it automatically :) |
OK, I will try to parse 1.5's .propTypes objects. |
I prepared the first .d.ts version. I have problem with the functional properties signature. Some of them I recognized from your code or examples - can you check it out please? And there are some of them which I cannot recognize. Thanks. Cannot recognize:
Check it out please:
|
TableHeader.cellFormatter can take 3 params, but only the first one is really needed. The 2 others are just in some specific usecases. (String, Object, Number) which are the value in the cell, the row object, and the index of the row. Your definition for TableHeader.sortFn is correct. And the others as well. |
All elements are expected to have intrinsic HTML attributes like |
@tleunen thanks, I modified TableHeader.cellFormatter to (val:string, row: any, rowIndex:number) => string. What is your idea concerning using this file in your project? Some of pure JavaScript repos has Typescript directory in the root. Or will it be better to wait for @alexeyzimarev version (which will be part of DefinitelyTyped project)? @alexeyzimarev, thanks for info about your project, I removed obsolete Comments:
interface CardTitleElement extends React.ReactElement<CardTitleProps> { }
const CardTitle: CardTitle;
|
I don't mind adding a typescript definition file in this project, if one of you guys want to send a PR for that ;) |
intrinsic attributes value?: string | string[];
rows?: number; Those definitions are in conflict with the following react-mdl definitions: Possible solution is to keep |
@PavelPZ as you can see, I define interfaces for both Props and for ComponentClass. This is because I find it not correct to define classes in type definitions although I realize that these are ambient references, still it actually would generate some real JS code, whilst interface definitions do not generate anything. In order to export a component type, I declare a constant that has interface as its type and export it. This approach is used in type definitions for many popular component libraries like react-bootstrap. Regarding the HTML attributes, all components are in fact HTML elements and normally should have all intrinsic HTML attributes available. These attributes are widely used in samples and this is where I got issues using your d.ts file. I am not sure if machine generation is good or not. I am still working on my definitions file and I test all components with it. Adding oneOf is not a problem for me too but of course it will need changes if the source library changes. |
@alexeyzimarev, HTML attributes are already solved. |
I see that typescript are available in the DefinitelyTyped repo. See https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/react-mdl/ |
@tleunen first thanks a lot for creating react-mdl. I came from .NET and angular world and I surprisingly recognized that there is not any feasible ui framework for React so far (apart from horrible and not mobile friendly Material-UI or apart from react-bootstrap). I appreciate a lot your approach of react component wrapping up Google JS and CSS and I find it very promising.
However, I am missing the Typescript support. Typescript is not so popular in React community but its usage in JavaScipt and node.js (and angular 2) world is incredibly growing.
Are you interested in contributing react-mdl.d.ts Typescript definition file?
If yes:
The text was updated successfully, but these errors were encountered: