-
Notifications
You must be signed in to change notification settings - Fork 75
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
tsconfig "reactNamespace" setting #114
Comments
Hmmm as I look at the docs it looks like If you use TypeScript support for JSX libraries that aren’t React is still somewhat lacking. For instance, we use symbols to represent special elements like In any case, I think the config settings are for users, and it doesn’t really matter what configuration flags the crank repository has set in TSConfig, though I may be wrong. Re: why not a default module.. Maybe, but that would mean having to reexport every export in the Crank module a second time. I’m personally not a fan of default exports, but if you can come up with a compelling reason why Thanks for checking out Crank! |
Thanks for the detailed response. To your last point, having a default export would allow you to do this as well: import Crank, { Context } from '@bikeshaving/crank'; With the import * as Crank from '@bikeshaving/crank';
import { Context } from '@bikeshaving/crank'; Also
you shouldn't have to. I made myself a little wrapper module to achieve this import effect I'm after, which I think could translate to your code fairly easily. // crank.ts wrapper module
export * from '@bikeshaving/crank';
import * as Crank from '@bikeshaving/crank';
export default Crank; then in a component file... // some-component.tsx
import Crank, { Context } from './crank'; Of course, it would be nice to not need this wrapper. 🙂 |
I’m sympathetic to this problem; I wish you could do stuff like |
Have you considered taking advantage of TypeScript's
reactNamespace
setting? If you add the following to your tsconfig,you can skip the
/* @jsx createElement */
comments and instead doIf crank had an
export default
, you could write it even shorter, just as conveniently as React:I think this should at least be mentioned in the TS docs. It reduces boilerplate (especially if you have lots of .tsx files) and might make React devs feel more at home. 🙂
Just giving you some food for thought. I love the idea behind this library!
The text was updated successfully, but these errors were encountered: