Friendica
treefit

treefit

treefit@fosstodon.org
treefit

treefit

treefit@fosstodon.org

Developer🧑‍💻 @ #deltachat with focus on #deltachat-desktop, sometimes also working on #deltachat-core and #deltachat-iOS.

I ❤️ #rust-lang, like #typescript and dislike coding in java.

ActivityPub
2022-11-02 18:12:11 2022-11-02 15:28:40 2022-11-02 15:28:38 1103652

treefit
treefit
mastodon - Link to source

treefit

2 years ago • •

treefit

2 years ago • •


Use typescript, they said. Your types will be safe, they said. 😭
type T = { h: number }
// As expected we get an error here
function justReturn(s: T): T {
  return { h: 7, hello: '' }
}
// Why are those working?
function returnVar(s: T): T {
  let t = { h: 7, hello: '' }
  return t
}
function returnConst(s: T): T {
  const t = { h: 7, hello: '' }
  return t
}

the error:
Type '{ h: number; hello: string; }' is not assignable to type 'T'.
  Object literal may only specify known properties, and 'hello' does not exist in type 'T'.
type T = {a:number}
function setState(cb: (prevState: T) => T) {}
// All good
setState((_prevState) => ({a: 12}))
// Proper error, also good
setState((_prevState) => ({b: 12}))
// oehm, typescript? No error? Maybe because of ...spread syntax?
setState((prevState) => ({...prevState, b: 12}))
// Event without spread syntax no type error??
setState((prevState) => ({a: prevState.a, b: 13}))
// But here tsc complains or what?
const test: T = {a: 12, b: 13}
  •  Languages
  •  Search Text
  •  Share via ...
in reply to treefit

Jikstra
mastodon - Link to source

Jikstra

in reply to treefit • 2 years ago • •
This just caused us one week of headaches on #deltachat #desktop because we still had an old property key in our state reducer after a refactoring. github.com/deltachat/deltachat…

Refactor chat_scroll to be immutable by Jikstra · Pull Request #2968 · deltachat/deltachat-desktop

Fixes #2956 Fixes #2953
GitHub
#deltachat #desktop
  •  Languages
  •  Search Text
  •  Share via ...

treefit reshared this.

in reply to Jikstra

treefit
mastodon - Link to source

treefit

in reply to Jikstra • 2 years ago • •

In other words, the bug where desktop (test version 1.33) kept scrolling to the top of a chat is solved now thanks to @jikstra.
That was one of the blocking bugs that are delaying the desktop 1.34 release.

#deltachat_desktop #deltachat

#deltachat #deltachat_desktop @Jikstra
  •  Languages
  •  Search Text
  •  Share via ...
in reply to treefit

lil5  🚲 🇳🇱
mastodon - Link to source

lil5 🚲 🇳🇱

in reply to treefit • 2 years ago • •
in the first image I think it is because typescript gives up after the first error
  •  Languages
  •  Search Text
  •  Share via ...
in reply to lil5 🚲 🇳🇱

treefit
mastodon - Link to source

treefit

in reply to lil5 🚲 🇳🇱 • 2 years ago • •

@lil5 😂

order does not matter actually, but nice explanation ;)

@lil5 🚲 🇳🇱
  •  Languages
  •  Search Text
  •  Share via ...
⇧