結論
ts-essentials の DeepReadonly など、よく使用する型は毎回 import するのが手間だし、import が積み重なってしまう。
呼び出し元.ts
import { DeepReadonly } from 'ts-essentials'
type T = DeepReadonly<{ field: string }>
この作業に煩わしさを感じたら global の拡張を検討すると良い。
global.d.ts
import { DeepReadonly } from 'ts-essentials'
declare global {
type DR<Type> = DeepReadonly<Type>
}
tsconfig.json
{
"include": ["src/**/*", "global.d.ts"] # src配下にある場合はglobal.d.tsは不要
}
呼び出し元.ts
// import が不要になった
type T = DR<{ field: string }>
ts-essentials