Skip to main content

duplicated_export_reexports

Function duplicated_export_reexports 

Source
pub fn duplicated_export_reexports(
    modules: &[PathBuf],
    emitted: &[StagedFile],
    merged: &[String],
    barrel_loc: &Path,
    import_ext: ImportExt,
) -> Vec<TsStmt>
Expand description

#1820: the explicit re-exports a multi-file context’s barrel needs where two or more of its files’ modules export one name. User names are unique across a unit, but each file emits its own copy of what its declarations need from outside it: the context’s rebrand of a usesd commons type, that commons type’s codecs re-exported, a boundary type’s codecs (wherever the type is declared). Each copy is a function of the type alone, so the barrel re-exports the name from the first module (sorted by path) that exports it, which takes precedence over export *; without it, export * is ambiguous (TS2308) and drops the name at runtime. merged names the helpers the barrel defines itself (merged_unit_helpers), which are skipped.

modules is each file’s module path; emitted, the staged output in which each is found at its ts_output_path. What a module exports is read with TsStmt::exported_names, which sees structured exports only; every generated name that repeats across files is exported structurally (the commons codec re-export is TsDecl::ExportNames for this reason). A name the chosen module exports only as a type (a rebrand of a commons type with no of constructor is a bare type alias) is re-exported as type X: under the build’s isolatedModules, export { X } of a type-only name is TS1205 (#1862 review).