documentation
                                
                                 documentation copied to clipboard
                                
                                    documentation copied to clipboard
                            
                            
                            
                        TypeScript imports cannot be resolved
Input
CLI command
yarn documentation build --document-exported src/index.ts --format md --github
src/index.ts
export { default as useDeviceMotion } from './useDeviceMotion'; // Missing '.ts' extension
src/useDeviceMotion.ts
import { useEffect, useState } from 'react';
import { managedEventListener } from './utils'; // Missing '.ts' extension
export default function useDeviceMotion() {
  const [motion, setMotion] = useState({});
  // ...
  return motion;
}
Output
Error: Cannot find module 'D:\Development\Projects\my-project\src\useDeviceMotion'
Require stack:
- D:\Development\Projects\my-project\node_modules\documentation\src\extractors\exported.js
- D:\Development\Projects\my-project\node_modules\documentation\src\parsers\javascript.js
- D:\Development\Projects\my-project\node_modules\documentation\src\index.js
- D:\Development\Projects\my-project\node_modules\documentation\src\commands\build.js
- D:\Development\Projects\my-project\node_modules\documentation\src\commands\index.js
- D:\Development\Projects\my-project\node_modules\documentation\bin\documentation.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
    at Function.resolve (internal/modules/cjs/helpers.js:21:19)
    at getCachedData (D:\Development\Projects\my-project\node_modules\documentation\src\extractors\exported.js:179:20)
    at findExportDeclaration (D:\Development\Projects\my-project\node_modules\documentation\src\extractors\exported.js:207:15)
    at D:\Development\Projects\my-project\node_modules\documentation\src\extractors\exported.js:110:25
    at Array.forEach (<anonymous>)
    at ExportDeclaration (D:\Development\Projects\my-project\node_modules\documentation\src\extractors\exported.js:97:20)
    at NodePath._call (D:\Development\Projects\my-project\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (D:\Development\Projects\my-project\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (D:\Development\Projects\my-project\node_modules\@babel\traverse\lib\path\context.js:88:12)
error Command failed with exit code 1.
Environment
- What version of documentation.js are you using?: 11.0.1
- How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): CLI
We should probably add ts to requireExtension defaults. https://github.com/documentationjs/documentation/blob/4ea3a95539513029fc1bafddad4e770934b7d019/src/input/dependency.js#L64
Try running with --require-extension=ts?
@tmcw Thank you for the quick tip! Unfortunately, it still fails...
Actually, yarn documentation build src/*.ts --format md --parse-extension=ts seems to be working, although it's a bit hacky.
The issue seems to be something with --document-exported.
Whoops, try --require-extension=.ts? Forgot that there's a . necessary.
@tmcw I already tried that, doesn't seem to work either.
No luck here either. Made a new issue: https://github.com/documentationjs/documentation/issues/1272
--shallow
--require-extension .ts and --parse-extension ts do not help to import referenced ts files
Hi, is there any new information on this? I am having the same problem, when I add --document-exported it fails on imports without the .ts extension. unfortunately wen I do that, typescript starts complaining (and possible the other devs in my company hehe). So it seems I'm stuck between a rock and a hard place here.
I've submitted #1484 to fix this.