Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

The normalize function in VectorUtils.ts was missing an instanceof check for Float16Array, causing it to fall through to the default Float32Array return, losing type information.

Changes:

  • Added Float16Array instanceof check with runtime availability guard (typeof Float16Array !== "undefined")
  • Returns new Float16Array(normalized) when input is Float16Array
  • Positioned check after Float32Array, before Int8Array checks

Implementation:

// @ts-ignore - Float16Array is not yet in TypeScript's lib but is supported in browsers
if (typeof Float16Array !== "undefined" && vector instanceof Float16Array) {
  // @ts-ignore
  return new Float16Array(normalized);
}

The runtime check ensures compatibility with environments where Float16Array is unavailable (Node.js < v22) while preserving type information where it exists.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update VectorQuantizeTask and VectorSimilarityTask based on feedback Add Float16Array type preservation to normalize function Jan 4, 2026
Copilot AI requested a review from sroussey January 4, 2026 01:03
Copy link
Collaborator

@sroussey sroussey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the @ts-ignore -- this has been fixed in recent versions

@sroussey sroussey closed this Jan 4, 2026
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.

2 participants