Typedoc: "Error: Expected a symbol for node with kind StringLiteral"

Created on 18 Jun 2020  路  7Comments  路  Source: TypeStrong/typedoc

Search terms

Error: Expected a symbol for node with kind

Expected Behavior

previously, typedoc worked great with our monorepo in the main branch.

we expect it to compile correctly

note: the actual typescript compilation is working fine. all the project references compile correctly.

Actual Behavior

when we merged a feature branch that uses export * from './module-path, typedoc is having a parser error on that file.

 Mapping  /graphiql/packages/graphiql/src/api/index.ts  ==>  graphiql
/graphiql/node_modules/typedoc/dist/lib/converter/context.js:55
            throw new Error(`Expected a symbol for node with kind ${ts.SyntaxKind[node.kind]}`);
            ^

Error: Expected a symbol for node with kind StringLiteral
    at Context.expectSymbolAtLocation (/home/rikki/projects/graphiql/node_modules/typedoc/dist/lib/converter/context.js:55:19)

the file in question looks like this:

export * from './providers/GraphiQLEditorsProvider';
export * from './providers/GraphiQLSessionProvider';
export * from './providers/GraphiQLSchemaProvider';
export * from './hooks';
export * from './types';

this occurs with or without third party plugins, such as typedoc-monorepo-plugin which we were using successfully before this PR merge.

Steps to reproduce the bug

I cannot seem to reproduce the bug in a simplified, non-monorepo context:
https://github.com/acao/typedoc-export-bug-example

export * from 'module-path' seems to work fine with tsdoc in this case.

but in https://github.com/graphql/graphiql/ that is not the case

steps:

  1. clone https://github.com/graphql/graphiql/
  2. yarn
  3. yarn build
  4. yarn build-docs

Environment

  • Typedoc version: 0.17.7
  • TypeScript version: 3.9.5
  • Node.js version: 13
  • OS: linux, alpine
bug

All 7 comments

You likely can't reproduce this in a simplified context because there aren't compiler errors in your simple context. Turn off ignoreCompilerErrors and you will almost certainly see an error about TypeScript not being able to find the module. See #1293.

That said... I followed your repro steps, and upgraded typedoc, and am unable to reproduce your problem, the generated documentation is empty, but that's a separate problem... (Likely related to #1265, haven't had enough time to work on this lately)

ignoreCompilerErrors is already set to true:
https://github.com/graphql/graphiql/blob/master/typedoc.json#L15

thank you! i'll keep looking into it

you followed repro steps for the graphql/graphiql repo?

here are the changes you mentioned, still not working for typedoc bin locally. (the netlify failure is unrelated)
https://github.com/graphql/graphiql/pull/1585/files

ignoreCompilerErrors is already set to true:

Yes, and this is a problem. Doing this means that if there are compiler errors, TypeDoc will likely crash, since the TypeScript API doesn't necessarily follow its API contract if there are errors.

Yes, I used graphql/graphiql, checked out master. I also tried checking out your branch. Now that I'm looking at it with fresh eyes, a few things look odd.

  1. I'm not familiar with what the monorepo plugin, but unless it is doing something special with inputFiles, I'm surprised that ever worked. TypeDoc doesn't support globs there, only files and directories... though that's being entirely ignored anyways (again unless the monorepo plugin does something strange) due to the bug fixed by #1265.
  2. npm has a prepublishOnly script, the prepublish script could be changed to that to avoid running it on install (only reason I knew it tried to run is I'm on Windows, and instead of running the script... cmd.exe will open the file in the default text editor)
  3. Another windows-ism, TypeDoc gets 'packages' passed as the first argument, which results in it not finding any input files... and it silently ignores that. #1233.
  4. Correcting 3, I now see a bunch of compiler errors, which look to be related to not loading the tsconfig.json. Using --tsconfig packages/graphiql fixes this, but results in another problem... now TS complains about files being outside of the rootDir. I modified paths to only look at packages/graphiql/src, which fixed that...
  5. But then TypeDoc complains because it filters json files out from the input files, and they are used. This is a bug... no issue to track it yet I think.
  6. Hacking around that...
    node_modules/typedoc/dist/lib/application.js +129 const supportsJson = this.options.getCompilerOptions().resolveJsonModule; +152 } else if (supportsJson && file.endsWith('.json')) { +153 files.push(file) +154 }
    Still doesn't work, looks like there's an infinite loop introduced in UnionOrIntersectionConverter.convertType, not entirely sure how... out of time today to look at this.

thank you for digging in so deeply on this! many things i can improve on here

here is the last working build:
https://5ee2586531b6070008b2c313--graphiql-test.netlify.app/typedoc/

and the last working ref:
https://github.com/graphql/graphiql/tree/294fd834efe485132744c0cd9d24690a61b45501

which is essentially the same as 1.0.0 branch

I'm going to dig in further today based on your notes and get back to you. i really really appreciate all the time you've taken to help me with this. we published a new monaco-mode and now the api docs are broken so this will be very helpful to many users!

Was this page helpful?
0 / 5 - 0 ratings