taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

NestJS Build Issue #120

Closed Huseyinnurbaki closed 3 years ago

Huseyinnurbaki commented 3 years ago

Hi,

Cannot use it with NestJS.

Steps to reproduce:

Create a nestjs project & install node-html-parse.

nest start --debug --watch

Following error prompted

node_modules/node-html-parser/dist/nodes/comment.d.ts:17:17 - error TS1110: Type expected.

17     toString(): `<!--${string}-->`;
                   ~~~~~~~

node_modules/node-html-parser/dist/nodes/comment.d.ts:18:1 - error TS1128: Declaration or statement expected.

18 }
   ~

[1:08:35 AM] Found 2 errors. Watching for file changes.

Any typescript supported alternative ?

Huseyinnurbaki commented 3 years ago

found it, closing.

iamswain25 commented 3 years ago

i came across the same error, what alternative did you find?

Huseyinnurbaki commented 3 years ago

I fixed it. @iamswain25

You can use this one. @hhaluk/node-html-parser

I'm using it in this repository --> https://github.com/Huseyinnurbaki/crypto-watchdog

boukeversteegh commented 3 years ago

You could try to solve this by upgrading typescript.

This worked for me, in a vue 2.x project.

package.json

-   "typescript": "^3.9.9",
+   "typescript": "^4.3.5",
nonara commented 3 years ago

Interesting issue. Looks like the new TS is inferring template literals for return types. That's pretty wild! That's why it's failing with older TS.

@Huseyinnurbaki I don't recommend keeping a separate fork (as you'll miss out on fixes, etc), but you're welcome to. I'll create an issue and see if we can get it sorted out.

Update

I really don't think this should happen, but it looks like it did, somehow for the last release. When I build it, it compiles as toString(): string. Investigating the issue, you can follow #143 for that