I've been attempting to create an extension method for Observable
import { Observable } from 'rxjs/Observable';
declare module 'rxjs/Observable' {
interface Observable<T> {
customFilter<T>(this: Observable<T>): Observable<T>;
}
}
function customFilter<T>(this: Observable<T>) {
return this;
}
Observable.prototype.customFilter = customFilter;
However, I keep encountering a compilation error
ERROR in src/app/utils/observable.extensions.ts(13,1): error TS2693: 'Observable' only refers to a type, but is being used as a value here.
Here is my tsconfig.app.json configuration:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es6",
"types": [],
"paths": {
"@angular/*": [
"../node_modules/@angular/*"
]
}
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
Does anyone have any insights on how to resolve this issue?