refactor(core): add overloads to useVueFlow (#1481)

* refactor(core): add overloads to `useVueFlow`

* chore(changeset): add

* chore(core): cleanup
This commit is contained in:
Braks
2024-06-18 12:29:29 +02:00
parent 9b4e3b2656
commit 4fe1a7b541
5 changed files with 37 additions and 26 deletions
+7
View File
@@ -14,6 +14,9 @@ export enum ErrorCode {
EDGE_SOURCE_TARGET_SAME = 'EDGE_SOURCE_TARGET_SAME',
EDGE_SOURCE_TARGET_MISSING = 'EDGE_SOURCE_TARGET_MISSING',
EDGE_ORPHANED = 'EDGE_ORPHANED',
// deprecation errors
USEVUEFLOW_OPTIONS = 'USEVUEFLOW_OPTIONS',
}
const messages = {
@@ -36,6 +39,10 @@ const messages = {
[ErrorCode.EDGE_ORPHANED]: (id: string) =>
`Edge was orphaned (suddenly missing source or target) and has been removed\nEdge: ${id}`,
[ErrorCode.EDGE_NOT_FOUND]: (id: string) => `Edge not found\nEdge: ${id}`,
// deprecation errors
[ErrorCode.USEVUEFLOW_OPTIONS]: () =>
`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`,
} as const
type ErrorArgs<T extends ErrorCode> = (typeof messages)[T] extends (...args: any[]) => string