Skip to content

Commit

Permalink
bug: avoid trying to get properties of HTMLElement types
Browse files Browse the repository at this point in the history
  • Loading branch information
josemarluedke committed Mar 9, 2024
1 parent cd14340 commit 127f9f8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"compile": "tsc",
"prepare": "tsc",
"test": "jest",
"lint:js": "eslint . --ext .js,.ts"
"lint:js": "eslint . --ext .js,.ts",
"lint:js:fix": "eslint . --ext .js,.ts --fix"
},
"dependencies": {
"debug": "^4.3.4",
Expand Down
12 changes: 10 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,18 @@ export default class Parser {
};
}

// check if one element has string ending with Element
let isElement = false;
[symbol?.getName(), typeAsString].forEach((v) => {
if (v && v.endsWith('Element')) {
isElement = true;
}
});

if (
symbol &&
this.isInterfaceOrObjectWithOptionalProperties(symbol, type) &&
!/Element$/.test(symbol.getName())
!isElement &&
this.isInterfaceOrObjectWithOptionalProperties(symbol, type)
) {
const props = type.getApparentProperties();
return {
Expand Down
2 changes: 1 addition & 1 deletion tests/__fixtures__/button-args-only.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ interface ButtonArgs {
* The button component
* @since 1.0.0
*/
export default class Button extends Component<ButtonArgs> { }
export default class Button extends Component<ButtonArgs> {}
2 changes: 1 addition & 1 deletion tests/__fixtures__/button-with-extended-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ interface Signature {
Args: ButtonArgs;
}

export default class ButtonWithExtendedArgs extends Component<Signature> { }
export default class ButtonWithExtendedArgs extends Component<Signature> {}
2 changes: 2 additions & 0 deletions tests/__fixtures__/dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface DropdownArgs {
* @defaultValue true
*/
closeOnItemSelect?: boolean;

someRandomElement?: HTMLElement;
}

interface Transition {
Expand Down
4 changes: 2 additions & 2 deletions tests/__fixtures__/multiple-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ interface Signature {
// eslint-disable-next-line
class NotExportedButton extends Component<Signature> { }

export class ButtonNotDefault extends Component<Signature> { }
export default class ButtonDefault extends Component<Signature> { }
export class ButtonNotDefault extends Component<Signature> {}
export default class ButtonDefault extends Component<Signature> {}
11 changes: 11 additions & 0 deletions tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,17 @@ option allows to choose where it appears from.",
"type": "boolean",
},
},
{
"defaultValue": undefined,
"description": "",
"identifier": "someRandomElement",
"isInternal": false,
"isRequired": false,
"tags": {},
"type": {
"type": "HTMLElement",
},
},
],
"Blocks": [
{
Expand Down

0 comments on commit 127f9f8

Please sign in to comment.