zheng 2 дней назад
Родитель
Сommit
2bcfd62c6c

+ 1 - 0
19.ts/编译选项/dist/a.js

@@ -1,3 +1,4 @@
+"use strict";
 let a = 12121212;
 console.log(a, 'a');
 // document.getElementById

+ 12 - 6
19.ts/编译选项/dist/b.js

@@ -1,6 +1,12 @@
-let a2 = 222;
-console.log(a2, 'a');
-// document.getElementById
-// document
-// document.getElementById("box").onclick = function
-let a2 = 23;
+"use strict";
+// let a2= 222;
+// console.log(a2,'a');
+// // document.getElementById
+// // document
+// // document.getElementById("box").onclick = function
+// let a2 = 23;
+// let x:string = 12;
+function fn1() {
+    console.log(this);
+}
+fn1();

+ 1 - 0
19.ts/编译选项/dist/c.js

@@ -1,3 +1,4 @@
+"use strict";
 let a1 = 333;
 console.log(a1, 'a');
 // document.getElementById

+ 1 - 1
19.ts/编译选项/index.html

@@ -6,6 +6,6 @@
     <title>Document</title>
 </head>
 <body>
-    <script src="./src/a.js"></script>
+    <script src="./dist/b.js"></script>
 </body>
 </html>

+ 2 - 0
19.ts/编译选项/src/a.ts

@@ -1,3 +1,5 @@
+import {xxxx} from './b';
+console.log(xxxx);
 let a = 12121212;
 console.log(a,'a');
 // document.getElementById

+ 17 - 6
19.ts/编译选项/src/b.ts

@@ -1,6 +1,17 @@
-let a2= 222;
-console.log(a2,'a');
-// document.getElementById
-// document
-// document.getElementById("box").onclick = function
-let a2 = 23;
+// let a2= 222;
+// console.log(a2,'a');
+// // document.getElementById
+// // document
+// // document.getElementById("box").onclick = function
+// let a2 = 23;
+// let x:string = 12;
+// function fn1() {
+//     console.log(this)
+// }
+// fn1()
+function fn2(x:any, y:any) {
+    return x + y
+}
+fn2(1, 2);
+fn2("111", "222");
+export const xxxx = '妹妹';

+ 5 - 2
19.ts/编译选项/src/c.ts

@@ -1,4 +1,7 @@
 let a1 = 333;
 console.log(a1,'a');
-// document.getElementById
-// document
+let box = document.getElementById("box");
+box?.addEventListener("click",function() {
+    console.log("你好")
+})
+// document

+ 14 - 2
19.ts/编译选项/tsconfig.json

@@ -22,6 +22,7 @@
     // "extends": 继承
     // 编译选项
     "compilerOptions": {
+        // "ignoreDeprecations": "6.0",
         // 指定ts编译成哪个js的版本
         //  'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'esnext'.
         "target": "es6",
@@ -41,7 +42,18 @@
         // "removeComments": true
         // 是否对错误进行编译 检查 影响生成
         // "noEmitOnError": false
-        // 是否有报错 只检查 不影响生成
-        "noEmit": true
+        // 只检查 不影响生成 false
+        // 不生成 true
+        // 类型检查出错误 不输出
+        "noEmit": false,
+        "strict": true,
+        // 编译后的文件是否是严格模式
+        "alwaysStrict": true,
+        // 规定是否允许使用this
+        "noImplicitThis": true,
+        // 不允许使用默认类型的any
+        "noImplicitAny": false,
+        "strictNullChecks": true
+
     }
 }