From 04d7731ed9d72f295d0f8d160cf5228a256957d1 Mon Sep 17 00:00:00 2001 From: Johan Groth Date: Mon, 21 Nov 2022 10:23:31 +0100 Subject: [PATCH] fixup! feat(compiler): copy dock block from component to generated types --- src/utils/test/util.spec.ts | 13 +++++++++++-- src/utils/util.ts | 4 +++- test/karma/test-app/components.d.ts | 3 --- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/utils/test/util.spec.ts b/src/utils/test/util.spec.ts index 4b79ffe54ba1..6db49ba439af 100644 --- a/src/utils/test/util.spec.ts +++ b/src/utils/test/util.spec.ts @@ -201,7 +201,7 @@ describe('util', () => { }); }); - describe('addDockBlock', () => { + describe('addDocBlock', () => { let str: string; let docs: d.CompilerJsDoc; @@ -235,8 +235,17 @@ interface Foo extends Components.Foo, HTMLStencilElement {`); expect(util.addDocBlock(str, docs).includes('@internal')).toBeFalsy(); }); + it('excludes empty lines', () => { + docs.text = ''; + str = ' ' + str; + expect(util.addDocBlock(str, docs, 4)).toEqual(` /** + * @deprecated only for testing + */ + interface Foo extends Components.Foo, HTMLStencilElement {`); + }); + it.each([[null], [undefined], [{ tags: [], text: '' }]])( - 'does not add a dock block when docs are empty (%j)', + 'does not add a doc block when docs are empty (%j)', (docs) => { expect(util.addDocBlock(str, docs)).toEqual(str); } diff --git a/src/utils/util.ts b/src/utils/util.ts index 1dbac28538b3..69c1b1ec570a 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -117,7 +117,9 @@ function getDocBlockLines(docs: d.CompilerJsDoc): string[] { ...docs.tags .filter((tag) => !SUPPRESSED_JSDOC_TAGS.includes(tag.name)) .map((tag) => `@${tag.name} ${tag.text || ''}`.split(lineBreakRegex)), - ].flat(); + ] + .flat() + .filter(Boolean); } /** diff --git a/test/karma/test-app/components.d.ts b/test/karma/test-app/components.d.ts index 3e6906220602..d7e88ef7b99e 100644 --- a/test/karma/test-app/components.d.ts +++ b/test/karma/test-app/components.d.ts @@ -227,7 +227,6 @@ export namespace Components { interface ShadowDomBasicRoot { } /** - * * @virtualProp {string} colormode - The mode determines which platform styles to use. */ interface ShadowDomMode { @@ -873,7 +872,6 @@ declare global { new (): HTMLShadowDomBasicRootElement; }; /** - * * @virtualProp {string} colormode - The mode determines which platform styles to use. */ interface HTMLShadowDomModeElement extends Components.ShadowDomMode, HTMLStencilElement { @@ -1826,7 +1824,6 @@ declare module "@stencil/core" { "shadow-dom-basic": LocalJSX.ShadowDomBasic & JSXBase.HTMLAttributes; "shadow-dom-basic-root": LocalJSX.ShadowDomBasicRoot & JSXBase.HTMLAttributes; /** - * * @virtualProp {string} colormode - The mode determines which platform styles to use. */ "shadow-dom-mode": LocalJSX.ShadowDomMode & JSXBase.HTMLAttributes;