e 2 months ago
parent
commit
7d087f8696

+ 0 - 3
14.ts/3.编辑选项/dist/hi

@@ -1,3 +0,0 @@
-console.log('第一部分');
-let a = '12';
-a = 3;

+ 11 - 0
14.ts/3.编辑选项/dist/index.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script src="./part2.js"></script>
+</body>
+</html>

+ 5 - 0
14.ts/3.编辑选项/dist/part1.js

@@ -0,0 +1,5 @@
+console.log('第一部分');
+let a;
+a = 12;
+a = true;
+a = '111';

+ 14 - 0
14.ts/3.编辑选项/dist/part2.js

@@ -0,0 +1,14 @@
+import { flower } from './part3';
+let h;
+function fn1(x, y) {
+    console.log(x + y);
+}
+fn1(12, 2);
+console.log(flower, '哈哈哈');
+var box = document.getElementById("box");
+box === null || box === void 0 ? void 0 : box.addEventListener('click', () => {
+    console.log("点击了");
+});
+function fn2(aa) {
+}
+fn2("你好");

+ 1 - 0
14.ts/3.编辑选项/dist/part3.js

@@ -0,0 +1 @@
+export const flower = '槐花';

+ 2 - 0
14.ts/3.编辑选项/src/a/hi.js

@@ -0,0 +1,2 @@
+console.log("你好",a)
+let a = 12;

+ 5 - 3
14.ts/3.编辑选项/src/a/part1.ts

@@ -1,7 +1,9 @@
 console.log('第一部分')
-let  a  = '12'
-a = 3;
-
+let a:any;
+a = 12;
+a = true;
+a = '111';
+// a = 3;
 // 你真好看
 // document.getElementById
 // docum

+ 19 - 0
14.ts/3.编辑选项/src/a/part2.ts

@@ -0,0 +1,19 @@
+import {flower} from './part3'
+let h;
+
+function fn1(x:number,y:number) {
+    console.log(x+y);
+}
+fn1(12,2)
+console.log(flower,'哈哈哈')
+var box = document.getElementById("box");
+
+box?.addEventListener('click',()=>{
+    console.log("点击了")
+})
+
+function fn2(aa:string) {
+    
+//    return console.log(this,aa)
+}
+fn2("你好")

+ 1 - 0
14.ts/3.编辑选项/src/a/part3.ts

@@ -0,0 +1 @@
+export const flower = '槐花';

+ 20 - 3
14.ts/3.编辑选项/tsconfig.json

@@ -19,21 +19,38 @@
     // 继承 extends
     // 文件 files
     "compilerOptions": {
+        "moduleResolution": "Node",
         // 规定ts转js使用哪个js的版本
         //  'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'es2024', 'esnext'.
         "target": "ES2015",
         // 模块  "CommonJS", "AMD", "System", "UMD", "ES6", "ES2015", "ES2020", "ESNext", "None", "ES2022", "Node16", "Node18", "NodeNext", "Preserve"
-        "module": "System",
+        "module": "ES2015",
         // lib 规定允许使用什么库
         "lib": ["dom"],
         // 规定将编译后的文件具体放到哪个位置
         "outDir": "./dist",
         // 规定将编译后的文件具体放到哪一个文件下
-        "outFile": "./dist/hi",
+        // "outFile": "./dist/hi",
         // 移除所有的注释
         "removeComments": true,
         // 规定文件是否允许报错编译
-        "noEmitOnError": false
+        "noEmitOnError": false,
+        // 允许编译js文件
+        // "allowJs": true,
+        // // 检查js文件是否符合规范
+        // "checkJs": true,
+        // 规定文件是否允许被编译
+        "noEmit": false,
+        // 开启严格模式
+        // "strict": true
+        // 不允许默认的数据类型是any
+        // "noImplicitAny": true,
+        // // 编译后的文件是否按照严格模式
+        // "alwaysStrict": true,
+        // // 检查是否为空
+        // "strictNullChecks": true,
+        // // 规定是否允许使用this
+        // "noImplicitThis": true 
 
 
     }