code-complexity icon indicating copy to clipboard operation
code-complexity copied to clipboard

TSC errors on building + Dev experience

Open medic-code opened this issue 2 years ago • 1 comments

Hi, I came across this package when reading a blog. Please let know if I'm missing something, but when I cloned the repo and attempted to install the dependencies I came across two errors.

Environment Node v18.12.1 Using WSL on windows 11

Steps to reproduce

  1. git clone https://github.com/simonrenoult/code-complexity.git
  2. Move to code-complexity folder
  3. npm install

Actual result

> [email protected] prepare
> npm run lint && npm run build


> [email protected] lint
> eslint --ext .ts .


> [email protected] build
> rm -rf dist && tsc

src/io/output.ts:2:28 - error TS2307: Cannot find module '../../dist/src/lib/statistics' or its corresponding type declarations.

2 import { IStatistic } from "../../dist/src/lib/statistics";
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/lib/statistics/statistics.ts:1:28 - error TS2307: Cannot find module '../../../dist/src/lib/statistics' or its corresponding type declarations.

1 import { IStatistic } from "../../../dist/src/lib/statistics";
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors in 2 files.

Errors  Files
     1  src/io/output.ts:2
     1  src/lib/statistics/statistics.ts:1

Expected result To return to prompt without errors with the project build (in the dist folder)

Attempts to solve the issue If I change the imports to IStatistic in /src/lib/statistic.ts - I'm able to build and subsequently run tests. Am I missing something ?

Questions

Does this have something to do with how to use the tool via npx if we haven't installed the package locally as to why the imports for IStatistic point to the dist folder ?

After thoughts

Again I realise I'm coming at this fresh but this brought up some other thoughts.

  1. I wondered about a dev script dev script using ts-node for the project.
  2. I was also wondering whether having a script that type checks might be handy.
  3. A start script to run the code created from the build script might be quite nice too.

I'd be happy to open a PR to add those additional scripts if you think it would be of benefit.

medic-code avatar May 08 '23 15:05 medic-code

I see https://github.com/simonrenoult/code-complexity/pull/47 - is exactly the changes I made to fix it.

Curious to know about the other after thoughts.

medic-code avatar May 08 '23 21:05 medic-code