Merge pull request #10505 from ssttevee/master

Add scriptjs type defs
This commit is contained in:
Ryan Cavanaugh
2016-08-30 20:03:16 -07:00
committed by GitHub
2 changed files with 47 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
/// <reference path="scriptjs.d.ts" />
import * as $script from 'scriptjs';
const callback = (): void => 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);
$script.ready(['foo', 'bar', 'thunk'], callback, (missing: string[]): void => console.log('missing deps:', missing));
$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);
}
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for scriptjs
// Project: https://github.com/ded/script.js
// Definitions by: Steve Lam <https://github.com/ssttevee>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface $script {
(paths:string | string[], idOrDone:string | (() => void), optDone?:() => void): $script;
get(path:string, fn:() => void): void;
order(scripts:string[], id:string, done:() => void): void;
path(p:string): void;
urlArgs(str:string): void;
ready(deps:string | string[], ready:() => void, req?:(missing:string[]) => void): $script;
}
declare module 'scriptjs'{
var $script: $script;
export = $script;
}