typescript 接口实现时返回值类型不一致居然不报错?这是什么情况

export interface IFileServeService {
    UploadFileStatus(hash: string, totalChunks: number): Promise<IExistFileExistResponse>;
    upload(data: IUploadForm): Promise<{code: number, item: IFileStruct|null, success: boolean}>;
    convertModelBySelf(fileId: string,modelGroupId: string): Promise<{success: boolean, data: {done: boolean, found: boolean, success: boolean, percent: number}}>
}
class FakeFileServeService implements IFileServeService {
    upload(data: IUploadForm): Promise<{code: number, item: IFileStruct, success: boolean}>{
        return ''
    }
    UploadFileStatus(hash: string, totalChunck: number): Promise<IExistFileExistResponse> {

    }
    convertModelBySelf(): any {

    }
}

我实现接口,但是我实现的方法返回值类型与接口定义的返回值类型完全不一致,居然不报错。
我如果在实现接口的地方不写返回值类型,他又要报错。
在实现接口的地方写了返回值类型,鼠标放上去显示的返回值是any
TIM截图20191121101056.png

回复
阅读 2k
2 个回答

微信图片_20191121110155.png

图片描述

上面是 vscode,下面是 webstorm。都会报错。不知道你的是什么配置?

图片描述

"typescript": "^3.6.3"

logo
Microsoft
子站问答
访问
宣传栏