随笔分类 - TypeScript
TypeScript 工具类型
摘要:1. typeof 1.1 判断类型 typeof关键字可以用于判断变量的类型,如:"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"。 类型保护是可执行运行时检查的一
TypeScripts 学习笔记
摘要:TypeScript 是拥有类型的JavaScript超集,它可以被编译成普通、干净、完整的JavaScript代码。 一、起步 1. TypeScripts的编译环境 1.1 安装 # 全局安装 npm install typescript -g 安装好后, # 查看版本 tsc --versio
Property 'style' does not exist on type 'Element' in TS
摘要:1.报错情况: 当前环境:TS 发生错误的实例: 原因: 通过document.getElementsByClassName函数返回的类型为HTMLCollectionOf<Element>,而Element类型上不存在style属性。需要通过**类型断言**设置正确的类型。 2. 解决 1.使用d