Comments (12)
We also need TS support. Well, it serves as documentation, it allows to use IntelliSense, and fits well in the project that is already using Typescript everywhere.
I can see that Google in their different APIs are moving faster and faster with adopting Typescript and providing typings inside libraries (Firebase, for example, many others too, but not datastore
itself yet).
If to narrow down to 1 argument:
It serves as documentation, sometimes better than documentation itself.
from gstore-node.
Yes that might be a solution. Just writing the type definitions files 😄 I was thinking in converting the whole project from js to Typescript but might not be necessary. I will give it a thought.
from gstore-node.
Hello,
I just made a release (v4.1.0) with Typescript support. Let me know if it works for you 👍
from gstore-node.
Hello,
Although this would be a nice feature, this is not currently planned in future releases. I guess you are mainly interested in getting all the typings for your project?
It would be nice to know what is the interest for Typescript support. Let's leave this issue opened and find out 😄
from gstore-node.
Ok I take note. I am currently finishing a big feature (cache mechanism) for the next release (v3.0.0)
Typescript might then be a next target.
from gstore-node.
Sounds good! Good luck with 3.0!
from gstore-node.
Hello..
Could you point me to a few good node library that you use that are made in Typescript? So I can have a look at how they package and expose their lib.
thanks!
from gstore-node.
@sebelga I'm also interested in typescript types.
Here's repository for typescript types.
For examples you can check the @types/express or @types/node
from gstore-node.
Hi @LogansUA thanks but I was referring to NodeJS libraries you are using in your projects done in Typescript. So I can have a look at how they expose their bundles. (both in es6 and Typescript format). 👍
from gstore-node.
Well, I'm now using express, dotenv, ramda, stripe, winston etc. in my TS project with their typescript types
from gstore-node.
Hello,
I finished writing the typings for gstore-node. I haven't published it yet as I would like if someone could test it in a actual Typescript project. I hope I haven't forgot anything 😄
@LogansUA @nexussmart @kirillgroshkov could one of you test this inside your project?
Just clone the "feature/#89-typescript-definitions" branch and replace the content in the node_modules/gstore-node
folder.
This is how to add the Types for a User Model
type UserTypes = {
userName: string;
email: string;
age?: number; // optional
tags?: string[]; // optional
birthday?: Date; // optional
}
// Strict typings (not other properties allowed than the ones on Schema)
// ----------------------------------------------------------------------------------
const schema = new Schema<UserTypes>({
userName: { type: 'string' },
email: { type: 'string' },
age: { type: 'int', optional: true },
tags: { type: 'array', optional: true },
birthday: { type: 'datetime', optional: true },
unknownNotAllowed: {} // this should give a ts error
});
const User = gstore.model<UserTypes>('User', schema);
// Strict typings + other properties allowed (explicitOnly: false)
// ----------------------------------------------------------------------------------
const schema = new Schema<UserTypes>({
userName: { type: 'string' },
email: { type: 'string' },
age: { type: 'int', optional: true },
tags: { type: 'array', optional: true },
birthday: { type: 'datetime', optional: true },
unknownNotAllowed: {} // this should give a ts error
}, { explicitOnly: false });
// Allow "other" properties on the entities
const User = gstore.model<UserTypes & {[propName: string]: any}>('User', schema);
// No Tyings on Schemas (backward compatible)
// ----------------------------------------------------------------------------------
const schema = new Schema({
userName: { type: 'string' },
email: {},
age: {},
tags: {},
birthday: {},
unknownAllowed: {} // this should *not* give a ts error
}, { explicitOnly: false });
const User = gstore.model('User', schema);
from gstore-node.
Great, thanks! I'll get back when we actually try and start using it. But good to know that we have types now!
from gstore-node.
Related Issues (20)
- query filter on nested property value. HOT 5
- tsc error: Could not find a declaration file for module 'nsql-cache' HOT 3
- could not get data filter by entity key
- Support for @google-cloud/datastore version 5 HOT 2
- Support for custom validators (AJV)
- bulk insert? HOT 2
- Cannot read property 'Symbol(KEY)' when body is null or undefined HOT 1
- Typescript Compile Error HOT 2
- Support for HABTM
- Could not find gstore instance with id "${id}" HOT 2
- How to validate a value agains another property? HOT 1
- Datastore Key type error when using cache HOT 7
- Update method doesn't clear cache HOT 6
- Add Transaction support to `findOne` option HOT 1
- Support filtering for a missing optional property. HOT 1
- New query operators HOT 1
- @google-cloud/datastore version 7 support HOT 1
- could not get data filter by entity key HOT 1
- Migrate Travis CI builds to Circle CI
- Gstore node 7.2.8 TypeError: OptionalDataloader is not a constructor HOT 1
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 gstore-node.