Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type definitions are buggy #111

Closed
iacore opened this issue Apr 13, 2024 · 3 comments · Fixed by #114
Closed

Type definitions are buggy #111

iacore opened this issue Apr 13, 2024 · 3 comments · Fixed by #114

Comments

@iacore
Copy link

iacore commented Apr 13, 2024

❯ cat node_modules/uhtml/./types/dom/index.d.ts
import Document from './document.js';
import DOMParser from './dom-parser.js';
export { Document, DOMParser };

./document.js does not even exist. It should be ./document.d.ts afaik.

uhtml/init and uhtml/dom have this problem. Maybe they all have this problem.

@WebReflection
Copy link
Owner

it's tsc generating those though ... https://github.com/WebReflection/uhtml/blob/main/package.json#L17 ... 🤔

@iacore
Copy link
Author

iacore commented Apr 13, 2024

I removed all "types":.... lines from package.json and the types immediately worked in VSCode.

JSDoc is better. Typescript LSP recognize that.

  • Ctrl+Click jump to source code, not .d.ts
  • 1 less build step

For more details, see Why Svelte did TS->JSDOC.

@iacore
Copy link
Author

iacore commented Apr 13, 2024

I was using uhtml/init and uhtml/dom in my project, and the types was buggy. I'll fix it.

I tried. uhtml/init is generated somehow. The following code erased the type of exports.

  exports.Hole = Hole;
  exports.attr = attr;
  exports.html = html;
  exports.htmlFor = htmlFor;
  exports.render = keyed$1;
  exports.svg = svg;
  exports.svgFor = svgFor;

  return exports;

changing the code snippet to

  return {
    Hole : Hole,
    attr : attr,
    html : html,
    htmlFor : htmlFor,
    render : keyed$1,
    svg : svg,
    svgFor : svgFor,
  }

has fixed the problem for TypeScript LSP.

I think keeping only uhtml/init is the way to go. uhtml/keyed can be derived from that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants