首页 > 其他分享 >[Typescript] tsconfig libs and target

[Typescript] tsconfig libs and target

时间:2024-08-08 19:06:50浏览次数:6  
标签:Typescript target DOM will libs tsconfig

In tsconfig file, you have targetand libsconfiguration.

You always need to define a target, recommended as es2022

Specifying the lib option also lets us drill down into the specific features and libraries we want to include in our project, which we will see more of later.

{
  "compilerOptions": {
    "target": "ES2022",
    "lib": ["ES2022" , "ESNext.Intl"],
    // rest of config as before

 

Without libs, by default, it includes["DOM", "DOM.Iterable"]as well, if you give libswith some values, the default values will be replaced

标签:Typescript,target,DOM,will,libs,tsconfig
From: https://www.cnblogs.com/Answer1215/p/18349551

相关文章

  • [Typescript] Using Variables Declared Elsewhere
    The declare keywordinTypeScriptallowsyoutospecifytypesforglobalvariables.Wheneveryouuseit,anambientcontextiscreated,whichmeansthatthevariableisinjectedwithoutneedingtoprovideanimplementation.Here'showwewoulduse de......
  • [Typescript] Annotating the Errors Thrown by a Function
    /***Howdoweannotatetheerrorsthisfunctionthrows?*/typePossibleErrors=SyntaxError|DOMException;constgetUserFromLocalStorage=(id:string)=>{constuser=localStorage.getItem(id);if(!user){returnundefined;}re......
  • [Typescript] Type incompatible function argument as never
    Forthefollowingcode:constobjOfFunctions={string:(input:string)=>input.toUpperCase(),number:(input:number)=>input.toFixed(2),boolean:(input:boolean)=>(input?"true":"false"),};constformat=(i......
  • [Typescript] Typing Functions with Object Params
    import{expect,it,vitest}from'vitest';constlogId=(obj:{id:string})=>{console.log(obj.id);};constlogName=(obj:{name:string})=>{console.log(obj.name);};constloggers=[logId,logName];constlogAll=(o......
  • [Typescript] Understanding TypeScript's Function Parameter Comparisons
    Makethosepass:import{Equal,Expect}from"@total-typescript/helpers";typeEvent="click"|"hover"|"scroll";typeCallbackType=unknown;constlistenToEvent=(callback:CallbackType)=>{};listen......
  • 【TS】 TypeScript声明文件:打通JavaScript和TypeScript的桥梁
     TypeScript声明文件的讲解: TypeScript声明文件(DeclarationFile)在TypeScript项目中具有举足轻重的地位,它是连接TypeScript严格的类型系统与外部无类型或类型不明确的JavaScript代码的关键纽带。 声明文件的核心价值在于为TypeScript编译器提供必要的类型信息......
  • TypeScript 基础类型与类型声明
    前言在JavaScript中,变量是没有类型的,变量的值的类型是在运行时确定的,这被称为动态类型。这意味着可以在不同的时间将不同类型的值赋给同一个变量,并且JavaScript会在运行时根据当前赋给变量的值来确定其类型。示例:leta;//声明一个变量aa=10;//此时a的......
  • TypeScript 类型断言、类型推论
    类型断言类型断言是一种TypeScript特性,用于告诉编译器将一个值视为特定的类型,即使编译器本身的类型推断可能不同。类型断言并不会改变变量的实际运行时类型,而是在编译阶段告知TypeScript编译器开发者期望该表达式具有某种类型。注意:类型断言不是类型转换,因为转换通常......
  • [Typescript] Advance query builder example
    typeBaseTable={[colName:string]:string|number|boolean;}typeColumns<Tablesextends{[tableName:string]:BaseTable}>={[KinkeyofTables]:Kextendsstring?(keyofTables[K]extendsstring?`${K}.${keyofTables[K]}`:never):......
  • [Typescript] Query builder example
    classQueryBuilder{privatefields:string[]=[]privatewheres:Record<string,string>={}privatetable:string=""select(...columns:string[]){this.fields=columnsreturnthis}from(table:string){t......