Skip to content

fix(collection): return the partial update schema from Collection.update - #378

Merged
tharropoulos merged 2 commits into
typesense:masterfrom
cpruijsen:fix/issue-150-cd9dae3f
Oct 10, 2026
Merged

tharropoulos merged 2 commits into
typesense:masterfrom
cpruijsen:fix/issue-150-cd9dae3f

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

Collection.update() in src/Typesense/Collection.ts now returns Promise<CollectionUpdateSchema>, which matches the partial PATCH response.
The previous CollectionSchema return type promised full collection properties that the response does not contain.
Callers that need name or num_documents can use retrieve().

CollectionUpdateSchema covers field-drop entries and metadata-only responses and matches the OpenAPI response definition.
Runtime request behavior is unchanged.

The regression tests in test/collection-update.type.test.ts require the partial return type and reject the full collection type.
Both fail against the original source and pass with this change.

Fixes #150.

@tharropoulos tharropoulos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for the contribution! just a small nitpick about testing scope.

Comment thread test/collection-update.type.test.ts Outdated
CollectionUpdateSchema,
} from "../src/Typesense/Collection";

describe("collection update", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

instead of a type test here, could we add a type test and runtime validation under the existing Collection.spec.ts tests?

@cpruijsen

Copy link
Copy Markdown
Contributor Author

Moved the test into the existing .update test in Collection.spec.ts. It now has a type assertion on the return value plus runtime checks on the response, and the standalone type test file is removed.

@tharropoulos

Copy link
Copy Markdown
Collaborator

Thank you for your contribution!

@tharropoulos
tharropoulos merged commit fde8fc0 into typesense:master Oct 10, 2026
1 check passed
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.

Return value of collection update method seems mis-typed

2 participants