- Washington, DC, USA
- https://peculiarcharacter.com
-
A peculiar character.
- Joined on
cmdln
renamed repository from gitea_proof
to cmdln/git_proof
2 weeks ago
cmdln
transferred repository cmdln/server-rules
to Mastodon.Beer/server-rules
3 months ago
cmdln created repository Mastodon.Beer/server-rules
3 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsI also added some minimal project config since I don't use code.
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsThe body of the assertion function or type guard then is whatever logic you need or want to ensure the type is what you need it to be. Usually a lot of repetitive type and value checking. I have written some tidy utilities we can go over when you are ready to create guards and assertions on the fly, declaratively. ;)
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problems`document.getElementById` returns `HTMLElement
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problems...but after our assertion function, it is now the expected type. That is narrowing in action. If you think of an exception one branch of a conditional, the non-error case is another where we can safely say our type must be the one the assertion function checked.
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsIf you look at the type of e, hover over it in Code, here it is HTMLElement...
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsFunctions are first class in JS and TS and Typescript includes function typing that helps with this. The type of the `assertion` argument describes what is called an assertion function. Type guards and assertion functions are the answer to the most common question of, "How do I safely access a more specific type?"
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsI went a little deeper here but we can take time to unpack more.
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsI initially wanted to hate template literal strings but honestly, they are so damn convenient. I rarely preform string operations any other way. This may also be some Rust bias since that comes with powerful string formatting macros that *happen* to look like template literal strings.
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsThis is my style. I am leaning more and more into functional programmer. It all starts with `filter`/`map`/`reduce`.
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsI think the object literal short hand is idiomatic but I may be in the minority. The aliasing in the de-structuring assignments meant we could right the initializer this way because the field names also happen to match variables in scope. Very similar to template literal strings, see below.
4 months ago
cmdln commented on pull request ctmiller/menuplanner#1
Resolve type problemsDestructuring like this is fairly idiomatic. I also find it pretty erognomic when your types get more complex. Also, you can alias as part of this expression to avoid collisions.
4 months ago