diff --git a/readme.md b/readme.md index 8f541ed..94453a9 100644 --- a/readme.md +++ b/readme.md @@ -509,29 +509,29 @@ Use generic type parameters with caution. They are only checked by the TypeScrip import {assert} from '@sindresorhus/is'; async function badNumberAssumption(input: unknown) { - // Bad assumption about the generic type parameter fools the compile-time type system. - assert.promise(input); - // `input` is a `Promise` but only assumed to be `Promise`. + // Bad assumption about the generic type parameter fools the compile-time type system. + assert.promise(input); + // `input` is a `Promise` but only assumed to be `Promise`. - const resolved = await input; - // `resolved` is typed as `number` but was not actually checked at runtime. + const resolved = await input; + // `resolved` is typed as `number` but was not actually checked at runtime. - // Multiplication will return NaN if the input promise did not actually contain a number. - return 2 * resolved; + // Multiplication will return NaN if the input promise did not actually contain a number. + return 2 * resolved; } async function goodNumberAssertion(input: unknown) { - assert.promise(input); - // `input` is typed as `Promise` + assert.promise(input); + // `input` is typed as `Promise` - const resolved = await input; - // `resolved` is typed as `unknown` + const resolved = await input; + // `resolved` is typed as `unknown` - assert.number(resolved); - // `resolved` is typed as `number` + assert.number(resolved); + // `resolved` is typed as `number` - // Uses runtime checks so only numbers will reach the multiplication. - return 2 * resolved; + // Uses runtime checks so only numbers will reach the multiplication. + return 2 * resolved; } badNumberAssumption(Promise.resolve('An unexpected string'));