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

Add typescript option #89

Closed
gregberge opened this issue May 12, 2018 · 10 comments
Closed

Add typescript option #89

gregberge opened this issue May 12, 2018 · 10 comments

Comments

@gregberge
Copy link
Owner

As mentioned in #38, it should be possible to generate a TypeScript file instead of a JavaScript file.
Some details are provided in #38

Usage in CLI

svgr --typescript

Usage in Node / Webpack

transform('...', { typescript: true })

As a result, it will use a TypeScript friendly package and change the extension to ".ts".

@gregberge gregberge added this to the v2 milestone May 12, 2018
@gregberge gregberge changed the title Add a typescript option Add typescript option May 12, 2018
@gregberge gregberge mentioned this issue May 12, 2018
8 tasks
@gregberge gregberge removed this from the v2 milestone Jun 12, 2018
@gregberge
Copy link
Owner Author

See previous work in #130.

@bntzio
Copy link

bntzio commented Oct 5, 2018

Any updates on this?

Thanks for SVGR btw! 👏😄

@TrySound
Copy link
Contributor

TrySound commented Oct 5, 2018

I think this should be left for user land. Because why not flow, and why not prop types? Template allows you to build anything.
https://gist.github.com/TrySound/d91557ff70e9a11318930a15a4394ea4

@gregberge
Copy link
Owner Author

Because Typescript is very very popular, and I think it should be supported out of the box!

@TrySound
Copy link
Contributor

TrySound commented Oct 5, 2018

Well, flow is also quite popular. I want it too like in my example :)

@nucab
Copy link

nucab commented Oct 18, 2018

Hopefully this get implemented soon. Looking forward to this :)

@TrySound
Copy link
Contributor

@noahjohn9259 you already may add ts template with config.

@gregberge
Copy link
Owner Author

TypeScript is already supported using a custom template. https://www.smooth-code.com/open-source/svgr/docs/typescript/

@alamothe
Copy link

alamothe commented Dec 19, 2018

@neoziro The custom template works great!

However, when I use it from CLI the output filenames still have .js extension. Is there a way to change extension to .ts? Thanks a bunch!

EDIT: Found --ext option! I suggest adding it to the TS doc.

@a7madgamal
Copy link

a7madgamal commented Aug 11, 2020

TypeScript is already supported using a custom template. https://www.smooth-code.com/open-source/svgr/docs/typescript/

the link is broken btw

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

No branches or pull requests

6 participants