Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typescript declaration files for all public APIs #247

Merged
merged 43 commits into from
Sep 25, 2018

Conversation

janpieterz
Copy link
Contributor

Let me know if this is appreciated, I can add types for the other packages too.

@msftclas
Copy link

msftclas commented Feb 23, 2018

CLA assistant check
All CLA requirements met.

@guperrot
Copy link
Member

(Subset of #172)

appcenter-analytics/Analytics.d.ts Outdated Show resolved Hide resolved
appcenter-analytics/Analytics.d.ts Outdated Show resolved Hide resolved
appcenter-analytics/Analytics.d.ts Outdated Show resolved Hide resolved
@elamalani
Copy link
Contributor

@janpieterz Thanks for submitting a PR in our SDK and we really appreciate your contribution. Our team reviewed your PR and it looks like you are adding typescript definition only in Analytics module. For this to be consistent across, all the modules - appcenter, appcenter-push, appcenter-crashes should have the definitions as well.

@guperrot
Copy link
Member

We would also need to make a Typescript version of TestApp before merging to validate the files.

@janpieterz
Copy link
Contributor Author

I'll tackle the appcenter, appcenter-push, appcenter-crashes as well, and create a typescript version of the TestApp. Might take a bit.

Would you prefer me tackling those all at once or pushing the definitions out per package so we keep the stuff to review small?

@guperrot
Copy link
Member

guperrot commented Mar 3, 2018

If we merge 1 by 1 then the target branch cannot be develop and we can create another hosting branch. Github offers incremental reviews since last time so it's not a problem for me as long as commits for TestApp are separated from the SDK changes it should be ok.

@guperrot
Copy link
Member

guperrot commented Mar 3, 2018

Changes on analytics are ok so far.

@janpieterz
Copy link
Contributor Author

Should have all typings now, let me know what's wrong and I'll fix it, then move on to the TestApp.

appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-push/Push.d.ts Outdated Show resolved Hide resolved
appcenter-push/Push.d.ts Outdated Show resolved Hide resolved
appcenter/AppCenter.d.ts Outdated Show resolved Hide resolved
Copy link
Member

@guperrot guperrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need a test app in same pr to validate the changes. Minor comments otherwise.
Nice progress on this 👍

appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
@guperrot
Copy link
Member

Looks good, now we would need a clone of the testapp we have in the repo but in typescript version to validate all the changes.

@janpieterz
Copy link
Contributor Author

Great stuff, will start tackling that.

@guperrot guperrot changed the title Add types for appcenter-analytics Add typescript declaration files for all public APIs Mar 20, 2018
@janpieterz
Copy link
Contributor Author

@guperrot Made some progress with the test app.

Couple of questions:

  1. PushNotification title can currently be a string, null or undefined. It looks like the test app doesn't account for it possibly being undefined. Is this something to change in the Typescript definition? Is it only null/undefined if message is null/undefined?
  2. ErrorAttachmentLog.attachmentWithBinary seems to be called with a string from the test apps, is this always the case?
  3. Did I miss shouldProcess and shouldAwaitUserConfirmation in the CrashesListener interface before? I've added them now, just making sure it's not a private API and it's supposed to be public.
  4. On analyticsScreen a variable data is used, undefined (I think). It's for Track Event badly (Do not do this, only strings are supported). What is supposed to happen here? It currently doesn't do anything.

@guperrot guperrot dismissed their stale review April 4, 2018 18:37

reset my feedback to review new changes

@guperrot
Copy link
Member

guperrot commented Apr 6, 2018

Replies to #247 (comment)

  1. Sounds like a bug, it should be string or null but not undefined. We will have to investigate.
  2. From Javascript we pass binary as string with base64 encoding, only native SDK APIs have support for byte arrays.
  3. Those APIs are not new and are publicly documented.
  4. I have to check but AppCenter is supposed to log an error in the console and not send the event. In TypeScript we have types so you don't need that button I guess.

I made a first quick review for changes on TestApp and need some fixes before I can deeply review and test.

Copy link
Member

@guperrot guperrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying comment as github collasped it and link does not work: #247 (comment)

Like in TestApp, make sure firebase is integrated: https://docs.microsoft.com/en-us/appcenter/sdk/push/migration/react-native-android.

When the procedure asks to download google-services.json, pick https://github.com/Microsoft/AppCenter-SDK-React-Native/blob/develop/TestApp/android/app/google-services.json instead and make sure your app has the same package name as TestApp.

@janpieterz
Copy link
Contributor Author

@guperrot Google Services added, not sure what else there is atm.

Copy link
Member

@guperrot guperrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No matter how I git clean -xdf and npm cache clean --force, when I checkout this branch, run ./update-npm-package.sh and react-native run-android, the JS server fails to bundle and thus the app is broken:

error: bundling failed: Error: Unable to resolve module `./artifacts/index` from `/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/index.js`: The module `./artifacts/index` could not be found from `/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/index.js`. Indeed, none of these files exist:

  * `/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/artifacts/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
  * `/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/artifacts/index/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
    at ModuleResolver.resolveDependency (/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:158:865)
    at ResolutionRequest.resolveDependency (/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:92:16)
    at DependencyGraph.resolveDependency (/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/node-haste/DependencyGraph.js:271:4465)
    at dependencies.map.relativePath (/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/DeltaBundler/traverseDependencies.js:379:19)
    at Array.map (<anonymous>)
    at resolveDependencies (/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/DeltaBundler/traverseDependencies.js:378:16)
    at /Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/DeltaBundler/traverseDependencies.js:203:33
    at Generator.next (<anonymous>)
    at step (/Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/DeltaBundler/traverseDependencies.js:296:307)
    at /Users/guperrot/git/appcenter-sdk-react-native/TestAppTypescript/node_modules/metro/src/DeltaBundler/traverseDependencies.js:296:467
 BUNDLE  [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

Please look into this so we can review this PR, none of the search results on Google were helpful for this issue.

The same problem exists for ios.

@FutureGUIs
Copy link

I'm not sure it's truly the fix for that latest 'bundling' error, but I used to get it when just running the normal react-native android or ios on RN 0.54 or 0.55. But then I would run a separate npm start or the RN \cli.js start and I'd be able to run my app. And after upgrading to the new RN 0.57 release, that issue has gone away.

@guperrot
Copy link
Member

I already tried npm run start as separate but it didn't change anything, same error.

@janpieterz
Copy link
Contributor Author

@guperrot This is because you're not running the Typescript compiler first. You're welcome to change the commands to something more to your liking, running npm run watch is needed.

There should be commands for npm run ios and npm run android that should automatically start the correct watcher and react-native run-X.

@guperrot
Copy link
Member

npm run watch did the trick, I could run test app successfully on both platforms.
However I am investigating on typing inconsistencies in crash report, will elaborate soon but we might have to update either SDK or typings.

Copy link
Member

@guperrot guperrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested everything and found some problems, nice job otherwise and looking forward to merging soon after the requested changes 👍

Please also copy .vscode/launch.json from TestApp to this app and commit it.

appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-crashes/Crashes.d.ts Outdated Show resolved Hide resolved
appcenter-push/Push.d.ts Outdated Show resolved Hide resolved
appcenter/AppCenter.d.ts Outdated Show resolved Hide resolved
appcenter/AppCenter.d.ts Outdated Show resolved Hide resolved
Copy link
Member

@guperrot guperrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appcenter-analytics/Analytics.d.ts Outdated Show resolved Hide resolved
appcenter-analytics/Analytics.d.ts Outdated Show resolved Hide resolved
@janpieterz
Copy link
Contributor Author

@guperrot Should all be fixed.

@guperrot guperrot merged commit d1ed9fc into microsoft:develop Sep 25, 2018
@guperrot
Copy link
Member

@janpieterz thanks for this huge contribution 👍

@dhei
Copy link
Member

dhei commented Sep 25, 2018

Hey @janpieterz,

I want to say a big thank you! Your contribution is highly appreciated. 👍

Thanks,
Di

@janpieterz
Copy link
Contributor Author

Thanks for the help gents, happy we landed it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants