Comments (31)
Having the lib in TS would be amazing - so far the slowest part of working with Typesense is the time taken to keep checking the docs to find out what methods I need to call on the client (plus the time debugging the errors caused by me assuming an incorrect return type etc).
In the meantime, I knocked together some type defs myself to make my own work more productive. Might be helpful for others until official TS support lands:
https://gist.github.com/michaelbromley/fd1e6137485200654cb7104439e6a699
from typesense-js.
I just wanna shout my thanks to @Ziao for your work :) I'm happily using typesense-js off your branch and it's working great. I really appreciate it!
from typesense-js.
@phihochzwei and everyone else,
I completed the TS conversion a while ago and updated the tests but never got around to getting the PR rebased and merged in. I'm very sorry to say that the work pressure is not allowing me to spend too much time on this at the moment, but essentially once any conflicts are solved and the work is reviewed, I'm cool having the PR merged in.
Here's the PR, btw: #62
from typesense-js.
Hey everyone,
Thanks to @Ziao and @dcantu476, we now have TypeScript types in v1.0.0-1
v1.0.0-3
.
There are no other breaking changes to the external API other than the switch to TypeScript. It felt like a big enough change to warrant a major version increment.
Would love to get your feedback!
from typesense-js.
Hey everyone, I need to update PR #43 to include types for the latest features available in Typesense. We're also working on v0.19 currently, which will have additional features. Once that's out in the coming weeks, I'll be able to focus on updating the PR.
In the meantime, I could definitely use some help on this, since I need to pick up Typescript on the fly.
from typesense-js.
I had a look at that PR, while a good start, it's generated from the JS source files and thus contains a lot of any
types, exposes private members (starting with _), and would be a monster keeping it synchronised with the actual source code while also providing high quality typings. As @goleary mentioned, using typescript instead of javascript would alleviate a lot of headaches, both now and in the future when things get out of sync.
Would you be okay with a PR where I convert the entire code base into Typescript (while ensuring the tests still pass, of course)? It's not as scary as it sounds, but would ensure that things stay in sync in the future, and you get amazing code completion in your editor. I don't think this project is under heavy development right now, so I think it wouldn't cause too many issues. I'd be happy picking this up short term. Is there a way to contact you directly, such as Discord or similar?
from typesense-js.
up
from typesense-js.
@Ziao - I really appreciate the amount of effort you've put into shaping this PR! ๐
@dcantu476 and I have been working on getting your PR up to date and adding in some remaining types as part of #71.
from typesense-js.
Thanks @dcantu476. I've released this in v1.0.0-4
.
from typesense-js.
@Ziao I missed Github's notification somehow.
Thank you for reviewing. It would be great to have a PR that converts the entire codebase to Typescript โค๏ธ
I made some tiny changes in the ts-server-0.20.0-support
branch and I'll be merging that to master soon. Could you branch off of that for this PR?
from typesense-js.
@p-young I believe you are correct, but I'll have to test it more to be sure. I also think the correct type is logger.LogLevelDesc
.
In the future, it might be better to implement some abstraction around the logger so that the client doesn't have to worry about using types directly from the logger library. It'd also put it in a good place where if you need to swap the logger out for something else in the future.
from typesense-js.
+1 would also love to see TS support
from typesense-js.
Really wouldn't be hard to write the definitions for it if the code had proper jsDocs.
from typesense-js.
I've personally not used Typsescript before, so I'd have to do some reading to get up to speed. Would love some help from more experienced Typescript experts!
from typesense-js.
Related: PR #43
from typesense-js.
Any updates on this? It looks the PR is done and ready to merge.
from typesense-js.
Hey @jasonbosco,
Any update on the TypeScript typings. We are evaluating search solutions at this moment for a new product and this is a great feature to have
from typesense-js.
I would be completely happy to pick this up and maintain it or if you need a hand with anything :)
from typesense-js.
@Ziao Thank you! That would be awesome!
I just started reading up on Typescript last week, but I could definitely use help with this. Would you be able to review PR #43? It's also missing the multi_search endpoint we added in v0.19. If you could help review + add types for the new endpoints, we can then merge that in.
from typesense-js.
Oh also, hereโs our Slack channel: https://join.slack.com/t/typesense-community/shared_invite/zt-mx4nbsbn-AuOL89O7iBtvkz136egSJg
from typesense-js.
Thank you for that @michaelbromley!
CC: @Ziao
from typesense-js.
Any news on this? We urgently need this to use Typesense in our Firestore-Projects.
from typesense-js.
@jasonbosco @dcantu476 Woohoo! Nice one! I'll try to give it a spin this weekend and go through the changes one last time. Looks good though!
from typesense-js.
Released a new version v1.0.0-2
with the feedback in #73.
from typesense-js.
I gave it a try and ran into this error:
node_modules/typesense/lib/Typesense/Configuration.d.ts:31:16 - error TS2503: Cannot find namespace 'logger'.
31 logLevel?: logger.LogLevel;
At the top of Configuration.ts, should it be:
import * as logger from 'loglevel'
instead of right now:
import logger from 'loglevel'
The default export of loglevel doesn't seem to be the right thing.
from typesense-js.
Released a new version with improvements: https://github.com/typesense/typesense-js/releases/tag/v1.0.0-3
@dcantu476 The only other pending thing is: #32 (comment)
from typesense-js.
@jasonbosco I'll do a small PR for the loglevel typings and redo the import. I do want to mention though, I never was able to reproduce issues with the import for logger in general.
from typesense-js.
Hi, we are currently using the Typescript version of Typesense, and i found few errors:
- The field
geo_distance_meters
is missing in the SearchResponseHit interface (example in the documentation) - The ImportResponseFail interface contains:
document: DocumentSchema;
- but it should be
document: DocumentSchema[];
Thanks for this TS version anyway, feel amazing to work with it ๐
from typesense-js.
I'll try to debug this one: #32 (comment)
from typesense-js.
Hey, I'm currently swapping over from Algolia, and something that would be a great nice to have would be to add Generics
.
I do see the Issue has been opened already here #152
Current:
const searchResults = await this.collections(collectionName).documents().search(options)
searchResults return type: SearchResponse<{}>
For me to get the hits with the correct types, I need to do something like
searchResults.hits?.map((hit) => hit.document) as Type[]
Suggestion:
const searchResults = await this.collections(collectionName).documents().search<Type>(options)
return type: SearchResponse<Type>
typeof searchResults[0].document === Type
from typesense-js.
Even better would be the ability to run a script that codegens the types, similar to what Prismic does.
from typesense-js.
Related Issues (20)
- Multi-search response type mismatch (`collection_name` missing from `request_params`) HOT 2
- 400 error with update(..., { filter_by }) HOT 2
- Missing Pagination Params `offset` and `limit` HOT 1
- `found_docs` not included in the SearchResponse interface HOT 2
- connectionTimeoutSeconds seems to not be working HOT 6
- Add support for mulltiple API keys per cluster HOT 2
- Error Updating by query with npm package & Typesense Cloud: RequestMalformed: Request failed with HTTP code 400 | Server said: For update, the `id` key must be provided. HOT 2
- Unable to make a request work HOT 2
- Bump axios to 1.6.0 (CVE-2023-45857) HOT 2
- Missing search param `enable_highlight_v1` in types
- Improve TypeScript compatibility HOT 1
- include_fields in Retrieve a document HOT 3
- Inconsistent Search Results for Nested Objects
- Axios Cross-Site Request Forgery Vulnerability HOT 8
- Import with empty array fails
- Request to Node 0 failed due to "undefined Network Error" | Error: Exception in HostFunction: Malformed calls from JS: field sizes are different. HOT 2
- PresetSchema is declared as id but api returns name HOT 1
- Typesense search is double encoding square brackets "[" in bare react-native projects HOT 3
- Deleting collections with special characters doesn't work HOT 1
- Issue when updating collection schema
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typesense-js.