Feathers: Add typescript definitions

Created on 16 May 2014  ·  20Comments  ·  Source: feathersjs/feathers

Has anyone asked for Typescript definitions or tried using feathers with Typescript? I'm tempted to make them but unsure if they're actually wanted.

Documentation Help Wanted

All 20 comments

Not that I am aware of. If you wanted to add definitions that would be great. I personally haven't done much Typescript if you want to submit an example we'll definitely add it to the readme.

Closing for now due to inactivity on this subject. I'm also not much of a typescript user. Will reopen if it becomes a more requested feature.

Typescript is now a pretty solid product. Having typings for feathers would be nice.

@talensjr Maybe interested to help out? :)

It will definitely need to be community driven. No one on the core team currently uses Typescript. If someone wants to take on the challenge I'll re-open the issue and we can slot it into a milestone.

Yes I would like to help, I don't know how much time can I spend on it right now, but sure I will try to help out

Ok re-opening and renaming. @omeid and @talensjr I'm going to pass the baton to you guys on this.

I will try to give this a crack and see how it goes.

This may be fairly quick to add to https://github.com/DefinitelyTyped/DefinitelyTyped. It can probably just extend the Express definitions from the same repository and then add the definitions for the API. It probably also makes sense to add definitions for the service interface.

I just added this to the next release which is currently set for July 15th. @omeid please let me know if you or anybody else can take this on until then.

Hi @daffl,

Unfortunately I am pretty caught up with work and can't look into this any time soon.

I'm going to leave this open and on the milestone until it gets closer to the release date in case anybody else is interested in picking this up. It seems to be fairly doable for anybody familiar with TypeScript interfaces.

Of course we will do everything we can to help anybody who would like to contribute TypeScript definitions but I am going to close this issue since it does not look like anybody is going to pick it up.

I'd really like to have this as well, because webstorm can't analyse the package
this is probably because of your bundling with babel
webstorm says that i.e. app.configure is an undefined function

looking for community stubs http://definitelytyped.org/

I'm not using Typescript itself, but it's still annoying to have everything underlined

Bundling with Babel shouldn't really make a difference. Maybe it can't statically analyze it because of the way it is added to the app. Webstorm usually also takes JSDocs into consideration (which we don't publish either though).

Either way, the open issue for TypeScript definitions is https://github.com/feathersjs/feathers/issues/381. Apparently making TypeScript definitions is really really hard because everybody keeps asking for them but nobody seems to be able to actually make it happen :trollface:

The issue is that maintaining them requires keeping the definitions and the code base in sync which is not always obvious.

@daffl write typescript definitions is hard, because this is:

A way of making explicit what is implicit.

I had to study a lot of source code and documentation to make this:#381

How I can program with typescript in featherjs?

Here's part of a Slack discussion:

alehn [11:56 AM]
it's possible feathers with typescript?

smixx
[12:11 PM]
https://github.com/feathersjs/feathers-typescript, none of us on the core team use TypeScript so they are maintained by the community

alehn [12:28 PM]
how use typescript?

harmony
[12:31 PM]
wait, do you want to use feathers with typescript but don't know how typescript works?

alehn [12:36 PM]
yes I know with typescript work , That's why I'm asking how I programn in feathers with ts

[12:37]
or I have to program with es6 obligatory

eddyystop
[12:39 PM]
@alehn .d.ts files are fundamental to TypeScript https://blog.mariusschulz.com/2014/05/19/using-typescripts-type-definition-files-to-get-tooling-support-for-plain-javascript#utilizing-type-definition-files-for-plain-javascript
Marius Schulz
Using TypeScript's Type Definition Files to Get Tooling Support for Plain JavaScript
TypeScript's type definition files are great to describe the public interface of JavaScript libraries. Here's how you can use them to get autocompletion and documentation for plain JavaScript code using Visual Studio and ReSharper.
May 19th, 2014 at 7:17 PM

(edited)

[12:40]
There is a whole ecosystem for them https://github.com/DefinitelyTyped/DefinitelyTyped

alehn [12:40 PM]
somewhere is using typescript in feathers? .ts

alehn [12:51 PM]
I use angular 4 for frontend and I need use feather for backend for web service but I have programming with ts and I dont want put js

eddyystop
[12:52 PM]
Your choice then is using the .d.ts. It is a perfectly satisfactory, perfectly accepted way to use TypeScript. Hundreds of packages are delivered like this.

[12:54]
I assume you will have inline TypeScript definitions for your own code, so you'll have to run a build step before executing your server code. (edited)

alehn [1:00 PM]
no I use webpack

[1:01]
I programing in ts only

bazaglia [1:36 PM]
joined #general

j2l4e [1:38 PM]
@alehn the current ts definitions are a work in progress. If you want everything to just work, delete any *.d.ts files in node-modules/feathers* and put declare module feathers; declare module feathers-*; in your typings.d.ts file. It doesn't get you intellisense, but makes it work (edited)

[1:39]
how do you escape the asterisk in markdown?

teddy-error [1:40 PM]
what's wrong with ur askterisks * * *

alehn [1:40 PM]
thanks

j2l4e [1:41 PM]
if you are into fiddling... the typings generally work, but there may be some packages that would need you to remove their definitions and put a wildcard definition in place

[1:42]
so you can try out what works for you

[1:43]
That aside, you should have a look at typescripts 'allowJS' setting, that was introduced recently. It should allow you to work with TS and JS files side-by-side regardless of the availability of definitions

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings