microsoft / microsoft/TypeScript

TS4082 occurs when using `composite: true`

Open
#54,878 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs More Info
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

TS4082, composite

🕗 Version & Regression Information
  • I was unable to test this on prior versions because composite is a new feature added to typescript (not actually)
⏯ Playground Link

Playground link with relevant code

💻 Code
// This throws
export default (
	a = () => {
		interface Props {}
		return {} as Props
	},
) => {};

// This works
let a = () => {
	interface Props {}
	return {} as Props
}
🙁 Actual behavior

When composite is enabled, the export default statement throws TS4082. And disabling composite fixes this issue.

🙂 Expected behavior

They should both throw, or both not throw :(

This issue only occurs when using an interface. Using a type alias won't cause this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked TypeScript Playground reproduction with composite enabled, then compare the exported and local callbacks and the interface and type-alias cases. Trace the compiler path that reports TS4082 and add a regression test; done means the two equivalent callback forms have consistent behavior without regressing the existing type-alias case.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.