openid / AppAuth-JS

JavaScript client SDK for communicating with OAuth 2.0 and OpenID Connect providers.
Apache License 2.0
977 stars 162 forks source link

Compile errors when using within another TypeScript project #22

Closed juriwiens closed 7 years ago

juriwiens commented 7 years ago

I use this lib within a TS project. When I import the NodeRequestor like in the node_app example and run tsc (version 2.5.2), I get the following compiler errors:

node_modules/@openid/appauth/built/node_support/node_requestor.d.ts(1,23): error TS2688: Cannot find type definition file for 'jquery'.
node_modules/@openid/appauth/built/node_support/node_requestor.d.ts(7,22): error TS2304: Cannot find name 'JQueryAjaxSettings'.
node_modules/@openid/appauth/built/xhr.d.ts(1,23): error TS2688: Cannot find type definition file for 'jquery'.
node_modules/@openid/appauth/built/xhr.d.ts(6,31): error TS2304: Cannot find name 'JQueryAjaxSettings'.
node_modules/@openid/appauth/built/xhr.d.ts(12,22): error TS2304: Cannot find name 'JQueryAjaxSettings'.
node_modules/@openid/appauth/built/xhr.d.ts(21,22): error TS2304: Cannot find name 'JQueryAjaxSettings'.

I can workaround this by adding the @types/jquery module to my project and "dom" to compilerOptions.lib in my tsconfig.json.

I think a solution for this problem would be to move @types/jquery from devDependencies to dependencies.

tikurahul commented 7 years ago

Yes, this is an oversight. I will go ahead and add this to the list of dependencies. I will also go ahead and update the project for TypeScript 2.5.

Meligy commented 6 years ago

Since this library is mainly for apps, would it make sense to replace jQuery with fetch()?

Developers still have the ability to replace the Xhr implementation today of course. And a workaround for the issue for now is to set "skipLibCheck": true in tsconfig.json, which disables errors in NPM packages (but still shows errors in your own code, or when your code interfaces with the package).