Skip to content

Conversation

@kaigritun
Copy link

Problem

The key property in FuseSortFunctionMatch is typed as string, but the actual runtime value is an object created by createKey() in KeyStore.js.

As reported in #811, when using sortFn, the logged key shows:

key: {path: Array(1), id: 'name', weight: 1, src: 'name', getFn: null}

Solution

This PR:

  1. Adds a new FuseKey<T> type that correctly represents the key object structure:

    • path: string[] - the path segments
    • id: string - the key identifier (joined path)
    • weight: number - the assigned weight
    • src: string | string[] - the original source key name
    • getFn - optional custom getter function
  2. Updates FuseSortFunctionMatch.key to use FuseKey<any> instead of string

  3. Updates the JSDoc example to reflect the actual object structure

Testing

All existing tests pass (121 tests).

Fixes #811

The key property in FuseSortFunctionMatch was incorrectly typed as string,
but the actual runtime value is an object created by createKey() containing:
- path: string[] - the path segments
- id: string - the key identifier
- weight: number - the weight
- src: string | string[] - the original source key
- getFn: Function | null - optional custom getter

This adds a new FuseKey<T> type and updates FuseSortFunctionMatch to use it.

Fixes krisk#811
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong key type for FuseSortFunctionMatch type

1 participant