<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      runinrain

      博客園 首頁(yè) 新隨筆 聯(lián)系 訂閱 管理

      TypeScript官網(wǎng)

      1.了解什么是TypeScript?

      你可以理解TS是JS的的一個(gè)超集,通過(guò)編譯成純js來(lái)在瀏覽器等上都可以使用。
      相對(duì)于js而言,ts是一個(gè)強(qiáng)類(lèi)型語(yǔ)言。二者之間的區(qū)別是TypeScript是靜態(tài)類(lèi)型,js是動(dòng)態(tài)類(lèi)型(詳見(jiàn)強(qiáng)類(lèi)型、弱類(lèi)型、靜態(tài)類(lèi)型、動(dòng)態(tài)類(lèi)型的區(qū)別)。
      弱類(lèi)型語(yǔ)言(js)是據(jù)類(lèi)型可以被忽略的語(yǔ)言。它與強(qiáng)類(lèi)型定義語(yǔ)言相反, 一個(gè)變量可以賦不同數(shù)據(jù)類(lèi)型的值。
      強(qiáng)類(lèi)型語(yǔ)言(ts)是強(qiáng)制數(shù)據(jù)類(lèi)型定義的語(yǔ)言。也就是說(shuō),一旦一個(gè)變量被指定了某個(gè)數(shù)據(jù)類(lèi)型,如果不經(jīng)過(guò)強(qiáng)制轉(zhuǎn)換,那么它就永遠(yuǎn)是這個(gè)數(shù)據(jù)類(lèi)型了。
      在開(kāi)發(fā)中,js一般報(bào)錯(cuò)是在控制臺(tái),在開(kāi)發(fā)的過(guò)程不容易發(fā)現(xiàn)錯(cuò)誤。相對(duì)于大型項(xiàng)目,ts具備類(lèi)型檢查,直接編譯到原生js,在開(kāi)發(fā)過(guò)程更容易發(fā)現(xiàn)問(wèn)題,更容易模塊化開(kāi)發(fā)以及避免命名空間發(fā)生浪費(fèi)的情況。

      2.安裝TypeScript

      2.1安裝

      有兩種主要的方式來(lái)獲取TypeScript工具:

      • 通過(guò)npm(Node.js包管理器)
      • 安裝Visual Studio的TypeScript插件

      2.2針對(duì)使用npm的用戶:

      npm install -g typescript

      3.運(yùn)行

      隨意創(chuàng)建一個(gè)后綴為index.ts的文件

      let people = "小明";
      function userTool(person) {
          return person+'使用粉筆寫(xiě)下幾個(gè)字';
      }
      

      在該文件夾下運(yùn)行tsc index.ts,生成一個(gè)index.js文件就算成功了;

      4.tsconfig.json文件配置

      運(yùn)行tsc --init生成一個(gè)tsconfig.json文件,對(duì)tsconfig.json文件進(jìn)行配置
      生成文件如下:

      {
        "compilerOptions": {
          /* Visit https://aka.ms/tsconfig to read more about this file */
      
          /* Projects */
          // "incremental": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
          // "composite": true,                                /* Enable constraints that allow a TypeScript project to be used with project references. */
          // "tsBuildInfoFile": "./.tsbuildinfo",              /* Specify the path to .tsbuildinfo incremental compilation file. */
          // "disableSourceOfProjectReferenceRedirect": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */
          // "disableSolutionSearching": true,                 /* Opt a project out of multi-project reference checking when editing. */
          // "disableReferencedProjectLoad": true,             /* Reduce the number of projects loaded automatically by TypeScript. */
      
          /* Language and Environment */
          "target": "es2016",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
          // "lib": [],                                        /* Specify a set of bundled library declaration files that describe the target runtime environment. */
          // "jsx": "preserve",                                /* Specify what JSX code is generated. */
          // "experimentalDecorators": true,                   /* Enable experimental support for legacy experimental decorators. */
          // "emitDecoratorMetadata": true,                    /* Emit design-type metadata for decorated declarations in source files. */
          // "jsxFactory": "",                                 /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
          // "jsxFragmentFactory": "",                         /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
          // "jsxImportSource": "",                            /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
          // "reactNamespace": "",                             /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
          // "noLib": true,                                    /* Disable including any library files, including the default lib.d.ts. */
          // "useDefineForClassFields": true,                  /* Emit ECMAScript-standard-compliant class fields. */
          // "moduleDetection": "auto",                        /* Control what method is used to detect module-format JS files. */
      
          /* Modules */
          "module": "commonjs",                                /* Specify what module code is generated. */
          // "rootDir": "./",                                  /* Specify the root folder within your source files. */
          // "moduleResolution": "node10",                     /* Specify how TypeScript looks up a file from a given module specifier. */
          // "baseUrl": "./",                                  /* Specify the base directory to resolve non-relative module names. */
          // "paths": {},                                      /* Specify a set of entries that re-map imports to additional lookup locations. */
          // "rootDirs": [],                                   /* Allow multiple folders to be treated as one when resolving modules. */
          // "typeRoots": [],                                  /* Specify multiple folders that act like './node_modules/@types'. */
          // "types": [],                                      /* Specify type package names to be included without being referenced in a source file. */
          // "allowUmdGlobalAccess": true,                     /* Allow accessing UMD globals from modules. */
          // "moduleSuffixes": [],                             /* List of file name suffixes to search when resolving a module. */
          // "allowImportingTsExtensions": true,               /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
          // "resolvePackageJsonExports": true,                /* Use the package.json 'exports' field when resolving package imports. */
          // "resolvePackageJsonImports": true,                /* Use the package.json 'imports' field when resolving imports. */
          // "customConditions": [],                           /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
          // "resolveJsonModule": true,                        /* Enable importing .json files. */
          // "allowArbitraryExtensions": true,                 /* Enable importing files with any extension, provided a declaration file is present. */
          // "noResolve": true,                                /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
      
          /* JavaScript Support */
          // "allowJs": true,                                  /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
          // "checkJs": true,                                  /* Enable error reporting in type-checked JavaScript files. */
          // "maxNodeModuleJsDepth": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
      
          /* Emit */
          // "declaration": true,                              /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
          // "declarationMap": true,                           /* Create sourcemaps for d.ts files. */
          // "emitDeclarationOnly": true,                      /* Only output d.ts files and not JavaScript files. */
          // "sourceMap": true,                                /* Create source map files for emitted JavaScript files. */
          // "inlineSourceMap": true,                          /* Include sourcemap files inside the emitted JavaScript. */
          // "outFile": "./",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
          // "outDir": "./",                                   /* Specify an output folder for all emitted files. */
          // "removeComments": true,                           /* Disable emitting comments. */
          // "noEmit": true,                                   /* Disable emitting files from a compilation. */
          // "importHelpers": true,                            /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
          // "importsNotUsedAsValues": "remove",               /* Specify emit/checking behavior for imports that are only used for types. */
          // "downlevelIteration": true,                       /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
          // "sourceRoot": "",                                 /* Specify the root path for debuggers to find the reference source code. */
          // "mapRoot": "",                                    /* Specify the location where debugger should locate map files instead of generated locations. */
          // "inlineSources": true,                            /* Include source code in the sourcemaps inside the emitted JavaScript. */
          // "emitBOM": true,                                  /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
          // "newLine": "crlf",                                /* Set the newline character for emitting files. */
          // "stripInternal": true,                            /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
          // "noEmitHelpers": true,                            /* Disable generating custom helper functions like '__extends' in compiled output. */
          "noEmitOnError": true,                            /* Disable emitting files if any type checking errors are reported. */
          // "preserveConstEnums": true,                       /* Disable erasing 'const enum' declarations in generated code. */
          // "declarationDir": "./",                           /* Specify the output directory for generated declaration files. */
          // "preserveValueImports": true,                     /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
      
          /* Interop Constraints */
          // "isolatedModules": true,                          /* Ensure that each file can be safely transpiled without relying on other imports. */
          // "verbatimModuleSyntax": true,                     /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
          // "allowSyntheticDefaultImports": true,             /* Allow 'import x from y' when a module doesn't have a default export. */
          "esModuleInterop": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
          // "preserveSymlinks": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
          "forceConsistentCasingInFileNames": true,            /* Ensure that casing is correct in imports. */
      
          /* Type Checking */
          "strict": true,                                      /* Enable all strict type-checking options. */
          // "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */
          // "strictNullChecks": true,                         /* When type checking, take into account 'null' and 'undefined'. */
          // "strictFunctionTypes": true,                      /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
          // "strictBindCallApply": true,                      /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
          // "strictPropertyInitialization": true,             /* Check for class properties that are declared but not set in the constructor. */
          // "noImplicitThis": true,                           /* Enable error reporting when 'this' is given the type 'any'. */
          // "useUnknownInCatchVariables": true,               /* Default catch clause variables as 'unknown' instead of 'any'. */
          // "alwaysStrict": true,                             /* Ensure 'use strict' is always emitted. */
          // "noUnusedLocals": true,                           /* Enable error reporting when local variables aren't read. */
          // "noUnusedParameters": true,                       /* Raise an error when a function parameter isn't read. */
          // "exactOptionalPropertyTypes": true,               /* Interpret optional property types as written, rather than adding 'undefined'. */
          // "noImplicitReturns": true,                        /* Enable error reporting for codepaths that do not explicitly return in a function. */
          // "noFallthroughCasesInSwitch": true,               /* Enable error reporting for fallthrough cases in switch statements. */
          // "noUncheckedIndexedAccess": true,                 /* Add 'undefined' to a type when accessed using an index. */
          // "noImplicitOverride": true,                       /* Ensure overriding members in derived classes are marked with an override modifier. */
          // "noPropertyAccessFromIndexSignature": true,       /* Enforces using indexed accessors for keys declared using an indexed type. */
          // "allowUnusedLabels": true,                        /* Disable error reporting for unused labels. */
          // "allowUnreachableCode": true,                     /* Disable error reporting for unreachable code. */
      
          /* Completeness */
          // "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */
          "skipLibCheck": true                                 /* Skip type checking all .d.ts files. */
        }
      }
      

      根據(jù)自己的需求完成配置

      {
        "compilerOptions": {
          "strict": true, //開(kāi)啟嚴(yán)格模式
          "module": "es2015",
          "moduleResolution": "node",
          "target": "es5", //編譯為es5 也可以是"es5","es2015", "es2016", "es2017", "es2018",
          "allowSyntheticDefaultImports": true,//允許我們?cè)跊](méi)有默認(rèn)導(dǎo)出的JavaScript模塊中,使用import語(yǔ)句來(lái)引入模塊
          "experimentalDecorators": true,//// 啟用實(shí)驗(yàn)性的ES裝飾器
          "strictNullChecks": false,//啟用嚴(yán)格的空校驗(yàn)
          "lib": [
            "es2017",
            "dom"
          ],
          "types": [
            // add node as an option
            "node"
          ],
          // typeRoots option has been previously configured
          "typeRoots": [
            // add path to @types
            "node_modules/@types"
          ]
        }
      }
      
      
      
      posted on 2025-02-10 16:53  不確定因素  閱讀(35)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 国产浮力第一页草草影院| 久久青青草原精品国产app| 人妻无码中文专区久久app| 免费十八禁一区二区三区| 97久久人人超碰国产精品| 欧美videos粗暴| 亚洲国产天堂久久综合226114| 在线高清免费不卡全码| 波多野结系列18部无码观看AV| 欧美日韩精品一区二区视频| 国产无遮挡又黄又大又爽| 国产精品人妻系列21p| 久久精品无码免费不卡| 夜夜爽77777妓女免费看| 国产一二三五区不在卡| 中文字幕日韩精品人妻| 偷窥国产亚洲免费视频| 久久午夜无码鲁丝片直播午夜精品| 欧美三级中文字幕在线观看| 亚洲一区二区三区| 无码人妻丝袜在线视频| 婷婷四虎东京热无码群交双飞视频| 国内少妇偷人精品免费| 免费ā片在线观看| 国产综合视频一区二区三区 | 亚洲gv天堂无码男同在线观看| 黑人玩弄人妻中文在线| 伊人激情av一区二区三区| 国产精品久久福利新婚之夜| 国产一区二区不卡自拍| 十八禁国产精品一区二区| 岗巴县| 97色伦97色伦国产| 精品国产乱子伦一区二区三区| 久久国产精品精品国产色婷婷| 国产视频一区二区三区麻豆| 亚洲国产日韩a在线播放| 天天做日日做天天添天天欢公交车 | 国产成人综合欧美精品久久| 青草国产超碰人人添人人碱| 好吊妞无缓冲视频观看|