Answer the question
In order to leave comments, you need to log in
Is it possible in TypeScript to make a constant method like in C++?
Just academic interest =)
In general, TypeScript has everything you need, except for one type check.
class Foo {
public biz = 0
bar(this: Readonly<Foo>) {
this.baz() // <-- Тут происходит, как бы, неявный каст типа Readonly<Foo> в просто Foo
}
baz(this: Foo) { // Даже если здесь я явно укажу тип для this
this.biz = 5
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question