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

Why does TypeDoc think all modules are missing? (Error: Could not find a declaration file for module) #1089

Closed
1 task done
trusktr opened this issue Aug 11, 2019 · 6 comments
Labels
bug Functionality does not match expectation

Comments

@trusktr
Copy link

trusktr commented Aug 11, 2019

I'm not having luck with generating TypeScript docs. I've been trying various tools, including TypeDoc, but no luck so far.

Expected Behavior

I have a project that compiles fine with tsc, gulp-typescript and webpack.

I am hoping to be able to run something like

typedoc --out ./typedocs --mode modules --excludeExternals --excludeNotExported --excludePrivate --excludeProtected ../infamous+infamous/src/index.ts

and get generated docs.

Actual Behavior

I get a bunch of errors like

...
Error: /Users/trusktr/src/infamous+infamous/src/lib/jss/index.ts(2)
 Could not find a declaration file for module 'jss-nested'. '/Users/trusktr/src/infamous+infamous/node_modules/jss-nested/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/jss-nested` if it exists or add a new declaration (.d.ts) file containing `declare module 'jss-nested';`
Error: /Users/trusktr/src/infamous+infamous/src/lib/jss/index.ts(3)
 Could not find a declaration file for module 'jss-extend'. '/Users/trusktr/src/infamous+infamous/node_modules/jss-extend/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/jss-extend` if it exists or add a new declaration (.d.ts) file containing `declare module 'jss-extend';`
...

Environment

  • Typedoc version: 0.15.0
  • Node.js version: 12.7.0
  • OS: macOS
@trusktr trusktr added the bug Functionality does not match expectation label Aug 11, 2019
@trusktr
Copy link
Author

trusktr commented Aug 11, 2019

Steps to reproduce the bug

Clone https://github.com/infamous/infamous, checkout the branch TypeStrong/typedoc-issue-1089, install dependencies, then npm run typedoc.

That should give the errors.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 11, 2019

Geez, I think that's the first time I've cloned something that took longer than the TypeScript repo to install dependencies...


Notes while debugging:

  • You are using a ridiculously old version of jss. Installing with yarn errors as it expects node <6.0.0.
  • Installed successfully with npm i,
  • I see the errors, after renaming the cloned repo folder to infamous+infamous. Why does the package assume I'm installing in a specific folder name, especially one that isn't the default when just doing a git clone?
  • The tsconfig.json uses extends, I know this caused problems for TypeDoc in the past, and I don't recall it being fixed, looking at utils/options/readers/tsconfig.ts doesn't immediately tell me if it was fixed.
  • Tried copying the extended tsconfig.json file into the root tsconfig.json, confirmed npm run build still worked (after correcting paths). This got rid of most of the TypeDoc errors, so it looks like TypeDoc still can't handle extends. Error with nested tsconfig extends #380 was potentially closed prematurely.
  • The remaining errors are caused by TypeDoc not picking up src/types/global.d.ts. This is likely caused by Application#expandInputFiles not finding global.d.ts as TypeDoc currently does not use TypeScript to find all source files. If the input files are changed from ../infamous+infamous/src/index.ts to ../infamous+infamous/src/ TypeDoc will recurse through the directories and correctly pick up global.d.ts.
  • npm run typedoc works.

Looks like there are a couple issues:

  1. TypeDoc should be able to use the include option in tsconfig.json to resolve source files.
  2. TypeDoc doesn't support extends in tsconfig.json

@aciccarello
Copy link
Collaborator

@trusktr Thanks for posting the issue and describing how to reproduce. We'll need to review the tsconfig options. Include was marked as being supported in #359 but it may not be. I've also reopened #380.

@Neloreck
Copy link

Neloreck commented Sep 13, 2019

@trusktr
I was able to generate docs after modifying your script:

"typedoc": "typedoc --out ./typedocs --exclude **/node_modules/** --mode modules --excludeExternals --excludeNotExported --excludePrivate --excludeProtected ./src",
  1. You declared target script, not folder
  2. Not all modules have typedefs and not all modules have right typedefs, so better exclude /node_modules/

Hope, answer is not too late :)

Screen Shot 2019-09-13 at 2 51 05 PM

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 29, 2020

Looks like there are a couple issues:

  1. TypeDoc should be able to use the include option in tsconfig.json to resolve source files.
  2. TypeDoc doesn't support extends in tsconfig.json

Both of these have been fixed in 0.20, so I'm pretty sure this has been resolved

@Gerrit0 Gerrit0 closed this as completed Dec 29, 2020
@AndyOGo
Copy link

AndyOGo commented Jan 2, 2021

I just upgraded to 0.20.9 - PR here AndyOGo/stylelint-declaration-strict-value#131

However I still can't build the docs.
It doesn't find my custom declaration files for 2 modules.

But my normal lint and build with typescript works.

I also tried to a the typeRoots options, but without luck 😞
https://www.typescriptlang.org/tsconfig#typeRoots

> [email protected] docs /stylelint-declaration-strict-value
> typedoc --plugin typedoc-plugin-markdown src/index.ts

Loaded plugin typedoc-plugin-markdown

Error: /stylelint-declaration-strict-value/src/index.ts(2)
 Could not find a declaration file for module 'shortcss'. '/stylelint-declaration-strict-value/node_modules/shortcss/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/shortcss` if it exists or add a new declaration (.d.ts) file containing `declare module 'shortcss';`
Error: /stylelint-declaration-strict-value/src/index.ts(3)
 Could not find a declaration file for module 'shortcss/lib/list'. '/stylelint-declaration-strict-value/node_modules/shortcss/lib/list.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/shortcss` if it exists or add a new declaration (.d.ts) file containing `declare module 'shortcss/lib/list';`
Error: /stylelint-declaration-strict-value/src/index.ts(4)
 Could not find a declaration file for module 'css-values'. '/stylelint-declaration-strict-value/node_modules/css-values/dist/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/css-values` if it exists or add a new declaration (.d.ts) file containing `declare module 'css-values';

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

5 participants