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

Optional properties inherited from interface not detected #178

Open
gronostajo opened this issue Aug 14, 2017 · 1 comment
Open

Optional properties inherited from interface not detected #178

gronostajo opened this issue Aug 14, 2017 · 1 comment
Labels

Comments

@gronostajo
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants