@marko/language-tools 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1748,7 +1748,7 @@ var ScriptExtractor = class {
1748
1748
  let typeParamsStr = "";
1749
1749
  let typeArgsStr = "";
1750
1750
  let jsDocTemplateTagsStr = "";
1751
- const hasComponent = componentClassBody || componentFileName;
1751
+ const isExternalComponentFile = !componentClassBody && componentFileName !== void 0;
1752
1752
  if (inputType) {
1753
1753
  if (inputType.typeParameters) {
1754
1754
  let sep = SEP_EMPTY;
@@ -1770,17 +1770,17 @@ var ScriptExtractor = class {
1770
1770
  } else {
1771
1771
  if (this.#scriptLang === "ts" /* ts */) {
1772
1772
  this.#extractor.write(
1773
- hasComponent ? "export type Input = Component['input'];\n" : `export interface Input {}
1773
+ isExternalComponentFile ? "export type Input = Component['input'];\n" : `export interface Input {}
1774
1774
  `
1775
1775
  );
1776
1776
  } else {
1777
1777
  this.#extractor.write(
1778
- `/** @typedef {${hasComponent ? "Component['input']" : "Record<string, unknown>"}} Input */
1778
+ `/** @typedef {${isExternalComponentFile ? "Component['input']" : "Record<string, unknown>"}} Input */
1779
1779
  `
1780
1780
  );
1781
1781
  }
1782
1782
  }
1783
- if (!componentClassBody && componentFileName) {
1783
+ if (isExternalComponentFile) {
1784
1784
  if (this.#scriptLang === "ts" /* ts */) {
1785
1785
  this.#extractor.write(
1786
1786
  `import type Component from "${stripExt(
@@ -1800,11 +1800,11 @@ var ScriptExtractor = class {
1800
1800
  const body2 = componentClassBody || " {}";
1801
1801
  if (this.#scriptLang === "ts" /* ts */) {
1802
1802
  this.#extractor.write(
1803
- `abstract class Component${typeParamsStr} extends Marko.Component<${hasComponent && !inputType ? "{}" : `Input${typeArgsStr}`}>`
1803
+ `abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`
1804
1804
  ).copy(body2).write("\nexport { type Component }\n");
1805
1805
  } else {
1806
1806
  this.#extractor.write(`/**${jsDocTemplateTagsStr}
1807
- * @extends {Marko.Component${hasComponent && !inputType ? "" : `<Input${typeArgsStr}>`}}
1807
+ * @extends {Marko.Component<Input${typeArgsStr}>}
1808
1808
  * @abstract
1809
1809
  */
1810
1810
  `);
package/dist/index.mjs CHANGED
@@ -1715,7 +1715,7 @@ var ScriptExtractor = class {
1715
1715
  let typeParamsStr = "";
1716
1716
  let typeArgsStr = "";
1717
1717
  let jsDocTemplateTagsStr = "";
1718
- const hasComponent = componentClassBody || componentFileName;
1718
+ const isExternalComponentFile = !componentClassBody && componentFileName !== void 0;
1719
1719
  if (inputType) {
1720
1720
  if (inputType.typeParameters) {
1721
1721
  let sep = SEP_EMPTY;
@@ -1737,17 +1737,17 @@ var ScriptExtractor = class {
1737
1737
  } else {
1738
1738
  if (this.#scriptLang === "ts" /* ts */) {
1739
1739
  this.#extractor.write(
1740
- hasComponent ? "export type Input = Component['input'];\n" : `export interface Input {}
1740
+ isExternalComponentFile ? "export type Input = Component['input'];\n" : `export interface Input {}
1741
1741
  `
1742
1742
  );
1743
1743
  } else {
1744
1744
  this.#extractor.write(
1745
- `/** @typedef {${hasComponent ? "Component['input']" : "Record<string, unknown>"}} Input */
1745
+ `/** @typedef {${isExternalComponentFile ? "Component['input']" : "Record<string, unknown>"}} Input */
1746
1746
  `
1747
1747
  );
1748
1748
  }
1749
1749
  }
1750
- if (!componentClassBody && componentFileName) {
1750
+ if (isExternalComponentFile) {
1751
1751
  if (this.#scriptLang === "ts" /* ts */) {
1752
1752
  this.#extractor.write(
1753
1753
  `import type Component from "${stripExt(
@@ -1767,11 +1767,11 @@ var ScriptExtractor = class {
1767
1767
  const body2 = componentClassBody || " {}";
1768
1768
  if (this.#scriptLang === "ts" /* ts */) {
1769
1769
  this.#extractor.write(
1770
- `abstract class Component${typeParamsStr} extends Marko.Component<${hasComponent && !inputType ? "{}" : `Input${typeArgsStr}`}>`
1770
+ `abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`
1771
1771
  ).copy(body2).write("\nexport { type Component }\n");
1772
1772
  } else {
1773
1773
  this.#extractor.write(`/**${jsDocTemplateTagsStr}
1774
- * @extends {Marko.Component${hasComponent && !inputType ? "" : `<Input${typeArgsStr}>`}}
1774
+ * @extends {Marko.Component<Input${typeArgsStr}>}
1775
1775
  * @abstract
1776
1776
  */
1777
1777
  `);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "dependencies": {
7
7
  "@babel/helper-validator-identifier": "^7.19.1",