Repository navigation
Conversation
TypeScript type-only imports and re-exports are erased by tsc, Babel and
Metro, so they can never change runtime behavior. Recording them as
dependency edges made impact analysis select far more modules than a
change can actually reach, especially through shared route/params type
files that import a type from every feature.
The scanner now skips:
- import type X / import type { A } / import type * as N from "x"
- export type { A } from "x" / export type * (as N) from "x"
- import { type A, type B } from "x" (all specifiers type-only)
Mixed lists such as import { type A, b } keep the edge and only select
the runtime specifiers. A default import named type (import type from
"x", import type, { a } from "x") and bindings named type
(import { type }, import { type as alias }) are now parsed correctly.
Bump SCANNER_VERSION to scan-file-v2 so cached scan results produced by
the old scanner are invalidated.
adelbeke
marked this pull request as ready for review
November 7, 2026 11:43
This branch has not been deployed
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.
Why
TypeScript type-only imports and re-exports are erased at build time by tsc, Babel and Metro. They cannot change what runs, so they should not be dependency edges for E2E impact analysis.
Sniffler 0.5.0 skips the
typekeyword and still records the edge. On typed apps this links modules that never depend on each other at runtime. A common case in React Native apps is a navigation params file that doesimport type { XStackParamList } from "<each feature>": every feature then looks like it depends on every other feature through that one file, and almost any change selects almost every test.Measured on a React Native app of about 1,700 modules, replaying real pull requests with a patched scanner:
What changes
The scanner (
src/scanner/scan-file.ts) no longer records:import type X from "x",import type { A } from "x",import type * as N from "x"export type { A } from "x",export type * from "x",export type * as N from "x"import { type A, type B } from "x"(every specifier is inlinetype)Mixed lists such as
import { type A, b } from "x"andexport { type A, b } from "x"keep the edge, and only the runtime specifiers (b) go into the entity selection.It also fixes two parsing cases around the
typekeyword that 0.5.0 got wrong:import type from "x"(a default import namedtype) was dropped; it is now a runtime default import.import type, { a } from "x"keeps working.import { type as alias } from "x"was read as a type-only import ofalias; it is now the bindingtypealiased toalias.Local
export type { A }(nofrom) still emits local exports, as before.Other changes:
SCANNER_VERSIONis bumped fromscan-file-v1toscan-file-v2, so caches written by the old scanner are invalidated instead of reusing type-only edges.tests/impact-cache.test.tsnow uses the constant instead of the literal.src/scanner/scan-file.js(the committed compiled copy that tests import) is regenerated from the.tssource withtsc -p tsconfig.build.json; it matches the build output byte for byte, minus the source map comment.Tests
tests/scanner.test.ts: newtype-only imports and exportssuite covering all the forms above, the non-regressions (import type from,import type, { a } from,import { type },import { type as alias },import {} from, side-effect imports), mixed inline specifiers, and inlinetypein re-exports. The existing first test expectedimport type { Value }to produce an edge; that expectation is removed.tests/graph.test.ts: a graph and traversal test showing a change to a module imported only through type-only imports affects only that module.pnpm test: 33 files, 228 tests passing.pnpm lintandpnpm buildpass.pnpm benchmark(synthetic graph, 1,441 files), master vs this branch, in hz:No regression, within noise.
Notes for review
verbatimModuleSyntax(or BabelonlyRemoveTypeImports),import { type A } from "x"is kept as a side-effect importimport "x". This PR follows the default tsc and Babel behavior (the whole import is removed). If you want to support that mode, a config flag could keep the edge for all-inline-typeimports. Happy to add it if useful.pnpm benchmark:app.🤖 Generated with Claude Code