We have developed custom typings for the latest version of material-ui@next
and successfully included them in the library during the last beta release.
For those interested, you can access the index.d.ts
file here.
However, there seems to be a problem with the current state of the typings. While they function properly when used locally during development, issues arise when attempting to package and distribute them with the library. TypeScript appears to utilize a different discovery method in this scenario.
Any typings that make reference to a subfolder (e.g.
declare 'material-ui/Button/Button'
) are not being recognized by TypeScript. This results in an error when trying to import components:
[ts]
Could not find a declaration file for module 'material-ui/Button/Button'. '<project path>/node_modules/material-ui/Button/Button.js' implicitly has an 'any' type.
Try `npm install @types/material-ui/Button/Button` if it exists or add a new declaration (.d.ts) file containing `declare module 'material-ui/Button/Button';`
Is there a limitation in TypeScript preventing the declaration of external imports within the node_modules
directory? It's worth noting that using these typings locally or relocating them to @types/material-ui
resolves the issue.
In addition, TypeScript seems able to locate the index.d.ts
file, as importing from the "root" directory functions correctly (
import { Button} from 'material-ui'
).