Skip to content

Declaration option of type ParameterType.Map can't use a defaultValue that is not part of the value map #1249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
krisztianb opened this issue Mar 26, 2020 · 1 comment · Fixed by #1250
Closed
1 task done

Comments

@krisztianb
Copy link
Contributor

krisztianb commented Mar 26, 2020

Expected Behavior

When adding a declaration option for a plugin the following call should work:

typedoc.options.addDeclaration({
    type: ParameterType.Map,
    name: "fontStyle",
    map: new Map([
        ["normal", FontStyle.Normal],
        ["plain", FontStyle.Plain],
        ["italic", FontStyle.Italic],
        ["bold", FontStyle.Bold],
   ],
   defaultValue: FontStyle.Undefined,
});

A default value not listed in the map of possible values enables the plugin to verify whether or not a value was provided for the option at all. Otherwise the plugin can't know if the default value was a fallback or specified by the user. This might make a difference in the logic of the plugin.

Actual Behavior

Upon loading the plugin the following error is thrown:

Error: Failed to validate default value for fontStyle
    at Result.expect (C:\MyProjects\typedoc\class-proj\node_modules\typedoc\dist\lib\utils\result.js:17:15)
    at Options.addDeclaration (C:\MyProjects\typedoc\class-proj\node_modules\typedoc\dist\lib\utils\options\options.js:59:18)
    at PluginEnumOption.addToApplication (C:\MyProjects\typedoc\class-proj\node_modules\typedoc-plugin-base\dist\plugin_enum_option.js:43:25)
    at PlantUmlPluginOptions.addToApplication (C:\MyProjects\typedoc\class-proj\node_modules\typedoc-plantuml\dist\plantuml_plugin_options.js:138:51)
    at PlantUmlPlugin.addOptionsToApplication (C:\MyProjects\typedoc\class-proj\node_modules\typedoc-plantuml\dist\plantuml_plugin.js:62:22)
    at PlantUmlPlugin.PluginBase.initialize (C:\MyProjects\typedoc\class-proj\node_modules\typedoc-plugin-base\dist\plugin_base.js:14:14)
    at load (C:\MyProjects\typedoc\class-proj\node_modules\typedoc-plantuml\dist\index.js:9:44)
    at PluginHost.load (C:\MyProjects\typedoc\class-proj\node_modules\typedoc\dist\lib\utils\plugins.js:28:21)
    at CliApplication.bootstrap (C:\MyProjects\typedoc\class-proj\node_modules\typedoc\dist\lib\application.js:44:22)
    at CliApplication.bootstrap (C:\MyProjects\typedoc\class-proj\node_modules\typedoc\dist\lib\cli.js:29:30)
C:\MyProjects\typedoc\class-proj\node_modules\typedoc\dist\lib\utils\result.js:17
        throw new Error(message);

Steps to reproduce the bug

The code is part of my custom plugin. You can find it here: https://github.com/krisztianb/typedoc-plantuml

Environment

  • Typedoc version: 0.17.3
  • Node.js version: 12.13.0
  • OS: Windows 10
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 29, 2020

Thanks for posting this! I remember it now but it had completely dropped off the radar.

@Gerrit0 Gerrit0 removed the bug label Feb 2, 2025
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 a pull request may close this issue.

2 participants