Skip to content
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

Warning from phantom comments #2715

Closed
crystalfp opened this issue Sep 27, 2024 · 5 comments
Closed

Warning from phantom comments #2715

crystalfp opened this issue Sep 27, 2024 · 5 comments
Labels
bug Functionality does not match expectation

Comments

@crystalfp
Copy link

Search terms

Pinia, link

Expected Behavior

In the following code (from a Pinia store) I expect no warnings from TSDoc.

export const useConfigStore = defineStore("ConfigStore", {

    state: () => ({

		camera: {
	                . . .
		},
		scene: {
			. . .
		},
		lights: {
			. . . 
		},
                helpers: {
                        . . .
                }
	} as Viewer3DConfiguration),

    // > Getters
    getters: {
        /**
         * Return the status to be saved in a project
         *
         * @param state - The store state
         * @returns JSON formatted content of the store to be saved
         */
        statusToSave(state: Viewer3DConfiguration) {
            const statusToSave = {
                camera: state.camera,
                scene: state.scene,
                lights: state.lights,
                helpers: state.helpers,
            };
            return JSON.stringify(statusToSave);
        },
        /**
         * Check if the camera is perspective
         *
         * @param state - The store state
         * @returns True if the camera is set to perspective
         */
        isPerspectiveCamera(state: Viewer3DConfiguration) {
            return state.camera.type === "perspective";
        }
    },

Actual Behavior

Typedoc complains about failed links in non-existent comments for statusToSave getter routine. Where it takes the "replace" thing?

[warning] Failed to resolve link to "searchValue" in comment for stores/configStore.useConfigStore.statusToSave.replace.replaceValue
[warning] Failed to resolve link to "replaceValue" in comment for stores/configStore.useConfigStore.statusToSave.replace
[warning] Failed to resolve link to "searchValue" in comment for stores/configStore.useConfigStore.statusToSave.replace

Strange enough, no complain from the second getter, even it has the same structure.

Steps to reproduce the bug

  1. Put the above code in a file called configStore.ts
  2. Run the following code:
root=`pwd | sed "s@/d/@/d:/@"`
node_modules/.bin/typedoc \
--name "See the Molecule new generation" \
--out "doc/typedoc" \
--readme none \
--suppressCommentWarningsInDeclarationFiles \
--plugin typedoc-plugin-vue \
--plugin @zamiell/typedoc-plugin-not-exported \
--disableGit \
--excludeInternal \
--sourceLinkTemplate "vscode://file$root/{path}:{line}:1" \
--tsconfig ./tsconfig.json \
configStore.ts

Environment

  • Typedoc version: 0.26.7
  • TypeScript version: 5.6.2
  • Node.js version: 22.5.1
  • OS: Windows 11 64bits
@crystalfp crystalfp added the bug Functionality does not match expectation label Sep 27, 2024
@crystalfp crystalfp changed the title Warning from phaantom comments Warning from phantom comments Sep 27, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Sep 28, 2024

Can this be reproduced without plugins? Bugs caused by plugins should be reported to that plugin, not to this project.

@electrovir
Copy link

electrovir commented Sep 28, 2024

My warnings look slightly different:

[warning] Failed to resolve link to "searchValue" in comment for __type.replaceValue
[warning] Failed to resolve link to "replaceValue" in comment for __type
[warning] Failed to resolve link to "searchValue" in comment for __type

Nowhere in my codebase is anything named searchValue or replaceValue.

Repro is on this branch: https://github.com/electrovir/date-vir/tree/broken-docs. Repro steps are as follows:

  1. npm i in root
  2. cd packages/date-vir && npm run docs

I'm also getting a project warning which I don't understand because I've never gotten it before and I use the same config in all my repos.

[warning] date-vir (Project), defined in ./src/index.ts, does not have any documentation

I've narrowed the issue down to this line: https://github.com/electrovir/date-vir/blob/broken-docs/packages/date-vir/src/timezone/timezones.ts#L10 (notice Timezone is both a type and a const).

When I remove line 10, TypeDoc doesn't error out. It appears that TypeDoc is unable to handle this situation where an object is made to behave like a TypeScript enum.

I haven't found a workaround yet; adding @ignore doesn't work.

@electrovir
Copy link

Solution for my problem: remove @enum from the Timezone const. TypeDoc was incorrectly expanding the enum properties anyway, grabbing all the string properties from the Timezone type (which is a string union). It's unfortunate that I can't have that object marked as an enum in TypeDoc's output.

@crystalfp
Copy link
Author

@Gerrit0 The problem does not happen without plugins, but happens with any plugin.
OK, I will open the issue with both of the plugins I use, but the doubt remains: could be the mere presence of plugin to trigger the phantom comments?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Sep 29, 2024

No, this is almost certainly caused by a plugin doing something weird. One of the plugins is likely converting something defined in node_modules as a part of your code.

Closing as this issue doesn't appear to be caused by typedoc

@Gerrit0 Gerrit0 closed this as completed Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

3 participants