Appcenter-sdk-react-native: AppCenter LogLevel typescript type definition problem

Created on 24 Nov 2018  ยท  5Comments  ยท  Source: microsoft/appcenter-sdk-react-native

Description

The Type Definition for the Log Level in the AppCenter package seems wrong.

Repro Steps

If we follow the AppCenter type definition we should use the AppCenterLogLevel enum in this way:

import AppCenter from 'appcenter';

AppCenter.setLogLevel(AppCenter.AppCenterLogLevel.DEBUG);

But in reality the AppCenterLogLevel in undefined because is not defined in the AppCenter.js, so we should use LogLevelXXX instead:

import AppCenter from 'appcenter';

AppCenter.setLogLevel(AppCenter.LogLevelDebug);

But this will rise a type error since Property 'LogLevelDebug' does not exist on type AppCenter.

I think a possible solution could be export all the log level of the appcenter-log.js as a constant in the AppCenter.d.ts type definition file instead of a enum, something like this:

/**
 * Debug information will be logged
 */
export const LogLevelDebug = 3;

Details

AppCenter Package Version:

โ”œโ”€ [email protected]
โ”‚ โ””โ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚ โ””โ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚ โ””โ”€ [email protected]

React Native Environment Info:
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 546.52 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.5.0 - /usr/local/bin/node
Yarn: 1.3.2 - ~/.npm-global/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.3, 28.0.3
API Levels: 23, 24, 25, 26, 27, 28
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
@types/react: 16.7.7 => 16.7.7
@types/react-native: 0.57.13 => 0.57.13
react: 16.6.1 => 16.6.1
react-native: 0.57.5 => 0.57.5
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1

bug

All 5 comments

Hi @thomasgazzoni, thanks a lot for reporting this, it's indeed a bug. It is being tracked and we'll get to it as soon as we can.

Hi @thomasgazzoni, sorry about the confusion, this isn't actually a bug. This is the correct usage for Typescript:

AppCenter.setLogLevel(AppCenter.AppCenterLogLevel.DEBUG);

We don't have Typescript documentation explicitly. AppCenter.setLogLevel(AppCenter.LogLevelDebug); is used in Javascript only.

@thomasgazzoni We will deprecate the redundant AppCenter.AppCenterLogLevel.* log levels in favor of the shorter AppCenter.LogLevel.* based on your feedback

@jwallra Thank you! Looking forward for the next v1.10.1 version to have a try and close this issue.

Released in 1.11.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BrianTheArcane picture BrianTheArcane  ยท  6Comments

danielmilner picture danielmilner  ยท  10Comments

matthargett picture matthargett  ยท  7Comments

elnygren picture elnygren  ยท  5Comments

aprilmintacpineda picture aprilmintacpineda  ยท  5Comments