Skip to content

Commit

Permalink
Bump to v1.0.2, improve template.d.ts, bump vitest
Browse files Browse the repository at this point in the history
The previous version of lib/template.d.ts worked, and enabled Visual
Studio Code to provide documentation in JSDoc comments like:

```js
* @param {import("./component.hbs").TemplateRenderer} [params.render] -
```

or:

```js
* @param {import("*.hbs").TemplateRenderer} [params.render] -
```

But the 'jsdoc' tool, even with 'jsdoc-plugin-typescript' installed,
would choke on them. This update fixes this, and allows for a better
experience all around by providing a proper namespace:

```js
* @param {HandlebarsPrecompiler.TemplateRenderer} [params.render] -
```

I tried to think through how to declare the namespace so that users
wouldn't have to copy it. However, the original comment in the README
still stands:

> This is necessary because the precompiled modules are generated in
> _your_ project, not in `rollup-plugin-handlebars-precompiler`, so
> that's where TypeScript needs to find the type declarations.

Also bumped vitest to v1.2.1, along with:

- @stylistic/eslint-plugin-js: v1.5.4
- @types/node: v20.11.5
  • Loading branch information
mbland committed Jan 18, 2024
1 parent 24d46d9 commit c9b41d3
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 78 deletions.
9 changes: 6 additions & 3 deletions lib/template.d.ts
Expand Up @@ -4,11 +4,14 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

declare module "*.hbs" {
export const RawTemplate: Handlebars.TemplateDelegate
declare namespace HandlebarsPrecompiler {
export interface TemplateRenderer {
(context: any, options?: Handlebars.RuntimeOptions): DocumentFragment
}
const Template: TemplateRenderer
}

declare module "*.hbs" {
export const RawTemplate: Handlebars.TemplateDelegate
const Template: HandlebarsPrecompiler.TemplateRenderer
export default Template
}
14 changes: 7 additions & 7 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-handlebars-precompiler",
"version": "1.0.1",
"version": "1.0.2",
"description": "Rollup plugin to precompile Handlebars templates into JavaScript modules",
"main": "index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -31,11 +31,11 @@
"repository": "https://github.com/mbland/rollup-plugin-handlebars-precompiler",
"bugs": "https://github.com/mbland/rollup-plugin-handlebars-precompiler/issues",
"devDependencies": {
"@stylistic/eslint-plugin-js": "^1.5.3",
"@types/node": "^20.11.4",
"@vitest/coverage-istanbul": "^1.2.0",
"@vitest/coverage-v8": "^1.2.0",
"@vitest/ui": "^1.2.0",
"@stylistic/eslint-plugin-js": "^1.5.4",
"@types/node": "^20.11.5",
"@vitest/coverage-istanbul": "^1.2.1",
"@vitest/coverage-v8": "^1.2.1",
"@vitest/ui": "^1.2.1",
"eslint": "^8.56.0",
"eslint-plugin-jsdoc": "^46.10.1",
"eslint-plugin-vitest": "^0.3.20",
Expand All @@ -47,7 +47,7 @@
"rollup": "^4.9.5",
"test-page-opener": "^1.0.6",
"typescript": "^5.3.3",
"vitest": "^1.2.0"
"vitest": "^1.2.1"
},
"dependencies": {
"@rollup/pluginutils": "^5.1.0",
Expand Down
136 changes: 68 additions & 68 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c9b41d3

Please sign in to comment.