TypeScript Version: 2.5.3
Code
export interface ISlicedTableData {
origin: RawTableData;
}
if (tableData instanceof ISlicedTableData) { // <- compilation error here.
}
Expected behavior:
no compilation error, and ts checks tableData is a implementation of ISlicedTableData or not
Actual behavior:
compilation error: 'ISlicedTableData' only refers to a type, but is being used as a value here.
Interfaces only exist at compile-time and are removed after compilation, so that code makes no sense at run-time.
Thanks @Ghabriel
Is there any suggestion to do the type checking at runtime with an interface?
You can try using type guards for that.
Most helpful comment
Interfaces only exist at compile-time and are removed after compilation, so that code makes no sense at run-time.