Skip to content
This repository was archived by the owner on Dec 22, 2018. It is now read-only.

Usage with typescript? #10

Closed
kitzler-walli opened this issue Dec 28, 2017 · 13 comments
Closed

Usage with typescript? #10

kitzler-walli opened this issue Dec 28, 2017 · 13 comments

Comments

@kitzler-walli
Copy link

How were you able to compile this in typescript?
There is no types definition for fetch and there are other issues with bluebird.

@gautamsi
Copy link
Owner

I have shimmed fetch type definition myself 😄

I am not sure what issues with bluebird. can you explain.

@kitzler-walli
Copy link
Author

Could you check in your type definition with this project?
Then I'll send you a report about the issues with bluebird

@gautamsi
Copy link
Owner

let me know exact issue with type definitions.

@kitzler-walli
Copy link
Author

OK even though the ews-javascript-api-auth is written in TS I can't use it directly because of this error:
screenshot 2018-01-01 17 38 43

I then tried to remove the JS files from the ews-javascript-api-auth module. But still this didn't work out so I tried to compile it. Some references were missing so I called 'npm install' and then tried again which causes the bluebird issues. Here is the output of the console:

ews-javascript-api-auth ../typescript/bin/tsc
src/ntlmAuthXhrApi.ts(6,37): error TS2307: Cannot find module 'https'.
src/ntlmAuthXhrApi.ts(8,70): error TS2304: Cannot find name 'require'.
➜ ews-javascript-api-auth npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
added 60 packages in 21.15s
➜ ews-javascript-api-auth ../typescript/bin/tsc
node_modules/@types/bluebird/index.d.ts(466,33): error TS2304: Cannot find name 'Map'.
node_modules/@types/bluebird/index.d.ts(466,72): error TS2304: Cannot find name 'Map'.
node_modules/@types/bluebird/index.d.ts(731,37): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(731,69): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(745,39): error TS2304: Cannot find name 'Map'.
node_modules/@types/bluebird/index.d.ts(745,69): error TS2304: Cannot find name 'Map'.
node_modules/@types/bluebird/index.d.ts(745,107): error TS2304: Cannot find name 'Map'.
node_modules/@types/bluebird/index.d.ts(754,37): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(754,69): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(761,38): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(761,70): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(771,38): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(771,70): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(827,27): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(827,59): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(842,27): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(842,59): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(856,27): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(856,59): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(869,27): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(869,59): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(883,27): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/bluebird/index.d.ts(883,59): error TS2304: Cannot find name 'Iterable'.

@gautamsi
Copy link
Owner

gautamsi commented Jan 1, 2018

ok, package.json does not have ` property. I will fix and upload new version. you can fix by adding this attribute to package.json like this

"typings": "src/index.d.ts",

this should fix your issue.

do not remove js files.

@kitzler-walli
Copy link
Author

No it doesn't seem to fix it and there are other issues as well:

node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(1,45): error TS7016: Could not find a declaration file for module 'fetch'. '/Users/stephan/Projects/tstest/node_modules/ews-javascript-api-auth/node_modules/fetch/lib/fetch.js' implicitly has an 'any' type.
Try npm install @types/fetch if it exists or add a new declaration (.d.ts) file containing declare module 'fetch';
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(9,5): error TS2322: Type 'null' is not assignable to type 'string'.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(10,5): error TS2322: Type 'null' is not assignable to type 'string'.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(41,49): error TS7006: Parameter 'error' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(41,56): error TS7006: Parameter 'meta' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(41,62): error TS7006: Parameter 'body' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(123,42): error TS7006: Parameter 'error' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(156,52): error TS7006: Parameter 'error' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(156,59): error TS7006: Parameter 'meta' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(156,65): error TS7006: Parameter 'body' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(181,21): error TS2531: Object is possibly 'null'.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(182,24): error TS2531: Object is possibly 'null'.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(183,19): error TS2531: Object is possibly 'null'.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(184,20): error TS2531: Object is possibly 'null'.
node_modules/ews-javascript-api-auth/src/cookieAuthXhrApi.ts(185,23): error TS2531: Object is possibly 'null'.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(1,39): error TS7016: Could not find a declaration file for module 'fetch'. '/Users/stephan/Projects/tstest/node_modules/ews-javascript-api-auth/node_modules/fetch/lib/fetch.js' implicitly has an 'any' type.
Try npm install @types/fetch if it exists or add a new declaration (.d.ts) file containing declare module 'fetch';
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(6,37): error TS2307: Cannot find module 'https'.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(8,70): error TS2304: Cannot find name 'require'.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(19,5): error TS2322: Type 'null' is not assignable to type 'string'.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(20,5): error TS2322: Type 'null' is not assignable to type 'string'.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(55,17): error TS7017: Element implicitly has an 'any' type because type 'IXHROptions' has no index signature.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(56,17): error TS7017: Element implicitly has an 'any' type because type 'IXHROptions' has no index signature.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(57,66): error TS7006: Parameter 'error' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(57,73): error TS7006: Parameter 'meta' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(57,79): error TS7006: Parameter 'body' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(97,17): error TS7017: Element implicitly has an 'any' type because type 'IXHROptions' has no index signature.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(98,17): error TS7017: Element implicitly has an 'any' type because type 'IXHROptions' has no index signature.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(102,41): error TS7006: Parameter 'chunk' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(107,41): error TS7006: Parameter 'meta' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(116,42): error TS7006: Parameter 'error' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(139,26): error TS7017: Element implicitly has an 'any' type because type 'IXHROptions' has no index signature.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(151,45): error TS7006: Parameter 'error' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(151,52): error TS7006: Parameter 'meta' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/ntlmAuthXhrApi.ts(151,58): error TS7006: Parameter 'body' implicitly has an 'any' type.
node_modules/ews-javascript-api-auth/src/utils.ts(3,5): error TS7017: Element implicitly has an 'any' type because type 'XMLHttpRequest' has no index signature.
node_modules/ews-javascript-api/typings/ExchangeWebService.d.ts(223,68): error TS7006: Parameter 'T' implicitly has an 'any' type.
node_modules/ews-javascript-api/typings/ExchangeWebService.d.ts(7690,35): error TS7006: Parameter 'key' implicitly has an 'any' type.
node_modules/ews-javascript-api/typings/ExchangeWebService.d.ts(15273,13): error TS7006: Parameter 'string' implicitly has an 'any' type.
node_modules/ews-javascript-api/typings/ExchangeWebService.d.ts(15274,23): error TS7006: Parameter 'any' implicitly has an 'any' type.

@gautamsi
Copy link
Owner

gautamsi commented Jan 2, 2018

are you trying to build it yourself or just consume?

@kitzler-walli
Copy link
Author

I'm trying to consume - but it seems like tsc tries to compile the auth module

@gautamsi
Copy link
Owner

gautamsi commented Jan 2, 2018

you can set skipLibCheck to true in compiler options in typescript. it will not report these errors. latest version of typescript introduced strict type checking which may be causing this issue.

@omatrot
Copy link

omatrot commented Jan 10, 2018

@kitzler-walli @gautamsi I have the same problem with a slightly different error:

error TS7016: Could not find a declaration file for module 'ews-javascript-api-auth'. '/..../node_modules/ews-javascript-api-auth/src/index.js' implicitly has an 'any' type.

skipLibCheck is already set to true and adding "typings": "src/index.d.ts" in package.json spawns a ton of errors at compilation.

The fix to package.json seems to not have been committed.

@omatrot
Copy link

omatrot commented Jan 10, 2018

Solved it with this comment.

@gautamsi
Copy link
Owner

gr8, I am not sure if adding this switch in tsconfig of this repo would help. ideally skipLibCheck is enough.

@gautamsi
Copy link
Owner

gautamsi commented May 1, 2018

let me know if you still facing this issue.

@gautamsi gautamsi closed this as completed May 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants