I am trying to build our React Native project using the guidelines described here:
https://facebook.github.io/react-native/docs/typescript#adding-typescript-to-an-existing-project
The major issue is when enabling isolatedModules. Our code imports the following from the AppCenter React Native SDK:
import AppCenter from "appcenter";
import Crashes, { ErrorAttachmentLog } from "appcenter-crashes";
When I run the TypeScript compiler, I get the following errors:
yarn run v1.15.2
$ tsc
node_modules/appcenter-crashes/Crashes.d.ts:1:19 - error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
1 export const enum UserConfirmation {
~~~~~~~~~~~~~~~~
node_modules/appcenter/AppCenter.d.ts:1:19 - error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
1 export const enum LogLevel {
~~~~~~~~
node_modules/appcenter/AppCenter.d.ts:14:19 - error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
14 export const enum AppCenterLogLevel {
~~~~~~~~~~~~~~~~~
error Command failed with exit code 1.
From my searching online, it appears that library declarations need to avoid const enum so they can be used with or without the isolatedModules flag. Since this flag is now recommended by the React Native TypeScript guidelines, it is something the AppCenter SDK needs to support.
Please list the steps used to reproduce your issue.
yarn tsc)react-native info React Native Environment Info:
System:
OS: macOS 10.14.6
CPU: x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 9.03 GB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.4 - /var/folders/x5/9543yn1n4hg2cyk_9bzgfcdh0000gp/T/yarn--1571674717580-0.39145863065495035/node
Yarn: 1.15.2 - /var/folders/x5/9543yn1n4hg2cyk_9bzgfcdh0000gp/T/yarn--1571674717580-0.39145863065495035/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.11.4/bin/npm
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.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.2, 26.0.3, 27.0.0, 27.0.3, 28.0.2, 28.0.3, 29.0.0, 29.0.2
API Levels: 21, 22, 25, 26, 27, 28
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
@types/react: 16.7.3 => 16.7.3
@types/react-native: 0.57.19 => 0.57.19
react: 16.6.3 => 16.6.3
react-native: ^0.57.0 => 0.57.8
npmGlobalPackages:
react-native-create-library: 3.1.2
pod --versionN/A
[MSAppCenter setLogLevel: MSLogLevelVerbose]; before your call to [AppCenterReactNative register]; (or any other SDK registration). For Android, use AppCenter.setLogLevel(android.util.Log.VERBOSE); before your SoLoader.init call (you will need to import com.microsoft.appcenter.AppCenter;). Include the logs here:N/A
Hi @newyankeecodeshop,
Thanks for reporting this issue to us. We are fixing this issue.
Do you mind sharing your tsconfig with us?
PS: Looks like TypeScript v3.4.5 no longer make this an error, upgrading to TypeScript v3.4.5 or later is probably a workaround at this moment.
Thanks @dhei ,
I'll try upgrading to TypeScript 3.4 to see if that helps us. We've been meaning to upgrade anyway.
Here is our tsconfig:
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"*": ["src/*"],
"tests": ["tests/*"]
},
"esModuleInterop": true,
"isolatedModules": true,
"moduleResolution": "node",
"target": "esnext",
"lib": ["es2017"],
"jsx": "react",
"noEmit": true,
"noUnusedLocals": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"strict": true,
"strictFunctionTypes": false,
"preserveConstEnums": true,
"sourceMap": true,
},
@dhei I can confirm that upgrading to TypeScript 3.4.5 allows us to run tsc without the --skipLibCheck flag. Thank you for the advice.
Hey!
We've included fixes in the latest SDK release for this. I'm closing the issue but please reopen if you run into this again.
Most helpful comment
@dhei I can confirm that upgrading to TypeScript 3.4.5 allows us to run
tscwithout the--skipLibCheckflag. Thank you for the advice.