#Adding properties to functions

1 messages · Page 1 of 1 (latest)

brave epochBOT
#
OnkelTem#4669

Preview:```ts
function foo() {}
foo.randomProp = 1

function bar() {
return function baz() {}
}

const baz = bar()
baz.randomProp = 1```

tardy anvil
#

Why the first assignment works while the second doesn't?

#

How to still assign the randomProp in the latter case?

odd dome
#

you can annotate the type of baz to tell typescript it can have a randomProp property: