zheng 1 Minggu lalu
induk
melakukan
93cbdc35eb

+ 4 - 4
ts/3.编译选项/dist/a.js

@@ -1,6 +1,6 @@
 console.log("你好");
 let a = 12;
-// document.getElementById
-// document.getE
-// docume
-// document.
+var box = document.getElementById("box");
+box.addEventListener("click", function () {
+    console.log("haha");
+});

+ 0 - 12
ts/3.编译选项/dist/app.js

@@ -1,12 +0,0 @@
-console.log("你好");
-let a = 12;
-// document.getElementById
-// document.getE
-// docume
-// document.
-console.log("哈哈哈");
-let a1 = 12121;
-// document.getElementById
-// document.getE
-// docume
-// document.

+ 10 - 0
ts/3.编译选项/dist/b.js

@@ -0,0 +1,10 @@
+console.log("哈哈哈");
+let a1 = 12121;
+let cc;
+cc = 12;
+cc = '111';
+console.log(cc);
+function fn5(x, y) {
+    return x + y;
+}
+fn5(1, '77');

+ 2 - 0
ts/3.编译选项/dist/hello.js

@@ -0,0 +1,2 @@
+console.log("哈哈哈哈哈");
+let x = 12;

+ 5 - 0
ts/3.编译选项/src/a.ts

@@ -1,5 +1,10 @@
 console.log("你好")
 let a = 12;
+// console.log(awq);
+var box = document.getElementById("box");
+box.addEventListener("click",function(){
+    console.log("haha")
+})
 // document.getElementById
 // document.getE
 // docume

+ 9 - 1
ts/3.编译选项/src/b.ts

@@ -3,4 +3,12 @@ let a1 = 12121;
 // document.getElementById
 // document.getE
 // docume
-// document.
+// document.
+let cc:any;
+cc=12;
+cc='111'
+console.log(cc)
+function fn5(x:number,y:any){
+    return x + y;
+}
+fn5(1,'77')

+ 7 - 0
ts/3.编译选项/src/hello.js

@@ -0,0 +1,7 @@
+console.log("哈哈哈哈哈")
+let x = 12;
+// console.log(x1);
+// function fn1() {
+//     return;
+//     // console.log("12")
+// }

+ 12 - 2
ts/3.编译选项/tsconfig.json

@@ -28,10 +28,20 @@
         // 'esnext', 'node16', 'node18', 'nodenext', 'preserve
         "module": "amd",
         // lib 规定ts可以使用什么库
-        "lib": ["dom"],
+        // "lib": ["dom"],
         // 指定编译后文件所在目录
         "outDir": "./dist",
         // 指定所有文件编译后的合并文件
-        "outFile": "./dist/app.js",
+        // "outFile": "./dist/app.js",
+        // 允许编译js文件
+        "allowJs": true,
+        // 检查js是否存在报错
+        "checkJs": true,
+        // 移除注释
+        "removeComments": true,
+        // 是否允许错误文件编译
+        // "noEmitOnError": true,
+        // 不允许数据的默认类型是any
+        "noImplicitAny": true
     }
 }