Closed guoshencheng closed 5 years ago
@Yomguithereal my PR at DefinitelyTyped has been merged.
So, you made DefinitelyTyped accept a PR for a definition that covers this PR, while it has not yet accepted?
@yuchi the PR at DefinitelyTyped has been merged. i don not know why the DefinitelyTyped merged without author 's agreement. Sorry It's my first PR for that and am i made a big trouble?
Well, now TypeScript users will think that they have to use blessed-**
in their JSX, while this is not supported at all. To avoid confusion from users I believe @Yomguithereal must now quickly react to this issue, find a solution, and (eventually) provide a patch to DefinitelyTyped.
Not a big problem IMO, but you are forcing the hand on @Yomguithereal a bit :)
Also, I don‘t believe that plan b
is a good commit message 😅
What's more I am now completely lost :). Can someone recap all this?
button
component, which is both in HTML and react-blessed. TypeScript is not happy to overwrite the standard React button
definition, and errors.render()
entry point to have unique names, and therefore be able to add types.blessed-
, for example <blessed-button … />
. Those will never collide with standard HTML elements, and can be perfectly typed in TypeScript.blessed-*
types — expecting the reviewers to wait for the react-blessed authors for approval.blessed-*
elements on autocomplete, and those will not work since this PR has not been merged (and released!) yet.I personally believe that @guoshencheng proposal here is perfectly coherent and way better than the one he suggests on #85. Since using blessed-box
instead of box
is optional but brings types, the choice is completely in the hand of the user (either library or app developer) and brings no compatibility issue that would arise with #85 (what if I rename button
to btn
but a library uses button
?).
My opinion in short: after a good commit squash (sorry I’m a git history purist!) this PR solves the issue perfectly at the cost of some more typing for users.
The only other way would be to go in the react-pdf way (relevant snippet here):
// react-blessed
export const Box = 'box';
export const Button = 'button';
// ...
// some-app.js
import React from 'react';
import { render, Box, Button } from 'react-blessed';
render(<Box … />)
This would let @guoshencheng make TypeScript think that Box
etc. are not strings, but concrete React.ComponentType<Props>
.
thanks to @yuchi ! you make a better solution for less typing and it make the relations between tag and bless's component to be controlled by react-blessed
self. I would consider to recode my merge request in one or two days.
I don't like much the
import { Box, Button } from 'react-blessed';
solution. It's hard to maintain and tedious. But typing blessed-button
also is in a way. The way typescript interacts with react and/or jsx seems very precarious to me though. Anyway I would vouch for the solution of this PR. Let me just review the PR. (On a side note, there is no scheme such as the jsx pragma for TypeScript to handle those kind of cases gracefully?)
So is the PR ok for everyone involved? Can I merge and release in a near future?
So is the PR ok for everyone involved? Can I merge and release in a near future?
It's ok
Perfect :+1: (IMHO)
But I suggest @Yomguithereal to squash all commits into a single one, or use an explicit merge commit.
v0.4.0 is now released on npm.
For what it's worth, this is in part @types/react
's fault. The types in there are too DOM specific (considering React is used without the DOM in many places). There is an effort to fix this, which when done will allow react-blessed
types to reuse DOM element names.
Use
<blessed-xxx / >
instead of<xxx />
And add a typing definition PR at DefinitelyTypedTo be honest. the plan is not so excellence. but It's my final plan.