随笔分类 -  typescript

摘要:1、promise的then回调函数中res是any类型,在使用any类型的属性时报红? getToken().then(({res}:any) => { console.log(res.token) }) 阅读全文
posted @ 2025-05-22 13:21 吴飞ff 阅读(10) 评论(0) 推荐(0)
摘要:一、第三方包没有 声明文件时:https://blog.csdn.net/xiebaochun/article/details/122458063 解决方法1:从 @types/ 上下载对应的 包 解决方法2:自己写一个声明文件 ( .d.ts 文件) 在项目根目录新建 types 文件夹。 在 t 阅读全文
posted @ 2023-09-15 16:49 吴飞ff 阅读(44) 评论(0) 推荐(0)
摘要:声明文件介绍: 声明文件 也 叫做描述文件,以d.ts结尾的文件名,比如xxx.d.ts。声明文件主要是ts编译器 和 编辑器用的。 给 ts 编译器用:开发中 ts 不可避免要引用其它第三方的 js库。虽然通过总结引用可以调用库的类和方法,但是却无法使用 TS 诸如类型检查等特性功能。用 声明文件 阅读全文
posted @ 2022-03-23 17:54 吴飞ff 阅读(3090) 评论(0) 推荐(0)
摘要:对于前端来说,最大的优势其实就是TS的类型系统。 参考:https://www.tslang.cn/docs/handbook/basic-types.html【官网】 或 http://ts.xcatliu.com/basics/index.html(推荐) 一、原始类型: 布尔值:布尔值是最基础 阅读全文
posted @ 2020-07-28 08:48 吴飞ff 阅读(180) 评论(0) 推荐(0)