This is more a question about writing type definitions than about typings, feel free to let me know if I should post this elsewhere!
I've been working on the type definitions for Griddle, which only exports a React class, essentially to be used like so:
import * as React from 'react';
import { render } from 'react-dom';
import Griddle from 'griddle-react';
render(
<Griddle />,
document.getElementById('root')
);
There are some interfaces in my definition that would be really great for a developer to be able to consume, but I haven't found a good way to make it available. If I simply export them along side the true default export, they need to access it in a way that doesn't look so great:
import {default as Griddle, CustomColumnComponentProps} from 'griddle-react';
If I was able to declare a namespace that contained the interface that wasn't wrapped by typings in the ambient module declaration, they could gain direct access to the interface. Something resulting like:
declare namespace GriddleReact {
export interface GriddleProps {
someProp: string;
}
}
declare module 'griddle-react' {
export default class Griddle extends React.Component<GriddleReact.GriddleProps, any> {}
}
which could then be used like:
import Griddle from 'griddle-react';
var someProps: GriddleReact.GriddleProps = {someProp: 'prop'};
Is this frowned upon because it pollutes the environment with a namespace that the consumer may not be expecting? Any other thoughts or good ways to do this?
This is more a question about writing type definitions than about typings, feel free to let me know if I should post this elsewhere!
I've been working on the type definitions for Griddle, which only exports a React class, essentially to be used like so:
There are some interfaces in my definition that would be really great for a developer to be able to consume, but I haven't found a good way to make it available. If I simply export them along side the true default export, they need to access it in a way that doesn't look so great:
If I was able to declare a namespace that contained the interface that wasn't wrapped by typings in the ambient module declaration, they could gain direct access to the interface. Something resulting like:
which could then be used like:
Is this frowned upon because it pollutes the environment with a namespace that the consumer may not be expecting? Any other thoughts or good ways to do this?