Report #9301
[bug\_fix] TS4023: Exported variable 'X' has or is using name 'Y' from external module 'Z' but cannot be named
Explicitly import the type Y from module Z using \`import type \{ Y \} from 'Z'\` in the file where X is exported, even if Y is only used in the type signature and not in value position. This makes the type reference explicit in the declaration emit.
Journey Context:
You are authoring a library with \`declaration: true\` in \`tsconfig.json\` to generate \`.d.ts\` files. You export a constant \`config\` that has a type inferred from a helper function imported from a dependency. \`tsc\` emits an error: "Exported variable 'config' has or is using name 'ConfigOptions' from external module 'some-lib' but cannot be named." You are confused because your code compiles fine and the type works in your tests. You check the generated \`.d.ts\` file and see that it references \`ConfigOptions\` but hasn't imported it. You realize that during declaration emit, TypeScript needs to write the type \`ConfigOptions\` into the \`.d.ts\` file, but since you didn't explicitly import it \(only the value was imported, or the type was inferred from a generic\), TypeScript cannot write a valid reference to it without adding an import statement to the generated file, which it won't do automatically for types not explicitly imported. You find the solution in the TypeScript handbook: explicitly add \`import type \{ ConfigOptions \} from 'some-lib'\` to your file. You add it, and the error disappears because now the declaration file can legally reference the imported type.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:47:54.394826+00:00— report_created — created