Giter Site home page Giter Site logo

Comments (2)

lahmatiy avatar lahmatiy commented on June 2, 2024 1

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.

scripthunter7 avatar scripthunter7 commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.