Skip to content

extract-ts-types.mjs writes types.ts into a SimpleModule.<Module> directory that sm new module never creates #284

Description

@antosubash

Summary

scripts/extract-ts-types.mjs hardcodes the output project directory as SimpleModule.${moduleName}:

const projectDir = `SimpleModule.${moduleName}`;
const outPath = resolve(modulesDir, moduleName, 'src', projectDir, 'types.ts');
mkdirSync(resolve(modulesDir, moduleName, 'src', projectDir), { recursive: true });

But sm new module <Name> creates projects named <Name> and <Name>.Contracts, not SimpleModule.<Name>. The namespace is SimpleModule.<Name>; the directory is not.

Reproduction

sm new project MyApp && cd MyApp
sm new module Invoicing
npm run generate:types

Result

src/modules/Invoicing/src/Invoicing/            # the real project (Invoicing.csproj)
src/modules/Invoicing/src/Invoicing.Contracts/  # the real contracts project
src/modules/Invoicing/src/SimpleModule.Invoicing/types.ts   # created by the script, nothing else in it

The generated types land in a sibling directory that contains only types.ts and belongs to no project.

Why it matters

  • A module's own .tsx files cannot import the types by any path the module actually uses; they have to reach sideways into a directory with no project, no tsconfig.json and no package.json.
  • The directory matches the root workspaces glob src/modules/*/src/* while containing no package.json.
  • Deleting a module leaves it behind. After removing the scaffold's sample Items module (deleting src/modules/Items entirely), the next generate:types recreated src/modules/Items/src/SimpleModule.Items/types.ts from the still-present generated .g.cs, resurrecting a directory tree for a module that no longer exists.

Suggested fix

Write to the module's actual project directory — <modulesDir>/<moduleName>/src/<moduleName>/types.ts — so the types sit next to the Pages/ they are meant to type, and are covered by that project's existing tsconfig.json.

If the SimpleModule. prefix is intentional for some layouts, resolve the directory by looking for the project that exists rather than assuming the name.

Environment

  • SimpleModule.Cli 0.0.39, packages 0.0.39
  • .NET SDK 10.0.201, Node 23.5.0, macOS

Related: #283 (same script, emits for NuGet-installed modules).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions