Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

IDEA doesn't recognize typegoose type of model

Trying to include @typegoose/typegoose, followed all installation step for it and just put model which has been provided in example

import { prop, getModelForClass } from '@typegoose/typegoose';

class User {
    @prop()
    public name?: string;
}

const UserModel = getModelForClass(User);

IDEA couldn't recognize methods from UserModel like 'create' etc. screen

What's more interesting - just put in empty folder the same package.json and tsconfig.json and put in index this code:

import { prop, getModelForClass } from '@typegoose/typegoose';
import * as mongoose from 'mongoose';

class User {
    @prop()
    public name?: string;

    @prop({ type: () => [String] })
    public jobs?: string[];
}

const UserModel = getModelForClass(User); 

and IDEA see what's needed enter image description here

question from:https://stackoverflow.com/questions/65617228/idea-doesnt-recognize-typegoose-type-of-model

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Doesn't work in other editors as well (tried with VSCode):

enter image description here

enter image description here

As you can see, the inrferred type of UserModel is any, so there are no expected methods in completion. Looks as if the typings (d.ts files) of the @typegoose/typegoose package have to be re-worked


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...