Skip to content

Why are interfaces e.g. TableProps, part of the top-level external API, not exported? #3087

@craigkovatch

Description

@craigkovatch

Trying to define a component with an external API e.g.:

import * as React from 'react';
import { useTable } from 'react-aria';
import { useTableState } from 'react-stately';

export type ContentTableProps = TableProps & {

}

export const ContentTable: React.FC<ContentTableProps> = props => {
  return <div>

  </div>;
};

The necessary TableProps here is used in the parameters of the useTable signature, so it should be exported so I can define a new type based on it. Or just so I can create a type-safe object of it. Is there a reason it's not exported?

TableProps here is just an example, from what I can see there are lots of exported APIs which are defined against non-exported interfaces.

FWIW Microsoft makes a TypeScript analysis tool called API Extractor; it's Number 2 Headline Feature is designed to help detect and correct this situation: https://api-extractor.com/

Missing exports: Suppose the awesome-widgets package exports an API function AwesomeButton.draw() that requires a parameter of type DrawStyle, but you forgot to export this enum. Things seem fine at first, but when a developer tries to call that function, they discover that there’s no way to specify the DrawStyle. How to avoid these oversights?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions