type-fest/test-d/is-integer.ts
Haozheng Li f5b09de767
Add IsInteger and IsFloat, fix Integer and Float handing with edge case (#857)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2024-04-22 15:22:35 +07:00

18 lines
748 B
TypeScript

import {expectType} from 'tsd';
import type {IsInteger, PositiveInfinity} from '../index';
expectType<true>({} as IsInteger<0>);
expectType<true>({} as IsInteger<1>);
expectType<true>({} as IsInteger<1.0>); // eslint-disable-line unicorn/no-zero-fractions
expectType<false>({} as IsInteger<1.5>);
expectType<true>({} as IsInteger<-1>);
expectType<false>({} as IsInteger<number>);
expectType<true>({} as IsInteger<0o10>);
expectType<true>({} as IsInteger<1n>);
expectType<true>({} as IsInteger<0n>);
expectType<true>({} as IsInteger<0b10>);
expectType<true>({} as IsInteger<0x10>);
expectType<true>({} as IsInteger<1e+100>);
expectType<false>({} as IsInteger<PositiveInfinity>);
expectType<false>({} as IsInteger<typeof Number.POSITIVE_INFINITY>);