Skip to content

Config-related gaps between the existing SDK libraries and the JS emitter #3987

@kazrael2119

Description

@kazrael2119

Codegen gaps identified after config/ migration

After investigating the SDK-side batch PRs (#38557, #38574, #38580, #38583) and comparing with the codegen source in packages/rlc-common/src/metadata/, here are the specific gaps:


Gap A: test:node:esm script should be removed

  • Generated file: package.json (the scripts section)
  • Codegen file: packages/rlc-common/src/metadata/packageJson/buildAzureMonorepoPackage.ts (line ~201)
  • Current code:
    "test:node:esm": "dev-tool run test:vitest --esm",
  • Change needed: Remove this line. The vitest.esm.config.ts file no longer exists (removed by autorest.typescript#3938), so this script is dead. The node tests already exercise the ESM build via vitest.config.ts, and the browser tests cover browser-ESM via vitest.browser.config.ts.

Gap B: test:browser script should remove build-test step

  • Generated file: package.json (the scripts section)
  • Codegen file: packages/rlc-common/src/metadata/packageJson/buildAzureMonorepoPackage.ts (line ~180-181)
  • Current code:
    "test:browser": "dev-tool run build-test && dev-tool run test:vitest --browser",
  • Change needed: Update to:
    "test:browser": "dev-tool run test:vitest --browser",
    The new vitest.browser.config.ts (from eng/vitestconfigs/browser.config.ts) runs tests directly against source files (test/**/*.spec.ts) using Vite's browser mode. The separate build-test step is no longer needed.

Gap C: test script should include type-check step

  • Generated file: package.json (the scripts section)
  • Codegen file: packages/rlc-common/src/metadata/packageJson/buildAzureMonorepoPackage.ts (line ~202)
  • Current code:
    test: "npm run test:node && npm run test:browser"
  • Change needed: Update to:
    test: "tsc -b --noEmit && npm run test:node && npm run test:browser"
    The tsc -b --noEmit type-checks against the project references (the new config/ tsconfigs) before running tests, catching type errors early without emitting files.

Gap D: Missing config/tsconfig.lint.json generation

  • Generated file: config/tsconfig.lint.json (currently NOT generated)
  • Codegen file: Needs a new builder function, e.g. buildTsLintConfig() in packages/rlc-common/src/metadata/buildTsConfig.ts, and it needs to be called from packages/typespec-ts/src/index.ts alongside the other tsconfig builders.
  • Expected content:
    {
      "extends": "../../../../tsconfig.json",
      "include": ["../src", "../test"]
    }
  • Why: This is used by eslint.config.mjs for type-aware linting (see Gap E).

Gap E: eslint.config.mjs missing parserOptions block for typed linting

  • Generated file: eslint.config.mjs
  • Codegen file: packages/rlc-common/src/metadata/buildESLintConfig.ts (the esLintConfigEsm template)
  • Current generated output:
    import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
    
    export default azsdkEslint.config([
      {
        rules: { ... }
      }
    ]);
  • Change needed: Update to:
    import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
    
    export default [
      ...azsdkEslint.config([
        {
          rules: { ... },
        },
      ]),
      {
        files: ["src/**/*.ts", "src/**/*.mts", "test/**/*.ts"],
        languageOptions: {
          parserOptions: {
            projectService: false,
            project: "./config/tsconfig.lint.json",
          },
        },
      },
    ];
    This explicitly points typescript-eslint to the dedicated lint tsconfig and disables automatic projectService detection, which is required for type-aware rules to work with the new config/ directory structure. (This pairs with Gap D — both are needed together.)

Gap F: Copyright header missing from vitest configs

  • Generated file: vitest.config.ts and vitest.browser.config.ts
  • Codegen file: packages/rlc-common/src/metadata/buildVitestConfig.ts
  • Change needed: Add the standard copyright header to output:
    // Copyright (c) Microsoft Corporation.
    // Licensed under the MIT License.

Gap G: Stale vitest.esm.config.ts not cleaned up on regeneration

  • Generated file: N/A (it's a file that should be deleted)
  • Codegen file: packages/typespec-ts/src/index.ts (the update/regeneration flow around line 611+)
  • Change needed: When regenerating an existing package (the shouldGenerateMetadata / update path), the codegen should delete vitest.esm.config.ts if it exists, since it is no longer needed.

Priority summary

Gap Impact Notes
A High Every newly generated package gets a broken test:node:esm script
B High build-test step is unnecessary and slows down browser tests
C High Missing type-check means test script doesn't catch type errors
D High Eslint typed linting fails without this file
E High Eslint can't resolve types for type-aware rules
F Low Cosmetic, but inconsistent with SDK convention
G Medium Only affects regeneration of existing packages that had the old config

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions