-
Notifications
You must be signed in to change notification settings - Fork 36
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
Initial Typescriptification of tko.utils #62
base: main
Are you sure you want to change the base?
Conversation
To make it easier to see the changes to each file, I think it would good to split this into two commits. The first just renames the files and the second has the actual changes. |
You're right. I will do it evening. |
Using |
@caseyWebb No, that does unfortunately does not work. If do a I have committed again, changes are visible in second commit. The Github diff causes the same issues. |
It appears the rollup Typescript plugin is not really being maintained, and having multiple issues: rollup/rollup-plugin-typescript#116 |
[x-ref]: Profiscience/knockout-contrib#25 (comment) Just want to get clarification, are we going for TS or JS source for TKO? I'd started playing around with wiring up type-checking unobtrusively (only a handful of files), but I'm all for actually using TS the way it's intended to be used. If that is the case, I can start bringing in bits and pieces of knockout-contrib (see issue above). @Sebazzz I didn't realize you still had to commit the move as a separate commit. That is... not optimal. Silly git. |
This is great, thanks @Sebazzz . There are a couple things I'd like to understand.
None of these are blockers, but I feel it important to voice these concerns to make sure I understand the implications. Typescript might be a great foundation for the TKO/KO future, but I'd at least like to know about the options before we commit to this fairly hefty change. Thanks @Sebazzz — really appreciate your effort here, and hope to have these issues clarified soon! |
Been down the coffeescript road before as well and regretted it immensely. That said, TS is a different beast, because JS is TS (without types, which without Personally, I really think the benefits outweigh any potential negatives. I didn't really "get it" until I used it with VS Code and remembered how nice actual autocomplete and go-to-implementation were. It has significantly increased the robustness of our codebase since we began using it at work. |
Also, typescript is transpiling to standard JS. The result usually looks good with no strange additions in the generated js code. |
Please note that Typescript found already two actual bugs in the codebase. I understand the doubt, but the benefits of type safety are already showing. And this is just one small component that has been transformed. The basic Typescript escape plan is:
Typescript continues to aim to be compatible with ES language specs, and the features which aren't are marked expirimental and needs to be manually enabled (and shouldn't you use anyway in a distributed library).
(your link is broken, you appear to reference this issue) |
Great feedback, thanks all. It definitely sounds like the benefits are there, and there's a lot of momentum behind TS so I can see how it's distinguished from Coffeescript. I've never used Prettier - but it seems to solve same pain as StandardJS. I'd prefer @knockout/core — Any thoughts on TS & the tools? Unless there are major objections & concerns, or information I don't know, I'm inclined to agree to moving to strict TS. |
I prefer explicit semicolons over automatic semicolon insertion. The reason is that the latter may be ambiguous (another example), so in some situations you are required to use semicolons. In my opinion it is better to be consistent and then use them everywhere and I believe it is good practice in general. And this is personal taste: I'm able to parse code faster with semicolons because you can quickly scan where each statements ends. But perhaps this is old fashioned. |
The main argument to not include semis at this point is because the diffs will have a poor signal-to-noise ratio i.e. any semantic differences will be indistinguishable from semicolon injection. We can revisit the semicolon after, but for the JS→TS PRs we should keep the diffs crisp. |
I understand that. You would still need to configure prettier to use the current coding standard as much as possible, otherwise the noise in the diff will be too high, it is good to be aware of that. |
Prettier is less a linter and more a formatter. Like StandardJS, it's opinionated and has minimal configuration options. While ESLint/TSLint can do some formatting, it is the primary goal of prettier, so it's a lot more powerful. If you've ever worked in go, it's akin to gofmt. In fact, we may find we want to use it with ESLint/TSLint to catch issues related to quality and not style. I think it may be best to format the entire codebase in a separate PR to get all of the noise out of the way up front. (That said, I still don't like semis...) P.S. @Sebazzz Let me know if/what help you need with the Rollup side of this |
@caseyWebb Thanks. I'm unable to get actual compilation of Typescript working with the current configuration. So I could definitely use some help there :) It appears Rollup is currently configured to take an |
Just a quick note - I've investigated a bit and am 100% on board with Typescript. I'm pulling in the PR #50 to bring TKO up to speed with Knockout 3.5/6, and then this is on the list. |
Work in progress
As discussed in #6, initial Typescriptification of the core
tko.utils
package. This first pull request will set the direction for further Typescriptification, so let's get it right 😄Notes:
any
though I have attempted to minimalize ittslint
config file for Typescript lintingnode_modules
symlinkThere are still some pending issues, which I am currently not being able to work out due to my unfamiliarity with rollup:
index.js
of a package, but in this case we have aindex.ts
. What can be done here? Possible solution:rename allnope that does not work, rollup attempts to parse Typescript now.index.js
toindex.ts
this
parameter in many of the array utils due to compilation errors. Typescript doesn't appear to correct method resolution.