1 | // Type definitions for SystemJS 6.1
|
2 | // Project: https://github.com/systemjs/systemjs
|
3 | // Definitions by: Joel Denning <https://github.com/joeldenning>
|
4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 | // TypeScript Version: 3.5
|
6 |
|
7 | declare const System: {
|
8 | /**
|
9 | * Loads a javascript module from either a url or bare specifier that is in an import map.
|
10 | * You may optionally provide a parentUrl that will be used for resolving relative urls.
|
11 | */
|
12 | import: System.ImportFn;
|
13 |
|
14 | /**
|
15 | * Inserts a new module into the SystemJS module registry. The System.register format is
|
16 | * the underlying implementation that allows for ESM emulation.
|
17 | * See https://github.com/systemjs/systemjs/blob/master/docs/system-register.md for more details.
|
18 | * Register may be called with a name argument if you are using the named-register extra. (See
|
19 | * https://github.com/systemjs/systemjs#extras).
|
20 | */
|
21 | register(dependencies: string[], declare: System.DeclareFn): void;
|
22 | register(name: string, dependencies: string[], declare: System.DeclareFn): void;
|
23 |
|
24 | /**
|
25 | * Resolve any moduleId to its full URL. For a moduleId that is in the import map, this will resolve
|
26 | * the full import map URL. For a moduleId that is a relative url, the returned url will be resolved
|
27 | * relative to the parentUrl or the current browser page's base url. For a full url, resolve() is
|
28 | * a no-op.
|
29 | */
|
30 | resolve(moduleId: string, parentUrl?: string): string;
|
31 |
|
32 | /**
|
33 | * Delete a module from the module registry. Note that the moduleId almost always must be a full url and that
|
34 | * you might need to call System.resolve() to obtain the moduleId for modules in an import map.
|
35 | * The returned function is intended for use after re-importing the module. Calling the function
|
36 | * will re-bind all the exports of the re-imported module to every module that depends on the module.
|
37 | */
|
38 | delete(moduleId: string): false | System.UpdateModuleFn;
|
39 |
|
40 | /**
|
41 | * Get a module from the SystemJS module registry. Note that the moduleId almost always must be a full url
|
42 | * and that you might need to call System.resolve() to obtain the moduleId. If the module does not exist in
|
43 | * the registry, null is returned.
|
44 | */
|
45 | get(moduleId: string): System.Module | null;
|
46 | // tslint:disable-next-line no-unnecessary-generics
|
47 | get<T>(moduleId: string): T | null;
|
48 |
|
49 | /**
|
50 | * Indicates whether the SystemJS module registry contains a module. Note that the moduleId almost always
|
51 | * must be a full url and that you might need to call System.resolve() to obtain the moduleId.
|
52 | */
|
53 | has(moduleId: string): boolean;
|
54 |
|
55 | /**
|
56 | * An alternative to System.register(), this allows you to insert a module into the module registry. Note that
|
57 | * the moduleId you provide will go straight into the registry without being resolved first.
|
58 | */
|
59 | set(moduleId: string, module: System.Module): void;
|
60 |
|
61 | /**
|
62 | * Use for (let entry of System.entries()) to access all of the modules in the SystemJS registry.
|
63 | */
|
64 | entries(): Iterable<[string, System.Module]>;
|
65 | };
|
66 |
|
67 | declare namespace System {
|
68 | // tslint:disable-next-line no-unnecessary-generics
|
69 | type ImportFn = <T extends Module>(moduleId: string, parentUrl?: string) => Promise<T>;
|
70 |
|
71 | type DeclareFn = (_export: ExportFn, _context: Context) => Declare;
|
72 | interface Declare {
|
73 | setters?: SetterFn[];
|
74 | execute?(): any;
|
75 | }
|
76 | type SetterFn = (moduleValue: Module) => any;
|
77 | type ExecuteFn = () => any;
|
78 |
|
79 | interface ExportFn {
|
80 | (exportName: string, value: any): void;
|
81 | (exports: object): void;
|
82 | }
|
83 |
|
84 | type UpdateModuleFn = () => void;
|
85 |
|
86 | type GetFn = GetFnModule | GetFnGeneric;
|
87 | type GetFnModule = (moduleId: string) => Module;
|
88 | // tslint:disable-next-line no-unnecessary-generics
|
89 | type GetFnGeneric = <T>(moduleId: string) => T;
|
90 |
|
91 | interface Context {
|
92 | import: ImportFn;
|
93 | meta: {
|
94 | url: string;
|
95 | };
|
96 | }
|
97 |
|
98 | interface Module {
|
99 | default?: any;
|
100 | [exportName: string]: any;
|
101 | }
|
102 | }
|