Comments (6)
Thank you for reporting this problem, @toolsh. Using Sanctuary in TypeScript projects is currently problematic. TypeScript's intentionally naive left-to-right type resolution algorithm interacts poorly with Sanctuary's “data-last” API, and hacks are required to simulate type classes.
Significant effort has been expended trying to produce reasonable type definitions for Sanctuary over the past two or three years, most recently in DefinitelyTyped/DefinitelyTyped#37879 and in vicrac/DefinitelyTyped. The formidableness of the task has led several efforts to be abandoned.
We could add any => any
-style type definitions for functions added since [email protected]
, so TypeScript users could at least use these functions. What do you think of this approach, @toolsh?
from sanctuary.
It seems that v4 indeed improves type inference for curried functions.
Notice the unknown
types in 3.8.3:
And the type is correctly displayed for the 4.0.2 version:
That will allow removing lots of overloads in the current declarations (we may need to check if existing overloads need to be kept for backwards compatibility, though).
from sanctuary.
Does typescript 4 help with this?
I don't know.
@lfarroco has been improving the TypeScript type definitions, most recently in DefinitelyTyped/DefinitelyTyped#45895. If and when anyone submits a pull request (to Definitely Typed) to add even one missing type definition, I will approve it. :)
from sanctuary.
Sounds good to me, at least it could make those trivia warnings go away!
from sanctuary.
Hey, friendly neighborhood issue necromancer here. Does typescript 4 help with this? If not, lets any
away. Given typescript is mostly a compiler and a flat out missing function definitions could lead to compilation errors. Or shimming.
OFFTOPIC:
This issue is so incredible it's kind of funny, not sure if I understand the "typescript hacks" thing correctly but it seems that the type correctness of this lib is so dense that you guys had to build a custom runtime type-checker (which is a sin in the sacred small production bundle church) and not even the de-facto (not preaching it's quality just it's ubiquity) can keep up in type checking.
I think I'm starting to comprehend the joke "there is a programming language in my type system"
from sanctuary.
Wait what I don't get it, backwards compatible with what? Unsafe code that might be exploiting the unknown return types? Besides, just bump the version 🤷♂️
from sanctuary.
Related Issues (20)
- Possible example bug HOT 3
- How to create a function in 'sanctuary'? HOT 2
- State and Reader ADTs
- ES5 => ES6 HOT 1
- Bundled version contains refetences to undefined self HOT 4
- Add "picks" to include certain key/value pairs from an object HOT 3
- Deno version HOT 2
- Add a function to split an Array into equally sized chunks
- Idea: Only treat objects without prototypes as StrMaps HOT 6
- Be more explicit about S.get(s) being an escape hatch from type safety HOT 1
- Question about S.concat HOT 4
- Support logging S.Nothing in deno
- feat: Make types accessible by name in `S` HOT 1
- Remove the need for require ('util') in browser environment HOT 4
- Check for empty structures? HOT 1
- Searchbar on website https://sanctuary.js.org/ HOT 1
- Implement Types for all new EcmaScript objects.
- match has changed from version 3.1.0 HOT 2
- Refactor documentation to be more independent and catchy
- ECMAScript modules HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanctuary.