Replies: 4 comments 3 replies
-
I'm not familiar with TypeScript myself so I can't really comment on that. But, right now the codebase is still using old syntax and is tied to Node.js 0.12, which is very unfortunate. What I would do:
|
Beta Was this translation helpful? Give feedback.
-
I'm also not very familiar with TypeScript and I even like pure javascript, but I also like maybe less dodgy code with TypeScript. I think v1.0 should still be javascript (with type definitions), goal for this version was integrate parse5, but it is derailed over the years. I do like idea for porting code to TypeScript, but maybe it should be on road map for next version. |
Beta Was this translation helpful? Give feedback.
-
I have opened #1816, implementing this change. I'd appreciate if you could have a look! |
Beta Was this translation helpful? Give feedback.
-
Locking as this has landed. |
Beta Was this translation helpful? Give feedback.
-
Over the past year and a bit, I have ported all of my packages that Cheerio depends on to TypeScript. Some otherwise hard-to-diagnose bugs were fixed this way, the code style was updated to modern JS, and type definitions became more reliable.
I have been thinking about porting Cheerio for a bit now. I have recently found several issues using the TypeScript compiler in #1615, which was very promising. Some considerations for a port are:
(1) Is the exported
Cheerio
constructor an actual class?The issue here is that this constructor is rarely called with
new
. ES6 classes throw an error in that case, leading to a breaking change.We will target ES5 for now, in which case the TS compiler will actually allow us to create class instances without
new
. This could be an issue should we ever want to change our compilation target.(2) How do we maintain the directory structure?
We can maintain the existing directory structure by extending the interface of a Cheerio class:
I'd love to hear everyone's thoughts on making this change. This can be additional considerations, as well as general feedback whether this is the right move for this project.
cc'ing @matthewmueller, @5saviahv and @XhmikosR
Beta Was this translation helpful? Give feedback.
All reactions