aurelia / template-lint

Sanity check of Aurelia-flavor template HTML
Apache License 2.0
56 stars 17 forks source link

Inherited properties are not supported in static type checking #148

Closed 4nderss closed 7 years ago

4nderss commented 7 years ago

I saw the #68 but in my case I am not using an interface. I am using a base class and I get warnings for my properties declared in my base class.

Example

**Base class**
export class BaseItem {
     sharedValue: string = "5";
}

**ViewModel**
export class ExtendedItem extends BaseItem {
     extendedValue: int = 5;
     constructor() {
        super();     
     }
}

**View**
<template>
  <span>${sharedValue}</span>
  <span>${extendedValue}</span>
</template>

I get warnings for sharedValue WARNING: cannot find 'sharedValue' in type 'ExtendedItem'

Or am I missing something?

Using latest version

MeirionHughes commented 7 years ago

I will investigate.

MeirionHughes commented 7 years ago

Have a look here: https://github.com/MeirionHughes/aurelia-template-lint/commit/74f346297a7c4f2c294a9e9f025269298b0c8c3e Are you doing anything differently, because that test case works.

4nderss commented 7 years ago

This is our exact case:

list.ts

@autoinject()
export class List extends BaseList {
 constructor(
        router: Router,  taskQueue: TaskQueue) {
        super(router, taskQueue);
}

baselist.ts

export class BaseList {
    constructor(
        public router: Router,
        public taskQueue: TaskQueue) { }
}

list.html

    <button class="pl-button green block" click.trigger="router.navigateToRoute('new-doseprescription')" tabindex="10">Ny ordination</button>

result: image

MeirionHughes commented 7 years ago

~try constructor(public router: Router.... ) it won't be elevated to a class property without public/protected/private~

I see the issue; its public on the base class, but not the main class; current code doesn't traverse into base classes for that. should be fixable.

4nderss commented 7 years ago

Because it is public inside the base class wouldn't that make it a duplicate identifier and override the router declared inside baselist.ts ?

MeirionHughes commented 7 years ago

yeah your code is fine; I just need to make the constructor lookup traverse into base classes to find what public fields are declared there too.

4nderss commented 7 years ago

Perfecto :)

By the way props on your work, this is helping us alot!

MeirionHughes commented 7 years ago

try 0.9.21

4nderss commented 7 years ago

Works, thanks!

timfish commented 7 years ago

I'm using 0.9.23 and its not finding a property on my base class. Could this be due to generics?

export class FileDataSource extends BaseDataSource<MemoryStorageMap> {