mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge pull request #25895 from screendriver/loadjs
Add definitons for loadjs
This commit is contained in:
34
types/loadjs/index.d.ts
vendored
Normal file
34
types/loadjs/index.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Type definitions for loadjs 3.5
|
||||
// Project: https://github.com/muicss/loadjs
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
export as namespace loadjs;
|
||||
|
||||
export = loadjs;
|
||||
|
||||
declare function loadjs(files: string | string[], bundleIdOrLoaded: string | loadjs.LoadedFn): void;
|
||||
declare function loadjs(files: string[], bundleId: string, optionsOrCallback: loadjs.LoadOptions | loadjs.LoadedFn): void;
|
||||
|
||||
declare namespace loadjs {
|
||||
type LoadedFn = () => void;
|
||||
|
||||
interface LoadOptions {
|
||||
before?(path: string, scriptEl: string): void;
|
||||
success?(): void;
|
||||
error?(depsNotFound: string): void;
|
||||
async?: boolean;
|
||||
numRetries?: number;
|
||||
}
|
||||
|
||||
interface ReadyOptions {
|
||||
success?(): void;
|
||||
error?(depsNotFound: string): void;
|
||||
}
|
||||
|
||||
function ready(bundleIds: string | string[], optionsOrCallback: ReadyOptions | LoadedFn): typeof loadjs;
|
||||
function isDefined(bundleId: string): boolean;
|
||||
function done(bundleId: string): void;
|
||||
function reset(): void;
|
||||
}
|
||||
23
types/loadjs/test/loadjs-tests.ts
Normal file
23
types/loadjs/test/loadjs-tests.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import importedLoadJs = require('loadjs');
|
||||
|
||||
const loadOptions: importedLoadJs.LoadOptions = {
|
||||
before: (path, scriptEl) => {},
|
||||
success: () => {},
|
||||
error: (pathsNotFound) => {},
|
||||
async: true,
|
||||
numRetries: 3
|
||||
};
|
||||
|
||||
const readyOptions: importedLoadJs.ReadyOptions = {
|
||||
success: () => {},
|
||||
error: (depsNotFound) => {},
|
||||
};
|
||||
|
||||
importedLoadJs('/path/to/foo.js', () => {});
|
||||
importedLoadJs(['/path/to/foo.js', '/path/to/bar.js'], () => {});
|
||||
importedLoadJs(['/path/to/foo.js', '/path/to/bar.js'], 'foobar');
|
||||
importedLoadJs.ready('foobar', () => {}).ready('foobar', () => {});
|
||||
importedLoadJs.ready(['foo', 'bar'], () => {}).ready(['foo', 'bar'], () => {});
|
||||
importedLoadJs.isDefined('foobar');
|
||||
importedLoadJs(['/path/to/foo.js', '/path/to/bar.js'], 'foobar', loadOptions);
|
||||
importedLoadJs.ready('foobar', readyOptions);
|
||||
17
types/loadjs/test/loadjs-umd-tests.ts
Normal file
17
types/loadjs/test/loadjs-umd-tests.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
loadjs('/path/to/foo.js', () => {});
|
||||
loadjs(['/path/to/foo.js', '/path/to/bar.js'], () => {});
|
||||
loadjs(['/path/to/foo.js', '/path/to/bar.js'], 'foobar');
|
||||
loadjs.ready('foobar', () => {}).ready('foobar', () => {});
|
||||
loadjs.ready(['foo', 'bar'], () => {}).ready(['foo', 'bar'], () => {});
|
||||
loadjs.isDefined('foobar');
|
||||
loadjs(['/path/to/foo.js', '/path/to/bar.js'], 'foobar', {
|
||||
before: (path, scriptEl) => {},
|
||||
success: () => {},
|
||||
error: (pathsNotFound) => {},
|
||||
async: true,
|
||||
numRetries: 3
|
||||
});
|
||||
loadjs.ready('foobar', {
|
||||
success: () => {},
|
||||
error: (depsNotFound) => {},
|
||||
});
|
||||
24
types/loadjs/tsconfig.json
Normal file
24
types/loadjs/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/loadjs-tests.ts",
|
||||
"test/loadjs-umd-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/loadjs/tslint.json
Normal file
1
types/loadjs/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user