Skip to content

Improve compiler to deal with duplicate sources in project (caused by use of git submodules) #5889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markvandenbrink opened this issue Dec 2, 2015 · 1 comment
Labels
Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds

Comments

@markvandenbrink
Copy link

We have a large TypeScript project using different git repositories to separate work domains inside the project. We tend to create separate repositories for self-contained modules and use those modules in other repositories using git submodules. This helps tremendously to reduce clutter and distribute work.

In our case some modules are used in many other repositories and those repositories are in turn used in other repositories. This sometimes leads to duplicate sources in projects using submodules which themselves depend on a common submodule. Assume the following example to clarify this:

Project git
|-- A (git submodule)
|   |-- a.ts
|   |-- C (git submodule)
|       |-- c.ts
|-- B (git submodule)
|   |-- b.ts
|   |-- C (git submodule)
|       |-- c.ts
|-- app.ts

Submodule A git
|-- a.ts
    |-- C (git submodule)
        |-- c.ts

Submodule B git
|-- b.ts
    |-- C (git submodule)
        |-- c.ts

Submodule C git
|-- c.ts

In this case submodule C is a self-contained repository used as submodule in repositories A and B which in turn are used as submodules in our main project git. This results in duplicate sources for c.ts in the main project which can sometimes lead to compiler errors along the lines of Types have separate declarations bla bla. See #5039 for an example (this feature request is a spin-off from the discussion in #5039 which proposes path mappings).

This is because the TypeScript compiler treats the duplicate implementations of submodule C as separate implementations. Would it not be nice if the compiler detects those duplicate sources (by generating some sort of hash for each compiled source) and automatically maps subsequent sources to the first source already compiled? It would greatly improve the use of git submodules in TypeScript projects and prevents the formation of separate type declarations.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 19, 2016

The files really are different on disk. there is a chance that you do update the original bits, but have not updated the submodule, and in this case you really want to get an error.
it is very hard for the compiler to know that these two "things" are the same, or just similar. I think you are better off using something like path mapping module resolution(#5039) or use symlinks (#6365).

@mhegazy mhegazy closed this as completed Feb 19, 2016
@mhegazy mhegazy added Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds labels Feb 19, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds
Projects
None yet
Development

No branches or pull requests

2 participants