Assertions require every name in the call target to be declared with an explicit type annotation. 検証TypeScriptバージョンは4.8.2。 アサーション関数(Assertion Functions)の使い道として典型的なのは、Nullチェックのためのアサーションで、↓こんなようなのを作るわけですが export function assertNotNull<T>(val:T): asserts val is NonNullable<T> { // nullとundefined をまとめてチェック if (val == null) { throw new Error("valがnullかundefinedですよ"); } } export const assertNotNull = <T
![【TypeScript】Assertion Functionではarrow functionsを使わないほうがいい](https://cdn-ak-scissors.b.st-hatena.com/image/square/c323e68857cd711e22fbdab3d15ba84c80c68fbf/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fzenn%2Fimage%2Fupload%2Fs--CSW5Oo_h--%2Fc_fit%252Cg_north_west%252Cl_text%3Anotosansjp-medium.otf_55%3A%2525E3%252580%252590TypeScript%2525E3%252580%252591Assertion%252520Function%2525E3%252581%2525A7%2525E3%252581%2525AFarrow%252520functions%2525E3%252582%252592%2525E4%2525BD%2525BF%2525E3%252582%25258F%2525E3%252581%2525AA%2525E3%252581%252584%2525E3%252581%2525BB%2525E3%252581%252586%2525E3%252581%25258C%2525E3%252581%252584%2525E3%252581%252584%252Cw_1010%252Cx_90%252Cy_100%2Fg_south_west%252Cl_text%3Anotosansjp-medium.otf_37%3AA%252520Kid%252Cx_203%252Cy_98%2Fg_south_west%252Ch_90%252Cl_fetch%3AaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL3plbm4tdXNlci11cGxvYWQvYXZhdGFyL2M3MDE0NTRjODIuanBlZw%3D%3D%252Cr_max%252Cw_90%252Cx_87%252Cy_72%2Fog-base.png)