Skip to content

Conversation

@ocavue
Copy link

@ocavue ocavue commented Oct 31, 2023

When setting an option with the type of ParameterType.Flags, if this._values[declaration.name] doesn't exist yet, TypeDoc will throw [error] Cannot convert undefined or null to object. This PR fixes it by assigning an empty object when it is undefined.

This PR also improves the logging by adding some extra information about the current key when setValue method throws an error.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 31, 2023

It shouldn't be possible for _values[name] to be undefined for flags at this point... do you have a repro example you can share?

@ocavue
Copy link
Author

ocavue commented Nov 1, 2023

https://stackblitz.com/github/issueset/typedoc-markdown-flags-issue?file=config%2Ftypedoc-base.json

You can open this link to see the [error] Cannot convert undefined or null to object error.

I'm using the namedAnchors option from typedoc-plugin-markdown. Maybe this is an issue on the typedoc-plugin-markdown side.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 3, 2023

Ah, looks like I messed up in Options.copyForPackage, that function copies the declarations from the root options object, but neglects setting their default values. typedoc-plugin-markdown is doing the right thing.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 3, 2023

I don't think I want to add the logging to all of the readers, the errors thrown from the Options class (especially those that can be caused by bad configuration) should already have the option name in them, will review those to make sure they look right.

@Gerrit0 Gerrit0 closed this in c86f4a9 Nov 3, 2023
@ocavue
Copy link
Author

ocavue commented Nov 3, 2023

thanks for your fix!

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 3, 2023

Thank you! Your repro made it quickly obvious what the problem was once I looked at it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants