Skip to content

TSC errors on building + Dev experience #49

@medic-code

Description

@medic-code

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

> code-complexity@4.4.2 prepare
> npm run lint && npm run build


> code-complexity@4.4.2 lint
> eslint --ext .ts .


> code-complexity@4.4.2 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions