From 0336e9c74991129516aa9a19ba937ae5938db694 Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 16:15:40 -0700 Subject: [PATCH 01/10] added type def for scriptjs https://github.com/ded/script.js --- scriptjs/scriptjs.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 scriptjs/scriptjs.d.ts diff --git a/scriptjs/scriptjs.d.ts b/scriptjs/scriptjs.d.ts new file mode 100644 index 0000000000..074633fc8f --- /dev/null +++ b/scriptjs/scriptjs.d.ts @@ -0,0 +1,12 @@ +interface $script { + (paths:string | string[], idOrDone:string | (() => void), optDone?:() => void): $script; + get(path:string, fn:() => void); + order(scripts:string[], id:string, done:() => void); + path(p:string); + urlArts(str:string); + ready(deps:string | string[], ready:() => void, req?:(missing:string[]) => void): $script; +} + +declare var $script: $script; + +export = $script; From e73fdc130f4594e7af6cc5e39389cd2dd1aae649 Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 16:33:32 -0700 Subject: [PATCH 02/10] fixed implicit return types --- scriptjs/scriptjs.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scriptjs/scriptjs.d.ts b/scriptjs/scriptjs.d.ts index 074633fc8f..b11e7d375a 100644 --- a/scriptjs/scriptjs.d.ts +++ b/scriptjs/scriptjs.d.ts @@ -1,9 +1,9 @@ interface $script { (paths:string | string[], idOrDone:string | (() => void), optDone?:() => void): $script; - get(path:string, fn:() => void); - order(scripts:string[], id:string, done:() => void); - path(p:string); - urlArts(str:string); + get(path:string, fn:() => void): void; + order(scripts:string[], id:string, done:() => void): void; + path(p:string): void; + urlArts(str:string): void; ready(deps:string | string[], ready:() => void, req?:(missing:string[]) => void): $script; } From 57b7904945e87dc732d5691a60ec90214aba83f4 Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 16:47:24 -0700 Subject: [PATCH 03/10] typo --- scriptjs/scriptjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scriptjs/scriptjs.d.ts b/scriptjs/scriptjs.d.ts index b11e7d375a..fd3ea76ab3 100644 --- a/scriptjs/scriptjs.d.ts +++ b/scriptjs/scriptjs.d.ts @@ -3,7 +3,7 @@ interface $script { get(path:string, fn:() => void): void; order(scripts:string[], id:string, done:() => void): void; path(p:string): void; - urlArts(str:string): void; + urlArgs(str:string): void; ready(deps:string | string[], ready:() => void, req?:(missing:string[]) => void): $script; } From 9dfc17e21bcd8a7356085cf5a3c3f2946b138b3c Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 16:47:53 -0700 Subject: [PATCH 04/10] added scriptjs tests --- scriptjs/scriptjs-tests.ts | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 scriptjs/scriptjs-tests.ts diff --git a/scriptjs/scriptjs-tests.ts b/scriptjs/scriptjs-tests.ts new file mode 100644 index 0000000000..be7f393b4d --- /dev/null +++ b/scriptjs/scriptjs-tests.ts @@ -0,0 +1,39 @@ +/// + +import $script = require("scriptjs"); + +const callback = () => console.log('done'); + +function main(): void { + $script('foo.js', callback); + $script(['foo.js', 'bar.js'], callback); + + $script('foo.js', 'foo', callback); + $script(['foo.js', 'bar.js'], 'bundle', callback); + + $script('foo', callback); + $script('bundle', callback); + + $script.ready('foo', callback); + $script.ready('bundle', callback); + + const deps = { + foo: 'foo.js', + bar: 'bar.js', + thunk: ['thunkor.js', 'thunky.js'], + }; + + $script.ready(['foo', 'bar', 'thunk'], callback, (missing: string[]) => { + missing.forEach((dep: string) => { + $script(deps[dep], dep); + }); + }); + + $script.path('/js/modules/'); + + $script.get('http://example.com/base.js', callback); + + $script.urlArgs('key=value&foo=bar'); + + $script.order(['foo.js', 'bar.js'], 'bundle', callback); +} From 45ff6e7ac743f962556d02bfc1b6de90ac1a0369 Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 16:55:35 -0700 Subject: [PATCH 05/10] added meta data --- scriptjs/scriptjs.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scriptjs/scriptjs.d.ts b/scriptjs/scriptjs.d.ts index fd3ea76ab3..7dd1ad304b 100644 --- a/scriptjs/scriptjs.d.ts +++ b/scriptjs/scriptjs.d.ts @@ -1,3 +1,8 @@ +// Type definitions for scriptjs +// Project: https://github.com/ded/script.js +// Definitions by: ssttevee +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + interface $script { (paths:string | string[], idOrDone:string | (() => void), optDone?:() => void): $script; get(path:string, fn:() => void): void; From bc62f69d28ad8729f0e1c3e798f82303d493e6e7 Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 16:57:23 -0700 Subject: [PATCH 06/10] explicit return type --- scriptjs/scriptjs-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scriptjs/scriptjs-tests.ts b/scriptjs/scriptjs-tests.ts index be7f393b4d..027298891e 100644 --- a/scriptjs/scriptjs-tests.ts +++ b/scriptjs/scriptjs-tests.ts @@ -2,7 +2,7 @@ import $script = require("scriptjs"); -const callback = () => console.log('done'); +const callback = (): void => console.log('done'); function main(): void { $script('foo.js', callback); @@ -23,8 +23,8 @@ function main(): void { thunk: ['thunkor.js', 'thunky.js'], }; - $script.ready(['foo', 'bar', 'thunk'], callback, (missing: string[]) => { - missing.forEach((dep: string) => { + $script.ready(['foo', 'bar', 'thunk'], callback, (missing: string[]): void => { + missing.forEach((dep: string): void => { $script(deps[dep], dep); }); }); From 121f3f13452775c6f4aa651ecaba124c13334c7c Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 17:02:42 -0700 Subject: [PATCH 07/10] Update scriptjs.d.ts --- scriptjs/scriptjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scriptjs/scriptjs.d.ts b/scriptjs/scriptjs.d.ts index 7dd1ad304b..c0bf3d0c6d 100644 --- a/scriptjs/scriptjs.d.ts +++ b/scriptjs/scriptjs.d.ts @@ -1,6 +1,6 @@ // Type definitions for scriptjs // Project: https://github.com/ded/script.js -// Definitions by: ssttevee +// Definitions by: Steve Lam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface $script { From 251049a5e9b0a7fca462ea8abbc0a42c4031a582 Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 17:04:58 -0700 Subject: [PATCH 08/10] changed import statement --- scriptjs/scriptjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scriptjs/scriptjs-tests.ts b/scriptjs/scriptjs-tests.ts index 027298891e..3dbcbea3ac 100644 --- a/scriptjs/scriptjs-tests.ts +++ b/scriptjs/scriptjs-tests.ts @@ -1,6 +1,6 @@ /// -import $script = require("scriptjs"); +import * as $script from 'scriptjs'; const callback = (): void => console.log('done'); From afd81057b25c9c6931ea909d05829bb4035bfe4a Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sun, 7 Aug 2016 17:09:42 -0700 Subject: [PATCH 09/10] Update scriptjs-tests.ts --- scriptjs/scriptjs-tests.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scriptjs/scriptjs-tests.ts b/scriptjs/scriptjs-tests.ts index 3dbcbea3ac..4da747c978 100644 --- a/scriptjs/scriptjs-tests.ts +++ b/scriptjs/scriptjs-tests.ts @@ -17,17 +17,7 @@ function main(): void { $script.ready('foo', callback); $script.ready('bundle', callback); - const deps = { - foo: 'foo.js', - bar: 'bar.js', - thunk: ['thunkor.js', 'thunky.js'], - }; - - $script.ready(['foo', 'bar', 'thunk'], callback, (missing: string[]): void => { - missing.forEach((dep: string): void => { - $script(deps[dep], dep); - }); - }); + $script.ready(['foo', 'bar', 'thunk'], callback, (missing: string[]): void => console.log('missing deps:', missing)); $script.path('/js/modules/'); From 78d7ae624db6de4963223b5c56d205602c674c65 Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Fri, 19 Aug 2016 12:36:24 -0700 Subject: [PATCH 10/10] export scriptjs module --- scriptjs/scriptjs.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scriptjs/scriptjs.d.ts b/scriptjs/scriptjs.d.ts index c0bf3d0c6d..aa76b4517c 100644 --- a/scriptjs/scriptjs.d.ts +++ b/scriptjs/scriptjs.d.ts @@ -1,6 +1,6 @@ // Type definitions for scriptjs // Project: https://github.com/ded/script.js -// Definitions by: Steve Lam +// Definitions by: Steve Lam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface $script { @@ -12,6 +12,7 @@ interface $script { ready(deps:string | string[], ready:() => void, req?:(missing:string[]) => void): $script; } -declare var $script: $script; - -export = $script; +declare module 'scriptjs'{ + var $script: $script; + export = $script; +}