Skip to content

fix: preserve type-level syntax that was being dropped when printing - #159

Merged
manuel3108 merged 1 commit into
sveltejs:mainfrom
MathiasWP:fix/preserve-type-level-syntax
Aug 7, 2026
Merged

fix: preserve type-level syntax that was being dropped when printing#159
manuel3108 merged 1 commit into
sveltejs:mainfrom
MathiasWP:fix/preserve-type-level-syntax

Conversation

@MathiasWP

Copy link
Copy Markdown
Contributor

Four visitors carried type-level information on the node but never printed it. Each is a silent change of meaning — the output still parses, so nothing surfaces until the types are wrong.

Optional tuple elementsTSNamedTupleMember.optional

type Tuple = [required: string, optional?: number];      type Tuple = [required: string, optional: number];

Accessor signaturesTSMethodSignature.kind

interface Accessors {                interface Accessors {
	get value(): string;            	value(): string;
	set value(next: string);         	value(next: string);
}                                    }

Two accessors become two call signatures for the same method — a different (and, with differing parameter/return types, invalid) interface.

Instantiation expressions in typeofTSTypeQuery.typeArguments

type Instantiated = typeof identity<string>;      type Instantiated = typeof identity;

Explicit type arguments on JSX elementsJSXOpeningElement.typeArguments

const list = <List<string> items={items} />;      const list = <List items={items} />;

Both @sveltejs/acorn-typescript and oxc-parser populate all four properties under the same names, and both now produce identical output for each case.

One incidental change: expected.tsx is added to .prettierignore, next to the expected.ts and expected.jsx entries that were already there. The snapshot harness writes these files without a trailing newline, so lint fails on the first .tsx sample in the repo. #155 adds the same line for the same reason — whichever lands second will need that hunk dropped.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 5, 2026

Copy link
Copy Markdown

Install the latest version of esrap from e755f39:

pnpm add https://pkg.svelte.dev/esrap/c/e755f394528f20f4721f8ae3c67d34c6db2c3e18

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/esrap/pr/159

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e755f39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
esrap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@manuel3108
manuel3108 merged commit b7749d1 into sveltejs:main Aug 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants