Summary
_externalImportMap is keyed by simple name and is overwritten while discovering [Import] declarations from referenced assemblies. This makes external import resolution non-deterministic when two libraries expose bindings under the same TS name.
Evidence
MetaSharp.Compiler.TypeScript/Transformation/TypeTransformer.cs:323 does _externalImportMap[type.Name] = entry.
MetaSharp.Compiler.TypeScript/Transformation/TypeTransformer.cs:327 does _externalImportMap[tsName] = entry.
- The comment immediately above says this phase should only add entries and should not overwrite local ones, but the implementation overwrites unconditionally.
Risk
A transitive dependency can silently replace a local external import mapping. The result depends on Compilation.References ordering, which makes the behavior hard to predict and debug.
Recommendation
Replace simple-name indexing with symbol-qualified or origin-qualified resolution, or at minimum detect collisions and emit a diagnostic. Local entries should explicitly win over transitive ones.
Missing tests
- Two referenced assemblies with
[Import] for the same simple name.
- One local assembly and one referenced assembly defining the same external name.
- A collision involving
AsDefault = true and a named import.
Summary
_externalImportMapis keyed by simple name and is overwritten while discovering[Import]declarations from referenced assemblies. This makes external import resolution non-deterministic when two libraries expose bindings under the same TS name.Evidence
MetaSharp.Compiler.TypeScript/Transformation/TypeTransformer.cs:323does_externalImportMap[type.Name] = entry.MetaSharp.Compiler.TypeScript/Transformation/TypeTransformer.cs:327does_externalImportMap[tsName] = entry.Risk
A transitive dependency can silently replace a local external import mapping. The result depends on
Compilation.Referencesordering, which makes the behavior hard to predict and debug.Recommendation
Replace simple-name indexing with symbol-qualified or origin-qualified resolution, or at minimum detect collisions and emit a diagnostic. Local entries should explicitly win over transitive ones.
Missing tests
[Import]for the same simple name.AsDefault = trueand a named import.