inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 26, 2016 15:04:39 GMT -8
Any chance anyone uses typescript to develop plugs and has a types file for all the proboards functions?
|
|
inherit
226544
0
Oct 5, 2018 10:29:39 GMT -8
Ulises
4,881
November 2015
umacklin
Ulises Weirdo
|
Post by Ulises on Nov 26, 2016 15:05:37 GMT -8
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 26, 2016 15:14:49 GMT -8
Ulises, sorry, should have been more clear. I meant a Typescript declaration file: basarat.gitbooks.io/typescript/content/docs/types/ambient/d.ts.htmlTypescript is basically a developing environment for javascrtipt. It forces you do only use defined variables and such. Which is great if your not depending on other resources...like using any built in proboards functions. I'm just wondering if anyone uses Typescript and already has a typescript declaration file.
|
|
inherit
226544
0
Oct 5, 2018 10:29:39 GMT -8
Ulises
4,881
November 2015
umacklin
Ulises Weirdo
|
Post by Ulises on Nov 26, 2016 15:20:15 GMT -8
Oh, I gotchu, my only experience with typescript is in linux (which is completely different still from this ) Reading your link, I see where it would come in handy, neat -- didn't know that existed.
|
|
Former Member
inherit
guest@proboards.com
225992
0
Nov 30, 2024 10:54:13 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Dec 8, 2016 14:26:12 GMT -8
It's straightforward to do, you just need to create an interface that describes each(function/object or property)
Getting the function signatures for proboards would be quite time consuming. You would need to find each function, try to figure out it's argument types(using the debugger) and return type.
You would also need to include jQuery type definition for some of proboards functions, for example: Ajax
The ajax method returns a Jquery Promise(a much earlier implementation of a promise) so you can't just typecast it to a regular Promise.
ajax( options : Object ) : Promise - this would give incorrect type
To start, Add a definitions/ inside your project folder
create a proboards.d.ts file inside the definitions folder and include the following
export interface ProboardsInterface{ // Properties active_ajax_calls : number;
// Functions add_commified_numbers(numbers: Array<number>) : String; ajax( options : Object ) : Object // Objects analytics : {
google: { getClientId() : String, send(options : Array<Object> ) : boolean }
};
// @TODO: implement the rest } In your application file example.ts
import { ProboardsInterface } from './definitions/proboards.d'
declare var proboards : ProboardsInterface
((proboards)=>{
// @TODO
})(proboards) Some older versions of typescript you would need to include a reference at the top of the file also
///<reference path="./definitions/proboards.d.ts" />
I'm not sure I would use typescript with proboards though. A module loader will add a bit of code overhead to your plugin
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Dec 10, 2016 9:30:50 GMT -8
@synthtec, Thanks for the help and advice. The reason I'd like to use it is that it forces me to use better programming techniques and helps avoid weird typecasting errors that I am prone to make. Anyway, I'll probably never get around to putting that much work into getting all of it set up in the first place so, probably just wishful thinking. A good linter is really all I need anyway.
|
|
Former Member
inherit
guest@proboards.com
225992
0
Nov 30, 2024 10:54:13 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Dec 11, 2016 0:04:14 GMT -8
You can get away without any module loader overhead if you don't use any import,export,require statements and just add the proboardsInterface inside your example.ts file.
You would need to add it to all your files, so that could become annoying quickly. The above method will work If you use a good IDE(visual studio code|Atom) and it will give you proper intellisense.
I think "Visual Studio Code" also has a default ES Linter.
|
|