Skip to content

@Input on a property throws exception #282

@victorhurdugaci

Description

@victorhurdugaci

Repro:

  1. tns create TestApp --ng

  2. tns platform add android

  3. Change app.component.ts to:

    import {Component, Input} from "@angular/core";
    
    @Component({
        selector: "my-app",
        template: '<Label text="Hello"></Label>'
    })
    export class AppComponent {
        @Input() numberField: number;
    
        // Comment the @Input attribute and you'll
        // not get an exception
        @Input()
        public set NumberProperty(val: number) {
        }
    }
  4. Run

Expected: the app runs without any problem
Actual: exception:

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 
Fail to load module: /data/data/org.nativescript.TestApp/files/app/main.js

TypeError
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'decorate', file:'/data/data/org.nativescript.TestApp/files/app/tns_modules/reflect-metadata/Reflect.js', line: 76, column: 23
    Frame: function:'__decorate', file:'/data/data/org.nativescript.TestApp/files/internal/ts_helpers.js', line: 10, column: 96
    Frame: function:'', file:'/data/data/org.nativescript.TestApp/files/app/app.component.js', line: 16, column: 5
    Frame: function:'', file:'/data/data/org.nativescript.TestApp/files/app/app.component.js', line: 29, column: 2
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'/data/data/org.nativescript.TestApp/files/app/main.js', line: 4, column: 23
    Frame: function:'require', file:'', line: 1, column: 266


    at android.app.ActivityThread.handleBindApplica

Turns out that if you @Input() on a property, you get that exception. If you remove the property or the @Input, everything works. Also, note that @Input on a field works fine.

  • tns version: 2.0.1
  • OS: Win 10
  • Emulator: genymotion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions