Skip to content

Allow type_alias argument to prefer them over interfaces - #77

Open
hgiesel wants to merge 7 commits into
madonoharu:mainfrom
hgiesel:feat/type_alias
Open

hgiesel wants to merge 7 commits into
madonoharu:mainfrom
hgiesel:feat/type_alias

Conversation

@hgiesel

@hgiesel hgiesel commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

(see #80)

Adds the type_alias argument to #[tsify] to conditionally generate type aliases instead of interfaces.

I had to reformat a lot of tests to use indented type aliases, because inline types do not support doc comments at all.
So what was previously:

export type NonIdentifierRenameEnum = { "hello-world": boolean; } | { "hel#&*world": number; } | { "hello world": string; } | { "": number; } | { should_not_quote: string; };

Will now become this:

export type NonIdentifierRenameEnum = {
    "hello-world": boolean;
} | {
    "hel#&*world": number;
} | {
    "hello world": string;
} | {
    "": number;
} | {
    should_not_quote: string;
};

Closes #61

@hgiesel hgiesel mentioned this pull request Feb 26, 2026
@siefkenj

Copy link
Copy Markdown
Collaborator

Sorry, I merged some PRs and now there are some conflicts to clean up...

This idea looks nice, but I find the name type_alias confusing. (To me, I would expect type_alias = "bla bla...")

Maybe convert_as_type or convert_as_interface = false. @madonoharu Did you have any opinion here?

@hgiesel

hgiesel commented Mar 2, 2026

Copy link
Copy Markdown
Contributor Author

Maybe convert_as_type or convert_as_interface = false

How about as_type_alias, or prefer_type_alias. I'd refrain from just calling it type, because an interface is a type too.

@siefkenj

siefkenj commented Mar 8, 2026

Copy link
Copy Markdown
Collaborator

Let's go with as_type_alias.

This all looks good. Would you be able to add an example to the readme?

This was referenced Aug 23, 2026
@madonoharu madonoharu added this to the 0.6.0 milestone Aug 29, 2026
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.

Option to generate Types instead of Interfaces

3 participants