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

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

Open
Splash34 opened this issue Aug 21, 2020 · 0 comments
Open

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

Splash34 opened this issue Aug 21, 2020 · 0 comments

Comments

@Splash34
Copy link

Splash34 commented Aug 21, 2020

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:
NativeScript/android#1178

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

No branches or pull requests

1 participant