Skip to content

Enable verbatimModuleSyntax for @typespec/compiler [skip chg] - #11514

Merged
timotheeguerin merged 4 commits into
microsoft:mainfrom
timotheeguerin:type-import-pass-9
Jul 31, 2026
Merged

Enable verbatimModuleSyntax for @typespec/compiler [skip chg]#11514
timotheeguerin merged 4 commits into
microsoft:mainfrom
timotheeguerin:type-import-pass-9

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

Part of the incremental rollout of TypeScript's verbatimModuleSyntax across the workspace (batch 9, final).

Enables verbatimModuleSyntax: true for @typespec/compiler — the last and largest of the core packages.

Changes

  • Added "verbatimModuleSyntax": true to packages/compiler/tsconfig.json (inherited by tsconfig.build.json).
  • Converted type-only imports/exports to import type / export type across ~240 source and test files (via oxlint type-aware autofix).
  • Two imports in core/binder.ts and core/checker.ts (SymbolTable, TypeInstantiationMap) were hand-split to import type: each name is a types.js interface that is shadowed by a local runtime const … = class …, which the autofixer conservatively skips.
  • Kept the typekit barrel src/typekit/kits/index.ts as value export *. Those kits/* modules run defineKit(...) registration side effects at import time while only exporting type augmentations, so the autofixer's export type * would erase the modules and skip registration (the same trap fixed earlier for @typespec/http). Verified against the emitted dist that all 17 kit namespaces still register at runtime.

Validation

  • tsc -p tsconfig.build.json — 0 verbatim (TS1484/TS1205/TS1485) errors; full build (manifest, init-templates index, tsc, tmlanguage) passes.
  • oxlint --type-aware --deny-warnings clean.
  • End-to-end tsp compile of a sample spec succeeds; a runtime check confirms all 17 typekit namespaces (enum, model, operation, …) are registered.

Note: the scaffolding templates under templates/** are intentionally untouched — they are compiled by their own tsconfigs (not the compiler build) and shipped to users as plain starter code.

Standalone runtime emitters (http-client-csharp, http-client-java, http-client-python) remain out of scope, and tsconfig.base.json is intentionally untouched. This completes the workspace rollout.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Jul 31, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@11514

commit: cc083d0

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/compiler
Show changes

@timotheeguerin
timotheeguerin requested a review from Copilot July 31, 2026 16:34
Under verbatimModuleSyntax, tsc emits 'import { type X } from "mod"'
(all specifiers inline-type) as a bare side-effect 'import "mod"'. In
define-kit.ts this created a runtime edge define-kit -> program -> kits
that ran defineKit() before TypekitPrototype was initialized (TDZ).
Converting to 'import type { X }' fully erases the import, removing the
side-effect edges and fixing the cycle.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the workspace rollout of TypeScript’s verbatimModuleSyntax by enabling it for @typespec/compiler and updating the compiler’s sources/tests to use explicit type-only imports/exports where appropriate, while preserving runtime side-effect imports needed for typekit registration.

Changes:

  • Enable verbatimModuleSyntax: true for packages/compiler via tsconfig.json.
  • Convert many type-only imports/exports across compiler source and tests to import type / export type to prevent unintended runtime imports/exports under verbatim module semantics.
  • Adjust selected barrels/exports (e.g., YAML/types, formatter print types, server exports) to avoid emitting value exports for type-only symbols.

Reviewed changes

Copilot reviewed 248 out of 248 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/compiler/tsconfig.json Enables verbatimModuleSyntax for the compiler package build.
packages/compiler/src/init/init-template-validate.ts Type-only import conversion (needs a fix for typeof NoTarget with import type).
packages/compiler/src/lib/examples.ts Type-only import conversion (needs a fix for typeof NoTarget with import type).
packages/compiler/src/index.ts Converts several re-exports to export type to align with verbatim module semantics.
packages/compiler/src/config/index.ts Converts config surface re-exports to export type where applicable.
packages/compiler/src/yaml/index.ts Switches YAML types re-export to export type * to avoid runtime exports.
packages/compiler/src/server/serverlib.ts Splits LSP imports into type vs value imports to preserve runtime constants.
.chronus/changes/type-import-pass-9-2026-7-31.md Adds an internal changelog entry for the rollout.

Comment thread packages/compiler/src/init/init-template-validate.ts
Comment thread packages/compiler/src/lib/examples.ts
@azure-sdk-automation

azure-sdk-automation Bot commented Jul 31, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin timotheeguerin changed the title Enable verbatimModuleSyntax for @typespec/compiler Enable verbatimModuleSyntax for @typespec/compiler [skip chg] Jul 31, 2026
@timotheeguerin
timotheeguerin added this pull request to the merge queue Jul 31, 2026
Merged via the queue into microsoft:main with commit 3e307b1 Jul 31, 2026
33 checks passed
@timotheeguerin
timotheeguerin deleted the type-import-pass-9 branch July 31, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants