mui / mui/base-ui

[toast] Is it possible to augment/extend existing type?

Open
#3,437 2 comments 1 reaction 0 assignees View on GitHub
component: toast typescript
Dominant language
TypeScript
Stars
10.9k
Forks
543
Avg merge
1d 20h
Merged PRs (30d)
101

Description

Not sure if this is a bug or a misconfiguration on my part so please move this issue to discussion if the behavior is as expected

I would like to constraint the `type` in Toast actions to only have a few string literals so I have the following type declaration in my `base-ui.d.ts`
```ts
/** biome-ignore-all lint/correctness/noUnusedVariables: safe, only augmenting types */
import '@base-ui-components/react'

declare module '@base-ui-components/react/toast' {
interface ToastObject {
type?: 'default' | 'info' | 'error' | 'success'
}
}
```
But the hints from `toast.add({ type: /**/ })` is still showing as the default `string | undefined`, even though when press the "Go to definition" key from the IDE, the editor shows both the library code and my `d.ts` file, which means the LSP properly picked up my types file

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.