EddyVerbruggen / EddyVerbruggen/nativescript-feedback

You are trying to set "Companion" which is a final field!

Open
#71 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
128
Forks
26
PR merge metrics
No merged PRs in 30d

Description

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project:

CLI: 8.2.14
Cross-platform modules:
"tns-core-modules": "~6.5.15"
"nativescript-feedback": "^1.5.0",

Describe the bug
Calling this.feedback.show({..} ) fails with Error: You are trying to set "Companion" which is a final field! Final fields can only be read.

Add plugin into a new {N} project. Import and execute:

var test = require("nativescript-kotlintest");
test.doTest();

feedback.service.js :

```
import { Injectable } from '@angular/core';
import { Feedback, FeedbackType } from 'nativescript-feedback';

@Injectable({
providedIn: 'root'
})
export class FeedbackService {
private feedback: Feedback;

constructor() {
this.feedback = new Feedback();
}

showSuccessMessage(message: string) {
this.feedback.show({
message: message,
type: FeedbackType.Success
});
}
}
```

Component.ts:

```
login() {
this.processing = false;
this.authService.login(this.user.email, this.user.password).subscribe(
data => {
this.feedbackService.showSuccessMessage("test message");
this.routerExtensions.navigate(['/bills/tabs'], { clearHistory: true });
},
error => {
console.log(error);
}
);
}
```

Expected behavior
To not crash.

Additional context:
Issue occur if function gets invoked.

Full stacktrace:
```
JS: ERROR Error: Uncaught (in promise): Error: You are trying to set "Companion" which is a final field! Final fields can only be read.
JS: Error: You are trying to set "Companion" which is a final field! Final fields can only be read.
JS: at file:///node_modules/nativescript-feedback/feedback.js:17:0
JS: at new ZoneAwarePromise file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:902:0
JS: at Feedback.show file:///node_modules/nativescript-feedback/feedback.js:15:0
JS: at FeedbackService.module.exports.push../app/shared/services/feedback.service.ts.FeedbackService.showSuccessMessage file:///src/app/shared/services/feedback.service.ts:15:18
JS: at SafeSubscriber._next file:///src/app/auth/auth.component.ts:50:29
JS: at SafeSubscriber.push.../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub file:///node_modules/rxjs/_esm5/internal/Subscriber.js:192:0
JS: at SafeSubscriber.push.../node_modules/r...
```

Further github issue, which does not solve the problem:
https://github.com/NativeScript/android-runtime/issues/1178

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Feedback.show entry point in node_modules/nativescript-feedback/feedback.js at lines 15-17 and compare the failure with NativeScript/android-runtime issue 1178. Reproduce the call from the provided FeedbackService example in a new NativeScript project; done means invoking show no longer crashes with the final-field error.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.