-
Notifications
You must be signed in to change notification settings - Fork 352
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
TypeScript Support branch #223
Conversation
Great work so far in getting the codebase to compile under TypeScript! As you did note, most of the important arguments and parameters are lacking proper typing, and as such we're not really leveraging the most out of TypeScript yet. Do you plan to work on typifying those in this PR? |
@KiChjang completely agree. I am certainly willing to work on adding proper types in this PR.
|
Hmm... on second thought, it may be better to open a new PR just for the typings, as the current PR already has quite a lot of lines changed, and would increase the review burden. I certainly would want to have your PRs reviewed and merged ASAP, so perhaps this is the better way. |
Need more review or you will take that @KiChjang? Let me know. |
@@ -111,9 +111,9 @@ const loadAccounts = (state, dispatch) => { | |||
asyncLoadAccounts(); | |||
}; | |||
|
|||
const SubstrateContext = React.createContext(); | |||
const SubstrateContext = React.createContext(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the compiler complain if you leave out the undefined
parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, React.createContext()
requires 1 parameter (a default value). So passing in undefined
here should have the exact same behavior, as I understand it.
src/templateModule.tsx
Outdated
const [currentValue, setCurrentValue] = useState(0); | ||
const [formValue, setFormValue] = useState(0); | ||
const [currentValue, setCurrentValue] = useState('0'); | ||
const [formValue, setFormValue] = useState('0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect TypeScript isn't happy about the state being both a string
and a number
, hence why you had to change the argument to a '0'
, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct
@kamikazebr I appreciate the volunteering! I've been writing Rust for a while, so my knowledge of the TypeScript setup is a little rusty (no pun intended). As far as I remember, one can configure TypeScript compiler to operate in many ways, such as compiling first to JS via babel to achieve browser compatibility, or use TS files directly to serve pages. I haven't really figured out what the best strategy to use yet, so perhaps you could review that part and offer your opinions. I'd also like to ask other maintainers like @nukemandan and see what they prefer for the TS compilation strategy. |
@jimmychu0807 created the PR. The idea of having 1 PR that smaller ones will be point to is good, but not sure if it is mandatory. |
* Remove the traces on custom type and update to based on Node v16 * webpack 5 migration * Rm eslint related dev-dependencies & use URLSearchParams over querystring * Updated to the latest polkadot-js libs * Integrate with prettier * Friendlier connection failure message. * Refactored current selected account into SubstrateContext * bugfix * Fix console warning * Update README * Update to solve a yarn berry issue
@tarrball yes. I mean to retarget the PR to @wirednkod @kamikazebr maintaining both js and ts is not my intention as well. As mentioned above, we probably maintain BOTH branches only for a short period of time, say a month or less, and then once the ts version got tested and stablized, it will be merge into main. For maintenance, I suggest that for those prefer js, they can download the Btw, I made an improvement in the PR #225 that the |
Substrate developer hub main
Merged in updates from #225 & resolved conflicts. There's still some issues building TypeScript with the newly added |
@tarrball thank you for the effort of translating the project to ts version. The code is merged to |
The project is not building for me on the
|
@nukemandan This PR migrates the template over to TypeScript (addressing issue #205).
Couple issues of note:
any
to make the linter/compiler happy. It would be nice to clean these up and make the TS config more strict, but that will be a larger time investment.