Enable verbatimModuleSyntax for @typespec/compiler [skip chg] - #11514
Merged
timotheeguerin merged 4 commits intoJul 31, 2026
Conversation
commit: |
Contributor
|
❌ There is undocummented changes. Run The following packages have changes but are not documented.
Show changes |
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.
Contributor
There was a problem hiding this comment.
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: trueforpackages/compilerviatsconfig.json. - Convert many type-only imports/exports across compiler source and tests to
import type/export typeto 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. |
|
You can try these changes here
|
timotheeguerin
marked this pull request as ready for review
July 31, 2026 17:36
timotheeguerin
requested review from
RodgeFu,
bterlson,
catalinaperalta,
iscai-msft,
lmazuel,
markcowl and
xirzec
as code owners
July 31, 2026 17:36
timotheeguerin
enabled auto-merge
July 31, 2026 17:36
iscai-msft
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the incremental rollout of TypeScript's
verbatimModuleSyntaxacross the workspace (batch 9, final).Enables
verbatimModuleSyntax: truefor@typespec/compiler— the last and largest of the core packages.Changes
"verbatimModuleSyntax": truetopackages/compiler/tsconfig.json(inherited bytsconfig.build.json).import type/export typeacross ~240 source and test files (via oxlint type-aware autofix).core/binder.tsandcore/checker.ts(SymbolTable,TypeInstantiationMap) were hand-split toimport type: each name is atypes.jsinterface that is shadowed by a local runtimeconst … = class …, which the autofixer conservatively skips.src/typekit/kits/index.tsas valueexport *. Thosekits/*modules rundefineKit(...)registration side effects at import time while only exporting type augmentations, so the autofixer'sexport type *would erase the modules and skip registration (the same trap fixed earlier for@typespec/http). Verified against the emitteddistthat 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.--type-aware --deny-warningsclean.tsp compileof a sample spec succeeds; a runtime check confirms all 17 typekit namespaces (enum,model,operation, …) are registered.Standalone runtime emitters (
http-client-csharp,http-client-java,http-client-python) remain out of scope, andtsconfig.base.jsonis intentionally untouched. This completes the workspace rollout.