Kaynağa Gözat

feat(ts) migrate ScriptUtil to TS

dev0
Naman Jain 9 ay önce
ebeveyn
işleme
e7bed00e84
No account linked to committer's email address
1 değiştirilmiş dosya ile 19 ekleme ve 9 silme
  1. 19
    9
      modules/util/ScriptUtil.ts

modules/util/ScriptUtil.js → modules/util/ScriptUtil.ts Dosyayı Görüntüle

@@ -1,7 +1,16 @@
1
-const currentExecutingScript = require('current-executing-script');
1
+import currentExecutingScript from 'current-executing-script';
2 2
 
3 3
 /* eslint-disable max-params */
4 4
 
5
+export interface ILoadScriptOptions {
6
+    async: boolean;
7
+    errorCallback?: () => void;
8
+    loadCallback?: () => void;
9
+    prepend: boolean;
10
+    relativeURL: boolean;
11
+    src: string;
12
+}
13
+
5 14
 /**
6 15
  * Implements utility functions which facilitate the dealing with scripts such
7 16
  * as the download and execution of a JavaScript file.
@@ -22,13 +31,14 @@ const ScriptUtil = {
22 31
      * @param loadCallback on load callback function
23 32
      * @param errorCallback callback to be called on error loading the script
24 33
      */
25
-    loadScript(
26
-            src,
27
-            async,
28
-            prepend,
29
-            relativeURL,
30
-            loadCallback,
31
-            errorCallback) {
34
+    loadScript({
35
+        src,
36
+        async,
37
+        prepend,
38
+        relativeURL,
39
+        loadCallback,
40
+        errorCallback
41
+    }: ILoadScriptOptions): void {
32 42
         const d = document;
33 43
         const tagName = 'script';
34 44
         const script = d.createElement(tagName);
@@ -71,4 +81,4 @@ const ScriptUtil = {
71 81
 
72 82
 /* eslint-enable max-params */
73 83
 
74
-module.exports = ScriptUtil;
84
+export default ScriptUtil;

Loading…
İptal
Kaydet