Skip to content

Remove internal uses of "namespace barrel" modules, untangle repo #51443

Description

In #51387, I introduced the concept of the "namespace barrel" modules, located at **/_namespaces/*.ts.

While this does help us transition to modules, internally, this is a gross hack and makes it hard for us to start splitting the codebase up, export just the parser, etc.

We should be trying to remove internal uses of these files and use direct imports, leaving these files for our public API surface only.

Activity

  1. jakebailey commented on Nov 8, 2022

    @jakebailey
    MemberAuthor

    Low hanging fruit for untangling: typeHasCallOrConstructSignatures is defined as a helper, but is then used by the checker. This should be flipped and that's one cycle down.

  2. a-tarasyuk commented on Nov 11, 2022

    @a-tarasyuk
    Contributor

    While this does help us transition to modules, internally, this is a gross hack and makes it hard for us to start splitting the codebase up

    Jake Bailey (@jakebailey) Do you mean it's better to use

    // @filename: core.ts
    import { Debug } from "./debug";
    import { __String, CharacterCodes, Queue, TextSpan, UnderscoreEscapedMap } from "./types";
    import { Comparer, Comparison, EqualityComparer, MapLike, Push, SortedArray, SortedReadonlyArray } from "./corePublic";
    import { isWhiteSpaceLike } from "./scanner";
    ....

    instead of

    // @filename: core.ts
    import {
        __String, CharacterCodes, Comparer, Comparison, Debug, EqualityComparer, isWhiteSpaceLike,
        MapLike, Push, Queue, SortedArray, SortedReadonlyArray, TextSpan,
        UnderscoreEscapedMap,
    } from "./_namespaces/ts";
    ...

    ?

    Or do you mean that we need to avoid import * as ts from "./_namespaces/ts";?

  3. jakebailey commented on Nov 11, 2022

    @jakebailey
    MemberAuthor

    Yes, the first one, not the last two. Reasons being:

    1. This is how we would have written things if we had been modules from the start.
    2. By going through the barrels, we make cycles harder to resolve. For example, core.ts should not be depending on scanner.ts. That code should be moved.
  4. jakebailey commented on Aug 25, 2026

    @jakebailey
    MemberAuthor

    We are now Go, so this isn't happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

InfrastructureIssue relates to TypeScript team infrastructure

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions