Closed nonara closed 3 years ago
I also suspect that the build was bad.
There are two funny aspects here related to the typescript version:
toString(): <!--${string}-->
;
in comment.d.ts
(assumption, not tested)
toString(): string;
(tested)
So this is why upgrading to TS4 works, but it would be better if the dist contained :string
in the first place.
Also, I did not like being required to update my typescript to a next major version, just for 1 utility dependency. If there are no deep reasons why it requires TS4, I would much prefer this library to be TS3 compatible.
Sorry for late responding. I have rebuilt and released to 4.1.3. Thanks for all your work. https://github.com/taoqf/node-html-parser/release/tag/v4.1.3 https://unpkg.com/node-html-parser@4.1.3/dist/nodes/comment.d.ts
Abstract
The current release seems to have somehow inferred template literal types as a return type for class methods in the compiled declaration files. In these cases, a
string
is the proper return type. Because template literal types are a newer feature, this is breaking compilation with typescript versions below the one which supports template literals.Example
See: https://unpkg.com/node-html-parser@4.1.2/dist/nodes/comment.d.ts
Line 17 reads:
What's odd is, when I run yarn build, this properly compiles to:
toString(): string
. It's possible that there was a bug with the version of TS that was used to compile the latest.@taoqf Can you reset the project to the latest commit, wipe and reinstall node_modules, then run
yarn build
and let me know what line 17 says for./dist/nodes/comment.d.ts
?Proposed Solution
I think the solution here is:
: `
(colon space backtick) in any*.d.ts
files/dist/nodes/commend.d.ts
has typestring
to be sureRelated Issues
120
142