Comments (2)
I tried to rewrite CSSTree in TypeScript a couple of times. Add typing for List and other utils is quite a trivial problem that does not cause difficulties. However, a complex parts, like parser, are very non-TypeScript friendly due to their flexibility. At the moment, there is a choice, either typings or flexibility. Flexibility means the posibility of fork()
method and the ability to provide specialized entry points (like css-tree/selector-parser).
The fork()
method allows create an altered instance of API. For instance, you can extend parser, lexer and generator to work with new types of AST nodes, or alter parsing/serialization rules. This feature is used by other libs to add new syntax support or some kind of support for preprocessor's syntax (for instance in stylelint-validator - Saas and Less).
I'm still thinking about how to add TS typing and keep it flexible. For now, flexibility is more important than typing or performance.
from csstree.
Add typing for List and other utils is quite a trivial problem that does not cause difficulties. However, a complex parts, like parser, are very non-TypeScript friendly due to their flexibility
I can confirm this 😅
Another main topic of my issue is JSDoc. Unfortunately, the code is documented in very few places. For example, there is a lot of "this" that needs to be debugged to see where it comes from through which binding. For example, when creating types, I should know what the basic code does, but as I reach more and more "flexible" codes, this becomes an increasingly difficult task.
The use of "this" also occurs during fork implementation, although I could deduce what it is based on the core code.
At the moment I was "only" talking about documentation and .d.ts files. In my opinion, full TS porting is only possible by breaking change. I think flexibility can be maintained in TS as well, but in a completely different way.
from csstree.
Related Issues (20)
- `oklch()` support HOT 6
- csstree.lexer.matchProperty doesn't give an error on "filter" property with "blur(4px)empx"
- `font-weight` descriptor in `@font-face` doesn't allow two values HOT 2
- Support hask mark next to curly braces in CSS grammar
- Migrate to `@webref/css` for syntax data HOT 3
- Parsing invalid input with specified base location doesn't work properly HOT 1
- Customizable tokenizer in the fork API
- SyntaxError: ")" is expected HOT 2
- consider dropping some builds
- @import rule with supports() and/or layer() parsed as Raw HOT 3
- Do you have plans to replace mdn-data with other packages? HOT 2
- Imported Object.prototype conflict with csstree module! HOT 1
- Value Definition Syntax parser fails on "<an+b>" HOT 2
- Throws if the value of :lang() pseudo-class is quoted
- Nested attribute selector without & is parsed as raw
- How to do getComputedStyle for a list of classes?
- Value Definition Syntax parser rejects whitespaces in multipliers
- New sizing value stretch fails validation HOT 1
- Function node type miss in custom css property HOT 2
- Support `@position-try`
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 csstree.