observablehq / htl

A tagged template literal that allows safe interpolation of values into HTML, following the HTML5 spec
https://observablehq.com/@observablehq/htl
ISC License
305 stars 24 forks source link

feat: convert module to ts #50

Closed grant closed 1 year ago

grant commented 1 year ago

Converts modules from JS to TS.

Can be used as an archetypal patttern for converting other packages.


Example output

➜  ~/Documents/github/observablehq/htl git:(grant/ts) yarn lint
yarn run v1.22.19
$ eslint .
✨  Done in 1.11s.
➜  ~/Documents/github/observablehq/htl git:(grant/ts) yarn test
yarn run v1.22.19
$ mocha --experimental-specifier-resolution=node
(node:90906) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:90906) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.

  ✔ HTML attributes are implicitly lowercased
  ✔ SVG attributes are implicitly case-corrected
  ✔ SVG foreign attributes are implicitly namespaced
  ✔ unknown SVG foreign attributes are not implicitly namespaced
  ✔ interpolating into a tag name is not allowed
  ✔ interpolating an empty string with a suffix is not allowed
  ✔ interpolating a value with an appropriate end tag into raw text is not allowed

  7 passing (54ms)

✨  Done in 1.26s.
➜  ~/Documents/github/observablehq/htl git:(grant/ts) yarn prepublishOnly
yarn run v1.22.19
$ rm -rf dist && rollup -c && git push

bundle.ts → dist/htl.js...
created dist/htl.js in 640ms

bundle.ts → dist/htl.min.js...
created dist/htl.min.js in 588ms
Everything up-to-date
✨  Done in 2.91s.