Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index.js template typescript support #462

Closed
laitine opened this issue Jul 1, 2020 · 12 comments · Fixed by #670 · 4 remaining pull requests
Closed

index.js template typescript support #462

laitine opened this issue Jul 1, 2020 · 12 comments · Fixed by #670 · 4 remaining pull requests

Comments

@laitine
Copy link

laitine commented Jul 1, 2020

🚀 Feature Proposal

Option for index.js to customize the file extension.

Motivation

Complementing the typescript support adding an option for the index.ts to be generated would offer direct support for generating all files with .ts file extension.

Example

CLI: Override: --index-template-ext 'ts'

API Override: indexTemplateExt: 'ts'

@open-collective-bot
Copy link

Hey @laitine 👋,
Thank you for opening an issue. We'll get back to you as soon as we can.
Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers.
If you use SVGR at work, you can also ask your company to sponsor us ❤️.

@laitine
Copy link
Author

laitine commented Jul 1, 2020

An alternative naming could be

Example

CLI: Override: --index-ext 'ts'

API Override: indexExt: 'ts'

@gregberge
Copy link
Owner

Generated template has the .ts extension with TypeScript open isn't it? I am sorry, I don't understand the problem.

@stale
Copy link

stale bot commented Sep 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 25, 2020
@laitine
Copy link
Author

laitine commented Sep 26, 2020

As described in https://react-svgr.com/docs/options/ typescript is indeed supported by --typescript for the icon files but not the index file. It would be more obvious and better supported if the "index.js" could also be directly generated as "index.ts". The current situation requires additional config for development environments that only include files with typescript file extensions (.ts, .tsx) into compilation for example. Currently I have to generate the icon component index with a separate script because the index file is not generated as typescript.

@stale stale bot removed the wontfix label Sep 26, 2020
@stale
Copy link

stale bot commented Nov 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 25, 2020
@stale stale bot closed this as completed Dec 2, 2020
@hipstersmoothie
Copy link

This would be nice to have stale bot

@MateusAndrade
Copy link

This would be nice! Currently, I'm renaming the index.js to index.ts using a shell. 😅

@laitine
Copy link
Author

laitine commented Jan 28, 2022

Seems to be gaining traction, should be re-considered?

@gregberge
Copy link
Owner

@gregberge using TypeScript option, the generated index should be index.ts actually it is index.tsx. I make a fix.

@demedos
Copy link
Contributor

demedos commented Jan 16, 2023

It would be nice to have this as an option; my index is in tsx format, and I have to run mv after the svgr script to get the right file extension.

@carlosfpo
Copy link

@gregberge would you consider have the extension be configurable between '.ts' | '.tsx'? This is because if anyone intends to have jsx in the index file, the .ts won't allow it and additional scripting must be done in order to change the extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment