fp-ts: Use `unknown` type instead of `{}` (TypeScript 3.0+)
Affected APIs
Either.toError
Either.tryCatch
IOEither.tryCatch
ReaderTaskEither.tryCatch
Task.tryCatch
TaskEither.tryCatch
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (12 by maintainers)
Commits related to this issue
- New Feature: use `unknown` type instead of `{}`, closes #539 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: use `unknown` type instead of `{}`, closes #539 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: use `unknown` type instead of `{}`, closes #539 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: use `unknown` type instead of `{}`, closes #539 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: use `unknown` type instead of `{}`, closes #539 — committed to gcanti/fp-ts by gcanti 6 years ago
- New Feature: use `unknown` type instead of `{}`, closes #539 — committed to gcanti/fp-ts by gcanti 6 years ago
I see, thanks for explaining. That’s a bit hacky though and respect to
{}
would be a regression.Another option is module augmentation: 2.9 users which want to upgrade to
fp-ts@1.8.0
could augmentglobal
or even better
@mmkal yes, I just published https://github.com/gcanti/unknown-ts which exports
mixed = { [key: string]: any } | object | number | string | boolean | symbol | undefined | null | void
for older typescript versionsmixed = unknown
for>=3.1
I’m going to add
unknown-ts
as a dependency and publish a patch release@gcanti with the release of
typesVersions
this can now be a non-breaking change, can’t it?Interesting PR (“Adds support for “typesVersions” redirects”) https://github.com/Microsoft/TypeScript/pull/26568
Another proposal:
In order to avoid stagnation, how do you feel about supporting last 2 stable releases?
For example currently latest release is 3.0.1 so fp-ts should support
2.9.2
and3.0.1
. When3.1.0
will be released, fp-ts will support3.0.1
and3.1.0
.Yes, perhaps a little, sensible, easy fixable breaking change, but still a breaking change.
So looks like there’s only one option
That’s not desiderable though, given that TypeScript doesn’t follow semver and its release pace. For example let’s say we merge this PR and release
fp-ts@2.0.0
then, since mapped tuples are on their way (just found out) and they could be useful to improvecompose
andpipe
, the risk is that we are going to releasefp-ts@3.0.0
soon afterward.So if we want to avoid releasing major versions too frequently (and I do), we should “freeze”
fp-ts
and stick totypescript@2.3
features (as far as I know).