[typescript]: Missing line break with long generic parameter
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 2.6.2
Playground link
--parser typescript
--prose-wrap never
Input:
const hermesNotificationCancellationByUserTagSchema: ZodSchema<HermesNotificationCancellationByUserTag> =
z.object({
userTag: z.string(),
notificationType: z.nativeEnum(NotificationType).optional(),
})
const hermesNotificationCancellationByUserTagSchema: ZodSchema<
HermesNotificationCancellationByUserTag
> =
z.object({
userTag: z.string(),
notificationType: z.nativeEnum(NotificationType).optional(),
})
Output:
const hermesNotificationCancellationByUserTagSchema: ZodSchema<HermesNotificationCancellationByUserTag> =
z.object({
userTag: z.string(),
notificationType: z.nativeEnum(NotificationType).optional(),
});
const hermesNotificationCancellationByUserTagSchema: ZodSchema<HermesNotificationCancellationByUserTag> =
z.object({
userTag: z.string(),
notificationType: z.nativeEnum(NotificationType).optional(),
});
Expected behavior:
Im not sure if this is intentional, but I would expect both calls to end up as the second input (or a variation of it), and not as the first, as the first one violates the maximum line length.
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 linked Playground reproduction using the TypeScript parser and compare the two generic-parameter inputs with their formatted output. Trace the formatter behavior for long TypeScript generic parameters; done means both equivalent inputs produce a wrapped result that respects the maximum line length, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100