mittwald / flow

A collection of packages related to Flow – the mittwald design system.
https://mittwald.github.io/flow/
MIT License
6 stars 1 forks source link

Missing type exports #997

Closed gskyarts closed 4 days ago

gskyarts commented 1 week ago

I need the following type for my code import type NotificationController from "node_modules/@mittwald/flow-react-components/dist/js/types/components/NotificationProvider/NotificationController";. But as you can see, this looks pretty messy and hacky - it works, but it would be much nicer and cleaner if we could get this as an export.

Right now I only have these two cases:

Would it be possible to export all types and interfaces? Maybe only these two were forgotten.

Lisa18289 commented 5 days ago

the imports will be available, as soon as https://github.com/mittwald/flow/pull/998 is merged: import type { NotificationController } from "@mittwald/flow-react-components/NotificationProvider"; import type { Status } from "@mittwald/flow-react-components/types";

mfal commented 4 days ago

We decided not export named types that can be derived by existing types in every case, because this enlarges the libraries public interface and introduces the risk of breaking type changes. Also we would have to put extra effort into a non-conflicting naming.

But TypeScript offers some helpers to extract types:

import type { AlertProps } from "@mittwald/flow-react-components/Alert";

type AlertStatus = AlertProps["status"];
import type { useNotificationController } from "@mittwald/flow-react-components/NotificationProvider";

type NotificationController = ReturnType<typeof useNotificationController>

FYI: The NotificationController type will be exported in the PR.