Skip to content

Commit

Permalink
Merge pull request #59 from ssssota/multiple-members
Browse files Browse the repository at this point in the history
Multiple members
  • Loading branch information
ssssota authored Mar 7, 2024
2 parents 911f0a6 + cd0b935 commit e33121e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-foxes-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-doctest": patch
---

Fix behavior for multiple class members
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
}
5 changes: 4 additions & 1 deletion packages/vite-plugin-doctest/src/transformers/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ function findJSDoc(node: typescript.Node): typescript.JSDoc[] {
...node.jsDoc.flatMap((doc) => (typescript.isJSDoc(doc) ? [doc] : [])),
);
}
node.forEachChild((child) => nodes.push(...findJSDoc(child)));
node.forEachChild(
(child) => nodes.push(...findJSDoc(child)),
(children) => nodes.push(...children.flatMap((child) => findJSDoc(child))),
);
return nodes;
}

Expand Down
12 changes: 12 additions & 0 deletions test/src/class.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export class Foo {
/** some note about this property */ // ← this causes the test discovery to fail
private readonly bar: number = 3;

/**
* @import.meta.vitest
* ```ts
* assert(true);
* ```
*/
public readonly baz = (): void => {};
}

0 comments on commit e33121e

Please sign in to comment.