Skip to content

TypeScript imports cannot be resolved #1258

Closed
@kripod

Description

@kripod

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions