开发技巧
- TypeScript 相关 非空断言符号。
const doSoemthing = (el:string|null)=>{
if(!el){
const ch = el!.charAt(0)
}
}
DTS 文件
为了避免在所有的 ts 文件中显示地引入类型,可以在 DTS 文件声明全局类型。需要强调的是,不要在 DTS 文件中使用 import/export
这会让 ts compiler 将其视作为一个模块。
如果作为全局模块定义的 DTS 文件中确实需要引入第三方的模块定义,可以使用命名空间语法
declare module 'React' {
import React = require('react');
}
interface Option {
optionValues: string[];
propValues: Record<string, unknown>[];
}
interface TestMeta {
component: React.FunctionComponent;
api: string;
design: string;
version: string;
dimension: Record<string, Option>;
variables: Record<string, Option>;
initialChildren?: React.ReactNode[];
initialProps?: Record<string, unknown>;
}
- bash 杀死指定端口号的进程
lsof -nti:NumberOfPort | xargs kill -9
可以将它封装成为一个 bash 函数
funtion killbyport(){
lsof -nti:$1 |xargs kill -9
}
顺带一提,bash 的函数没有形参 3. useMemo 和 memo 本身就应该搭配使用
开阔视野
Verdaccio A lightweight Node. js private proxy registry ,可以用作私有 npm 源 https://verdaccio.org/
Tresjs 用 vue 写 three. js https://tresjs.org/guide/
icon8 图标和设计工具的平台
分发用户 Script 的平台