Joel Purra
6eb5d224b3
Propagate generic types where possible
...
- Replaces the hardcoded `unknown` type in for example `is.promise(value)` with `is.promise<T>(value)` so that a known (inferred or explicit) generic type `T` can be propagated in the type system.
- The same goes for `Key` and `Value` types in for example `Map<Key, Value>`, and so on.
- Also replacing `{[key: string]: unknown}` and similar with
`Record<Key, Value>` as appropriate.
- Kept `is.plainObject` as Record<string, Value>`, although the
`Key` can also be a `symbol`.
- If no inferred/explicit generic type is provided, the (current) default/implicit generic type is preserved. It is usually `unknown`.
- Use with caution, as `is` (nor the associated assertions) can not check generic type validity at runtime. It is a compile-time check performed by typescript, based on the developer-provided types (inferred or implicit).
- Making the wrong compile-time assumption about `T` can result in value with types which differ at runtime, leading to unexpected behavior. It is safer to stick with `unknown` generic types until they have been verified at runtime. This is particularly important when it comes to verifying the types of arbitrary inputs from users and external systems.
See
- https://www.typescriptlang.org/docs/handbook/generics.html
- https://github.com/sindresorhus/is/issues/102
2020-01-22 14:34:20 +01:00
Sindre Sorhus
11003b925e
Meta tweaks
2020-01-22 19:17:43 +07:00
Joel Purra
0c3f110386
Add assertion type guards ( #97 )
2020-01-22 18:08:35 +07:00
Joel Purra
c842cc260f
Upgrade dependencies ( #101 )
2020-01-21 23:56:44 +07:00
Sindre Sorhus
aeb3f74d65
Make the NodeStream type more accurate
2019-11-13 16:06:18 +07:00
Sindre Sorhus
c25b606c3b
Improve the type assertion for is.asyncFunction
2019-11-07 16:37:36 +07:00
Sindre Sorhus
af6b03d67f
Require Node.js 10
2019-11-07 15:58:29 +07:00
Sindre Sorhus
3f2caa4835
Revert "Bundle the required DOM types ( #93 )"
...
This reverts commit 7c16f20d16 .
2019-10-04 11:38:10 +07:00
Sindre Sorhus
7c16f20d16
Bundle the required DOM types ( #93 )
...
Closes #92
2019-10-02 23:06:53 +07:00
Sindre Sorhus
0cbd9df6ce
Minor refactoring
2019-07-01 23:19:25 +07:00
Sindre Sorhus
4f4820ef2f
Meta tweaks
2019-06-30 15:18:24 +07:00
Kai Niedziela
f04dffa575
Make is.number(NaN) return false ( #90 )
...
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2019-06-30 15:09:07 +07:00
Sindre Sorhus
ffc6ce4586
Fix linting
2019-06-15 02:12:31 +07:00
Sindre Sorhus
6106086a35
Revert "Drop duplicate export ( #84 )"
...
This reverts commit 28913cae88 .
Closes #89
Fixes #88
2019-05-21 16:45:07 +07:00
Sindre Sorhus
04cd282265
Fix the capitalization of is.bigInt64Array and is.bigUint64Array
2019-05-13 11:04:48 +07:00
Vlad Frangu
dd2a91dce5
Add support for BigInt ( #87 )
2019-05-04 16:05:23 +07:00
Adam Babcock
373605e40d
Test coverage for is(value) ( #86 )
2019-04-28 15:15:11 +07:00
Sindre Sorhus
120f74ab63
Require Node.js 8
2019-04-01 04:02:25 +07:00
Sindre Sorhus
ea4204f0b4
Switch to XO for linting
2019-03-31 21:34:47 +07:00
Federico Brigante
28913cae88
Drop duplicate export ( #84 )
2019-03-14 16:32:19 +07:00
Sindre Sorhus
2f5e03bed2
Minor tweaks
2019-02-04 02:54:30 +07:00
Sindre Sorhus
9683cd7fd9
Run TS as a require hook for tests instead of precompile
2019-02-04 02:38:38 +07:00
Sindre Sorhus
3c847be5a0
Improve the TypeScript types ( #80 )
2019-02-04 02:38:38 +07:00
Scottie Enriquez
2502442404
Rename .odd() to .oddInteger() and .even() to .evenInteger() for clarity ( #77 )
2019-02-04 02:38:38 +07:00
Sindre Sorhus
641d856b36
Stop using TypeScript namespace ( #78 )
2019-02-02 01:14:08 +07:00
Sindre Sorhus
ab586df0f9
Fix lint issue
2019-01-12 12:14:45 +07:00
Sindre Sorhus
42fd8d3574
Use the URL global when available
2018-12-13 16:57:06 +01:00
Sindre Sorhus
844b43c9df
Improve the is.observable check ( #74 )
...
Fixes #72
2018-12-13 16:52:55 +01:00
Itai Steinherz
566f363632
Add is.urlString ( #73 )
2018-12-13 16:52:21 +01:00
Sindre Sorhus
2ee148f5a1
Meta tweaks
2018-12-13 00:58:02 +01:00
Sindre Sorhus
9df6f4ebe9
Bump TypeScript version
2018-11-30 15:14:41 +07:00
Lukas Tetzlaff
d4869045c2
Refactor any to unknown where possible ( #68 )
...
Resolves #62
2018-11-02 17:43:51 +07:00
Itai Steinherz
7317226c80
Add is.numericString() ( #67 )
2018-11-01 18:21:49 +07:00
Sindre Sorhus
9ac56f1be7
Minor code style tweaks in the tests
2018-10-30 23:19:19 +07:00
Sindre Sorhus
45c976071a
Don't import util
...
We don't really need its full power. Not worth the bloat.
2018-09-28 13:32:55 +07:00
Arfat Salman
6e07df5896
Add emptiness methods ( #61 )
...
Fix #53
2018-09-28 13:24:35 +07:00
Sindre Sorhus
65c94f1a02
Include TS type lib references directly in the file
...
Fixes #51
2018-09-28 13:08:17 +07:00
Sam Verschueren
442f7b709f
Use is-buffer ponyfill for better browser support ( #66 )
2018-09-27 02:02:41 +07:00
Alex Russell
ad6f372c47
Fix parameter naming of isAbsoluteMod2 function. ( #64 )
2018-09-18 19:22:55 +03:00
Artur Androsovych
3bdaf21475
Add is.urlInstance ( #60 )
2018-07-10 16:04:20 +07:00
Artur Androsovych
c8736c2972
Add is.asyncIterable ( #59 )
2018-07-10 00:35:16 +07:00
Sindre Sorhus
db25d554dc
TS config tweaks
2018-05-19 15:42:12 +07:00
Lukas Tetzlaff
1df2ff09ce
Improve TS code by adding generics and removing any where applicable ( #49 )
2018-05-04 12:29:21 +07:00
Sam Verschueren
55c00956f9
Add is.observable ( #50 )
2018-05-03 10:22:32 +07:00
Sam Verschueren
38df0cfb24
Remove moot tslint disable comment ( #46 )
2018-04-04 13:08:29 +07:00
Sam Verschueren
8894dbec17
Add type guards ( #43 )
2018-04-04 00:05:59 +07:00
Sindre Sorhus
64ced4d33c
Simplify isFunctionOfType
...
ef85a5173d (r28310156)
2018-03-29 11:56:13 +07:00
Sindre Sorhus
ef85a5173d
Drop support for Node.js 4
...
Fixes #41
Fixes #40
2018-03-28 02:25:21 +07:00
Sindre Sorhus
28702421bf
Add missing dataView method
...
Fixes #37
2017-12-11 21:38:58 +01:00
Brandon Smith
70b08940be
Add is.directInstanceOf() ( #38 )
2017-12-09 11:55:08 -05:00