, Typescript , IStore , SomethingElse
(, #/Java ..) , . , :
interface IStore {
__isStore: true
}
interface SomethingElse { a: number; }
class AppStoreImplemetion implements IStore {
__isStore!: true
}
class SomethingImplementation implements SomethingElse {
a = 4;
}
class Foo {
selectSync<T extends IStore>(): T {
return <T>{ };
}
}
new Foo().selectSync<AppStoreImplemetion>();
new Foo().selectSync<SomethingImplementation>();
, , __isStore, , , IStore, - , Typescript , :
class SomethingImplementation implements SomethingElse {
a = 4;
__isStore!: true
}
new Foo().selectSync<SomethingImplementation>();
IStore, , , .
100% - , , IStore . , :
abstract class IStore {
private __isStore!: true
}
interface SomethingElse { a: number; }
class AppStoreImplemetion extends IStore {
}
class Foo {
selectSync<T extends IStore>(): T {
return <T>{ };
}
}
new Foo().selectSync<AppStoreImplemetion>();
class SomethingImplementation implements SomethingElse {
private __isStore!: true;
a = 10;
}
new Foo().selectSync<SomethingImplementation>();