microsoft / microsoft/TypeScript
Unexpected declaration error when using symbols and intersections
Open
Nobody has claimed this yet.
Bug
Domain: Declaration Emit
Help Wanted
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
- declarations
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about generating declarations.
⏯ Playground Link
💻 Code
// @filename: logger.ts
export const LoggerURI = Symbol("Logger");
export type LoggerService = { foo: string } & {
[LoggerURI]: { bar: string };
};
// @filename: api.ts
import * as Logger from "./logger";
export declare const fnW: <A, B>(a: A) => (b: B) => A & B;
export declare const fn: <A>(a: A) => (b: A) => A;
declare const x: Logger.LoggerService;
// ❌🤯
// Exported variable 'a' has or is using name 'LoggerURI' from external module "file:///logger" but cannot be named.(4023)
export const a = fnW(x);
// ✅
export const b = fn(x);
🙁 Actual behavior
Unexpected type error:
Exported variable 'a' has or is using name 'LoggerURI' from external module "file:///logger" but cannot be named.(4023)
🙂 Expected behavior
No type error. LoggerURI is exported so it can be named.
Additional information about the issue
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Playground link and the logger.ts and api.ts reproduction, comparing the exported results of fnW(x) and fn(x). Verify declaration generation and the reported 4023 diagnostic; done means the fnW case produces no unexpected error while retaining usable exported declarations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100