TypeScriptの宣言空間
declaration space
知ってたところでどうこうなるわけではないが
TypeScriptには3つの宣言空間がある
Value
Type
型宣言空間
Namespace
TypeScriptのnamespace
それぞれで名前が重複していてもエラーにはならない
code:例.ts
// エラーにならない
const Hoge = {};
interface Hoge {}
namespace Hoge {}
classみたいにValueとTypeに跨るやつもいる
table:a
Declaration Type Namespace Type Value
Namespace X X
Class X X
Enum X X
Interface X
Type Alias X
Function X
Variable X
#WIP
Declaration Merging
https://www.typescriptlang.org/docs/handbook/declaration-merging.html
#??
declare var
アンビエント変数
declare module
アンビエントモジュール
declare global
参考
『実践TypeScript』 5章
宣言空間 - TypeScript Deep Dive 日本語版
https://www.mushroom-blog.com/325/
https://developer.hatenastaff.com/entry/2016/06/27/140931
https://teppeis.hatenablog.com/entry/2014/04/typescript-declaration-spaces
https://www.typescriptlang.org/docs/handbook/declaration-files/by-example.html
TypeScriptのアンビエント宣言(declare)
型定義ファイル
https://typescript-jp.gitbook.io/deep-dive/type-system/intro
https://docs.solab.jp/typescript/ambient/declaration/
https://zenn.dev/qnighy/articles/9c4ce0f1b68350