arethetypeswrong / arethetypeswrong.github.io

Tool for analyzing TypeScript types of npm packages

Home Page:https://arethetypeswrong.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature: detect inferred type cannot be named error

unional opened this issue · comments

I was thinking about doing something similar.

Basically what's need is to get the package, install the dependencies, and see if the types in the output files can be resolved or not.

This is especially problematic with pnpm with monorepo as the transient packages are located at the top level ./node_modules/.pnpm/....

For example:

# Dependency graph
- lib-a
  - lib-b
    - lib-c
# folder
- packages
  - lib-a
    - node_modules
      - lib-b  # symlink to /node_modules/.pnpm/lib-b/version-y
- node_modules
  - .pnpm
    - lib-b@version-y
    - lib-c@version-x 

If lib-b does not re-exports the type from lib-c, you will get Inferred type cannot be named error.

Anything that needs a full npm install is going to be out of scope for a while, but I think eventually it would be useful to do that and just report any actual TS errors.

Understand. 😄

Have not looked at the code, does it capable of parsing the typescript file?
Maybe a npm install can be avoided if we can compare the import identifiers against the dependencies in the package json.

Yeah, the TS files are parsed. It’s not that installing dependencies is impossible, it’s just that it would introduce a lot of complexity. It could take a while and use a lot of data on the web, so we’d want to prompt first, etc.