外部APIから入力を受け取る関数をコーディングしているとしましょうMyAPI。
その外部APIにMyAPIは、a stringまたはa を返すことを示す契約がありnumberます。
それはのようなものから保護することをお勧めしますnull、undefined、booleanそれはのAPIの一部ではないにもかかわらずなど、MyAPI?特に、そのAPIを制御することはできないため、静的型分析などの方法で保証することはできません。
私はロバストネスの原則に関連して考えています。
<!doctype html><html><head><title>504 Gateway Timeout</title></head><body>The server was unable to process your request. Make sure you have typed the address correctly. If the problem persists, please try again later.</body></html>