Skip to content

Instantly share code, notes, and snippets.

@va9iff
Created July 31, 2025 17:00
Show Gist options
  • Select an option

  • Save va9iff/e32dde1ce663151743f6c2cb6098cc26 to your computer and use it in GitHub Desktop.

Select an option

Save va9iff/e32dde1ce663151743f6c2cb6098cc26 to your computer and use it in GitHub Desktop.
Inferred empty arrays, even with static methods
class A {
static foo() {
return true ? [] : [ new this() ]
}
}
const arr = A.foo() // type: A[]
@va9iff
Copy link
Author

va9iff commented Jul 31, 2025

nevermind. I made it to be able to extend and then use .all while having the extended class type inferred. but no, if I do class B extends A{}; new B().all it still sees it as A[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment