fp-ts: Use `unknown` type instead of `{}` (TypeScript 3.0+)
Affected APIs
Either.toErrorEither.tryCatchIOEither.tryCatchReaderTaskEither.tryCatchTask.tryCatchTaskEither.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.0could augmentglobalor 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 | voidfor older typescript versionsmixed = unknownfor>=3.1I’m going to add
unknown-tsas a dependency and publish a patch release@gcanti with the release of
typesVersionsthis 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.2and3.0.1. When3.1.0will be released, fp-ts will support3.0.1and3.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.0then, since mapped tuples are on their way (just found out) and they could be useful to improvecomposeandpipe, the risk is that we are going to releasefp-ts@3.0.0soon afterward.So if we want to avoid releasing major versions too frequently (and I do), we should “freeze”
fp-tsand stick totypescript@2.3features (as far as I know).