
ts
一支海棠
这个作者很懒,什么都没留下…
展开
-
使用 webpack 搭建 typescript环境 使用loader运行ts文件
npm init 初始化 引入本地webpack npm i webpack webpack-cli -D build 使用webpack打包 Ts loader npm install ts-loader typescript -D tsconfig.json 初始化tsconfig tsc --init 搭建本地服务 引入插件 html-webpack-plugin npm i --save-dev html-webpack-plugin npm install webpack-dev-server -原创 2021-08-04 17:48:05 · 785 阅读 · 0 评论 -
typescript Narrowing
/* 缩小就是对联合类型的详细判断 使用类型缩小使代码变得更加简洁准确安全 */ function padLeft(padding: number | string, input: string) { if (typeof padding === "number") return new Array(padding + 1).join(" ") + input; return padding + input;原创 2021-08-04 17:14:05 · 146 阅读 · 0 评论