angular - strictTemplates true 忽略类型保护
创始人
2024-10-14 23:01:13
0

在Angular中,可以通过在tsconfig.json文件中设置"angularCompilerOptions"来启用严格的模板类型检查,并忽略类型保护错误。

首先,确保正在使用Angular版本8或更高版本,因为在Angular 8中才引入了strictTemplates选项。

然后,打开项目中的tsconfig.json文件,并添加以下内容:

"angularCompilerOptions": {
  "strictTemplates": true,
  "fullTemplateTypeCheck": false,
  "strictInjectionParameters": true
}

这里的重点是将strictTemplates设置为true,同时将fullTemplateTypeCheck设置为false(以忽略类型保护错误)和strictInjectionParameters设置为true(以启用更严格的注入参数检查)。

以下是一个完整的示例tsconfig.json文件:

{
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "skipLibCheck": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "strictTemplates": true,
    "fullTemplateTypeCheck": false,
    "strictInjectionParameters": true
  }
}

保存tsconfig.json文件后,重新启动项目,Angular将在编译期间执行严格的模板类型检查,并且将忽略类型保护错误。

相关内容

热门资讯

透视必备!wepoker代打辅... 透视必备!wepoker代打辅助(透视)聚星ai辅助工具下载,教程手册(有挂技术)-哔哩哔哩1、实时...
智星德州可以透视吗!We po... 智星德州可以透视吗!We poker辅助器下载(透视)挂-确实分享真的是有挂1、上手简单,内置详细流...
透视解谜!wepokerplu... 透视解谜!wepokerplus开挂(透视)aapoker万能辅助器,教程积累(有挂猫腻)-哔哩哔哩...
wepoker有透视底牌吗!w... wepoker有透视底牌吗!werplan辅助软件(透视)工具-都是教你真的是有挂1、wepoker...
透视了解!wepoker到底有... 透视了解!wepoker到底有没有透视(透视)hhpoker脚本,教程学习(存在有挂)-哔哩哔哩1、...
aapoker怎么控制牌!fi... aapoker怎么控制牌!fishpoker透视底牌(透视)攻略-真是详细真的是有挂;1、首先打开a...
透视有挂!约局吧德州透视(透视... 透视有挂!约局吧德州透视(透视)hhpoker有没有透视辅助,教程妙招(有挂方略)-哔哩哔哩1、hh...
wepoker有透视功能吗!w... wepoker有透视功能吗!wepoker透视app下载(透视)软件-其实科普真的是有挂1、超多福利...
透视了解!pokemmo脚本(... 透视了解!pokemmo脚本(透视)哈糖大菠萝有挂吗,教程举措(有挂总结)-哔哩哔哩哈糖大菠萝有挂吗...
智星菠萝辅助!wepoker透... 智星菠萝辅助!wepoker透视脚本(透视)插件-果然解密是真的挂1、下载好wepoker透视脚本透...