AE
Size: a a a
AE
MS
GС
AE
AE
GС
A
class MyType {
constructor() {...}
}
class MyAdvancedType extends MyType {
constructor() {...}
}
class WorkerWithTypes<T extends MyType> {
constructor() {
let instance = new T(); // И ВОТ ТУТ ОШИБКА: 'T' only refers to a type, but is being used as a value here.
}
}к
class MyType {
constructor() {...}
}
class MyAdvancedType extends MyType {
constructor() {...}
}
class WorkerWithTypes<T extends MyType> {
constructor() {
let instance = new T(); // И ВОТ ТУТ ОШИБКА: 'T' only refers to a type, but is being used as a value here.
}
}к
к
const x = number.A
new T(), если я въявную указал, что T -- это таки тип? ну да, понятно: потому, что формально new T -- это вызов значения. Почему компилятор жалуется -- понятно. Как подобное делать?AK
class MyType {
constructor() {...}
}
class MyAdvancedType extends MyType {
constructor() {...}
}
class WorkerWithTypes<T extends MyType> {
constructor() {
let instance = new T(); // И ВОТ ТУТ ОШИБКА: 'T' only refers to a type, but is being used as a value here.
}
}к
new T(), если я въявную указал, что T -- это таки тип? ну да, понятно: потому, что формально new T -- это вызов значения. Почему компилятор жалуется -- понятно. Как подобное делать?A
к
к
class X { }🦉
class MyType {
constructor() {...}
}
class MyAdvancedType extends MyType {
constructor() {...}
}
class WorkerWithTypes<T extends MyType> {
constructor() {
let instance = new T(); // И ВОТ ТУТ ОШИБКА: 'T' only refers to a type, but is being used as a value here.
}
}к
к
к