Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No TypeScript definitions for Observable / Syncable #213

Closed
oising opened this issue Mar 29, 2016 · 12 comments
Closed

No TypeScript definitions for Observable / Syncable #213

oising opened this issue Mar 29, 2016 · 12 comments
Labels

Comments

@oising
Copy link

oising commented Mar 29, 2016

I tried to generate .d.ts files with the compiler after feeding it the es6 source, but it didn't come up with anything remotely logical. Any plans to release some definitions?

@dfahlander
Copy link
Collaborator

I would like to do that if there were time. Now i've spent too much time on Dexie the last weeks and need to focus on my main project (which is using observable/syncable though).

I think Dexie.d.ts would have to be adjusted some way (maybe changed Dexie from class to interface with acompanied new() function, like Table and the other classes are defined to be extendable) in order for the addons to put new methods etc on its generated instances. It would be something like:

declare var Dexie : new()=>IDexie;

But I havent tested that it's still possible to derive a subclass when doing so. When that's done, d.ts files could be added for the addons. For Dexie.Observable this would be almost nothing. For Syncable, a few methods (https://github.com/dfahlander/Dexie.js/wiki/Dexie.Syncable.js)

@dfahlander
Copy link
Collaborator

For now, just cast to any:

(Dexie as any).Syncable.registerSyncProtocol (name, instance);

@dfahlander
Copy link
Collaborator

If you for some reason felt very much like fixing this, your pull requests are much welcome :)

@oising
Copy link
Author

oising commented Mar 29, 2016

@dfahlander Hehe... sure, I'm already using a cast to <any> -- I was hoping perhaps you might have something. If I get around to creating some, I will surely send you a PR. Thanks!

@oising
Copy link
Author

oising commented Mar 29, 2016

@dfahlander One thing that I'll definitely submit back to you is a SignalR transport. I've figured out a design based on the EventAggregatorProxy and a server-side (c#) implementation of Caliburn.Micro.EventAggregator that can dispatch to a data store adapter. Once it's baked enough to share, I'll send you a PR.

@oising
Copy link
Author

oising commented Mar 29, 2016

I've also noticed that the tsc compiler doesn't pick up the typings in the package unless I'm using node module resolution and if I'm using NPM only. I am tracking some other github issues and bugs that are currently blocking this from working in jspm -- it appears you're doing everything right; it's just the module resolution in tsc that doesn't work with jspm yet... just an FYI :)

@oising
Copy link
Author

oising commented Mar 29, 2016

Oh, and yes -- we'd have to modify your existing dexie.d.ts to use interfaces to allow merging to work. It doesn't work with classes as far as I can tell. I'll see what I can do... you've already done a lot to help me. Thanks again.

@dfahlander
Copy link
Collaborator

Interesting stuff. Thanks for sharing 👍

@cherrydev
Copy link

Typescript 1.8 now allows merging into an existing module scope and in the the example, they specifically demonstrate an existing class Observable<T> and then adding a member to the class by merging in an interface also called Observable<T>. Unless I'm misunderstanding the problem that's described in this issue, this feature should effect what you're trying to do here.

This feature is described here under the heading "Augmenting global/module scope from modules" (why no anchor tags, MS??)

@dfahlander
Copy link
Collaborator

Very interesting info. Thanks!

@dfahlander
Copy link
Collaborator

They've removed the typescript release notes. New location:
Augmenting global/module scope from modules.

dfahlander added a commit that referenced this issue Dec 16, 2016
Implemented Dexie.d.ts so that addons can extend events and API with Typescript 2.1 (See #213).

Made a d.ts file for dexie-observable that does extend the dexie typings according to its API. Next step will be to implement d.ts also for dexie-syncable.
dfahlander added a commit that referenced this issue Dec 16, 2016
* Made dexie typings extendable by addons.
Implemented Dexie.d.ts so that addons can extend events and API with Typescript 2.1 (See #213).

Made a d.ts file for dexie-observable that does extend the dexie typings according to its API. Next step will be to implement d.ts also for dexie-syncable.
@dfahlander
Copy link
Collaborator

Addons now have typings in Dexie 2.0.0-beta-7. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants