Thomas Gideon cmdln
Loading Heatmap…

cmdln renamed repository from gitea_proof to cmdln/git_proof

2 weeks ago

cmdln pushed to main at cmdln/vimrc

2 months ago

cmdln pushed to main at Mastodon.Beer/server-rules

2 months ago

cmdln pushed to main at Mastodon.Beer/server-rules

2 months 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 pushed to main at cmdln/vimrc

3 months ago

cmdln pushed to main at cmdln/vimrc

3 months ago

cmdln pushed to main at cmdln/vimrc

3 months ago

cmdln commented on pull request ctmiller/menuplanner#1

Resolve type problems

I 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 problems

The 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 problems

If 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 problems

Functions 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 problems

I 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 problems

I 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 problems

This 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 problems

I 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 problems

Destructuring 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