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
casting to StemmableNote removed #1182
Conversation
@ronyeh taking into consideration this changes, I believe that |
Thanks for the change, Rodrigo. Can you fix the conflicts from the last merge please? |
I'm OK with adding all the relative paths (e.g., ../src/). That will avoid
any ambiguities like Element or Util. Feel free to do a search and replace
and submit a PR on this.
The only consideration is that VS code auto imports using the short form.
We might end up with a mix of styles (which is what we had before I made
all the tests consistent). I wonder if there is a setting that I'm missing
that forced vs code to auto import with relative paths. I can do some
research on this when I'm back with my computer.
…On Sat, Oct 16, 2021, 11:46 AM Rodrigo Vilar ***@***.***> wrote:
@0xfe <https://github.com/0xfe> done, ready to merge.
@0xfe <https://github.com/0xfe> @ronyeh <https://github.com/ronyeh> I had
to include the path in the import from util from RuntimeError in
renderer_text. VSCode was considering a Node internal module. As a
consequence I would prefer to add all the paths. Of course in another PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1182 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB2MCLMIR535PNRDW5WNNTUHHB67ANCNFSM5FT4ZXMA>
.
|
@0xfe this one should be ready |
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.
Thanks for the change Rodrigo, but digging in, it feels like we're losing more than we're getting. A lot of the useful type information captured in the code is now muddied because everything is being treated as a Note
, which IMO is too crude of an abstraction.
This PR is titled "casting to StemmableNote removed", but it looks like we're removing all references to StemmableNote, regardless of utility.
For example, the following feels unnecessary:
- function applyStemDirection(group: StemmableNote[], direction: number) {
+ function applyStemDirection(group: Note[], direction: number) {
@@ -29,7 +28,7 @@ function calculateStemDirection(notes: StemmableNote[]) { | |||
return Stem.UP; | |||
} | |||
|
|||
function getStemSlope(firstNote: StemmableNote, lastNote: StemmableNote) { | |||
function getStemSlope(firstNote: Note, lastNote: Note) { |
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'm trying to understand the rationale here -- it feels like we're replacing compile-time checks with runtime checks. It's good to have StemmableNote
a parameter here (you can't beam notes are not stemmable.)
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.
We had no compile check Beam
is being instantiated using as StemmableNote
:
const notes = voice.getTickables() as StemmableNote[];
const beams = [
f.Beam({ notes: notes.slice(0, 2), options: { autoStem: true } }),
f.Beam({ notes: notes.slice(2, 4), options: { autoStem: true } }),
f.Beam({ notes: notes.slice(4, 6), options: { autoStem: true } }),
f.Beam({ notes: notes.slice(6, 8), options: { autoStem: true } }),
f.Beam({ notes: notes.slice(8, 10), options: { autoStem: true } }),
f.Beam({ notes: notes.slice(10, 12), options: { autoStem: true } }),
];
The usage of Please note that:
|
Here there was also no compile check as the function was instantiated with:
which also uses |
Thanks Rodrigo. In those cases, the Re: |
@0xfe This is ok. The reason I had:
@ronyeh do you have a suggestion on how to reduce the ammount of casting/type-assertions |
Adding a few methods to
Note
it is possible to remove all the casting toStemmableNote
in the source base. I find this generalisation very useful.The method in
Note
are then overloaded inStemmableNote
. The changes are not complex.Several
ts-nocheck
resolved.No Visual differences.