type-fest/test-d/is-float.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
727 B
TypeScript

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