React Native, TypeScript code JS(non-TS) ORM module:
Parent BaseModel
:
export default class BaseModel {
static createTable() {
...
}
...
My model of Animal
does NOT redefine the method, it's just defined as:
export default class Animal extends BaseModel { ...
Now this code await Animal.createTable();
actually works, but VSCode TypeScript checker gives following error in code:
Property 'createTable' does not exist on type 'typeof Animal'.ts(2339)
Is this the editor/checker issue? Or should the JS/TS code be defined somehow better?
So it seems to be a problem in vscode typescript intelisense not properly analyzing pure JS module (not typescript). Because if I create middl e layer base model in typescript in project it recognizes it just fine. You have to redefine and proxy all used methods to the package parent, but it's still much less painful than adding them to each model.
Optionally, any
ts
error can be ignored by putting// @ts-ignore
BEFORE the line, which I don't recommend if you can avoid it since potentially it could hide important errors.My solution:
AppBaseModel.tsx
Animal.tsx
Example test usage