#`declare global`. `:` and `=`. When to use what?

25 messages · Page 1 of 1 (latest)

sterile anchor
#

I currently have to explicitly state self (or this) as the first arg but I do not like it so much

declare global {
  var db: {
    actor?: {
      position: () => {
        distance_to_sqr: (...any) => any
      }
      change_health: (self: typeof db.actor, by: number) => void
    }
  }
}
#

I feel like = lets me assign while : is just for providing a type

tall wind
#

i feel like there's 3 separate questions here

#

what exactly is your question?

tall wind
sterile anchor
tall wind
#

this for the object is only captured in normal functions, not arrow functions

sterile anchor
#

I know this, I had it with function too in the delcare global, this is just any and I have to manually declare its type

tall wind
#

I currently have to explicitly state self (or this) as the first arg but I do not like it so much
this is completely unrelated to : vs =

sterile anchor
#

this: {health: number}

sterile anchor
tall wind
sterile anchor
#

because it does not exist in my mod

tall wind
#

???

#

how are you even accessing this?

sterile anchor
#

wdym how

#

this.

tall wind
#

what do you mean by "this is any"

#

you aren't accessing it

#

if you don't have an implementation, you can't access it

#

except as a return type i guess, but you aren't using that either

sterile anchor
#

!resolved

#

thanks