aurelia / template-lint

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

Optional properties inherited from interface not detected #178

Open gronostajo opened 7 years ago

gronostajo commented 7 years ago

Here's an example:

model.ts

export interface Entity {
    pending?: boolean; // note the question mark!
}

export class Language implements Entity {
    name: string;
}

app.ts

import {Language} from "./model";

export class App {
    languages: Language[];

    constructor() {
        this.languages = [
            {name: 'foo'},
            {name: 'bar', pending: false},
            {name: 'baz', pending: true},
        ];
    }
}

app.html

<template>
    <h1>Hello world!</h1>
    <ul>
        <li repeat.for="language of languages">
            ${language.name}
            <button type="button" disabled.bind="language.pending">choose</button>
        </li>
    </ul>
</template>

Results of linting via gulp-aurelia-template-lint:

[12:27:20] WARNING: cannot find 'pending' in type 'Language' Ln 6 Col 13 \src\app.html

Here's the code in an app, complete with gulp and gulp-aurelia-template-lint: gronostajo/aurelia-template-lint-bug

gronostajo commented 7 years ago

Some thoughts on this:

  1. Actually, new Language().pending is an error because Language doesn't redeclare pending. But unless you try to access .pending in TS code, TS compiler won't warn you about it. Should linter do that?
  2. Also consider the case where Entity is a class.