Keep getting error: $.deferred is not a function
Asked Answered
R

0

0

I've installed jquery and @types/jquery. I want to use jquery.Deferred() but when i try to use it I get error that "$.Deferred is not a function".

import * as $ from "jquery";
u
// somewhere in code
let dfd = $.Deferred<
      { response: JQueryXHR; body?: any },
      { response: JQueryXHR; errorThrown: string }
    >();

It is from code that was generated by https://github.com/OpenAPITools/openapi-generator for typescript. I'm using it in React Native app. Any suggestions? Thanks!

Rhinoplasty answered 7/9, 2020 at 20:38 Comment(2)
$.Deferred is virtually obsolete now in modern browsers due to built in Promise APIDisclosure
Use Promise instead of $.Deferred. If you want to return a value that has been deferred, return Promise.resolve(someValue). If you want to return a deferred error, Promise.reject(someError). Etc.Impugn

© 2022 - 2024 — McMap. All rights reserved.