Skip to content

Conversation

@RemiHin
Copy link

@RemiHin RemiHin commented Jan 2, 2025

Fix: Incorrect lateinit Property Declaration in StepCounterModule

Issue

The StepCounterModule.kt file contained an incorrect Kotlin property declaration that was causing compilation errors. The lateinit modifier was incorrectly used with a val property and placed in the wrong position in the declaration:

private val lateinit sensorManager: SensorManager

This syntax is invalid in Kotlin and causes the following compilation error:

Property getter or setter expected

Additionally, this led to several "Unresolved reference: sensorManager" errors throughout the file as the property wasn't properly initialized.

Fix

Modified the property declaration to use the correct Kotlin syntax for lateinit properties:

private lateinit var sensorManager: SensorManager

This change:

  • Uses the lateinit modifier before the var keyword (lateinit can only be used with var, not val)
  • Follows Kotlin's proper property declaration syntax
  • Maintains the same functionality while fixing the compilation errors
  • Keeps the property non-null while allowing initialization in the init block

Testing

  • Verified that the code compiles successfully
  • Confirmed that the step counter functionality works as expected
  • No changes to the actual behavior of the module

This fix allows the module to be used in React Native projects without compilation errors while maintaining all existing functionality.

@trunk-io
Copy link

trunk-io bot commented Jan 2, 2025

✨ Submitted to Merge by Andrew Yu (@AndrewDongminYoo). It will be added to the merge queue once all branch protection rules pass and there are no merge conflicts with the target branch. See more details here.

@RemiHin
Copy link
Author

RemiHin commented Jan 2, 2025

/trunk merge

@trunk-io
Copy link

trunk-io bot commented Jan 2, 2025

An error occurred while submitting your PR to the queue: Only users that are a part of this repo's Trunk organization or have write permissions to the repo can submit a PR to the queue

@CarloDev15
Copy link

This fix is important as it resolves a breaking issue. Could you please review and merge it? Many developers are affected by this. Thanks.

@AndrewDongminYoo
Copy link
Owner

/trunk merge

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants