Comments (3)
@sandhose this is something I've explored in the past.
A bit of context on the problem space:
In general Unified wants to avoid adding generics, for generics sake (for example #47 (comment)), generics should be verifiable.
In this case, meaning that the plugin/parser/stringifiers added to unified return, match up with the return type on unified itself.
And ideally, that the return type can be inferred purely based off those plugins/parsers/stringifiers.
Two things that make this tricky.
- there is nothing preventing multiple stringifiers with different return types from being registered, the typing should be able to handle this case
- Unified supports arrays of plugins and presets, these should not break the typing either
From my early tests, generic tuples might offer the possibility make this possible. https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html
A few problems: microsoft/TypeScript#26113 and microsoft/TypeScript#5453 are incomplete, which can make extracting the types from lists of plugins and presets difficult. For an example see the following
Lines 253 to 261 in 952e15d
unified loses settings type checking in this case.
the impact is limited to a single use
, but for something like parsers and stringifiers, this would carry forward to through the rest of the use
plugin chain, all the way down to process
.
Another potential pit fall is presets.
Lines 227 to 236 in 952e15d
which rely on PluggableList
Lines 274 to 279 in 952e15d
Which is another place we currently lose some interferencing.
from unified.
The above doesn't necessarily mean that it can't be done.
Just that it is not a simple as adding a generic on process
, processSync
, and VFile
.
And there may be some challenges.
from unified.
I’m going to close this. It’s an issue that needs solving, but I think the proper solution is outlined here: vfile/vfile#45 (comment), and therefore is unrelated to changing vfile’s types for contents
/ value
.
from unified.
Related Issues (20)
- Update vfile to 4.2.1 HOT 1
- Logo not readable on github dark mode HOT 1
- Next major for the ecosystem HOT 46
- Dependencies need to be ESM HOT 6
- 3rd overload signature of `FrozenProcessor.run` should accept `ParseTree` instead of `CompileTree` HOT 5
- this.use() doesn't respect plugin order when combined with unified().use() HOT 6
- Support async compilers HOT 31
- Rethink how `*-stringify` should work HOT 16
- Throw on preset w/ neither `settings` nor `plugins` HOT 1
- unify AST types HOT 1
- Support `Node` typeParam in `Pluggable` and `PluggableList` HOT 9
- Notion Block AST HOT 4
- Error: No overload matches this call after library update. HOT 5
- Type errors on new major version → 11.0.2 HOT 5
- TypeScript error when doing simple unified markdown pipeline HOT 3
- CallableInstance throws error in older ECMA 5 targets HOT 6
- examples of tools? HOT 4
- tsc reports incorrect / missing types HOT 14
- VFile types do not support property result HOT 6
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 unified.