MithrilJS / mithril.d.ts

Types for mithril.js
MIT License
80 stars 11 forks source link

Intellisense issue with non-nullable properties #23

Open vrimar opened 7 years ago

vrimar commented 7 years ago

Given this example:

interface IComponentAttrs {
    test: number;
}

class Component implements m.ClassComponent<IComponentAttrs> {
    view({ attrs }: m.CVnode<IComponentAttrs>) {
        return m('');
    }
}

class Page {
    view() {
        return m(Component, {
            // <== Not getting intellisense here
        });
    }
}

The test property (along with lifcycle attrs) aren't showing up under the intellisense in Vscode.

Here's my tsconfig.json:

{
    "compilerOptions": {
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "importHelpers": true,
        "lib": [
            "dom",
            "es7"
        ],
        "module": "commonjs",
        "sourceMap": false,
        "target": "es5",
        "typeRoots": [
            "node_modules/@types"
        ]
    },
    "exclude": [
        "node_modules"
    ]
}

If I set test to nullable it shows up fine (along with lifecycle attrs). Any insight on this?

spacejack commented 7 years ago

Interesting that it shows up when nullable. To be honest I've never been sure why intellisense doesn't work for attrs, I assumed it had to do with the complexity of the hyperscript signature. I won't have a lot of time to look into this for a while unfortunately.

I'll leave this issue open if anyone else has any insights.

oldrich-s commented 7 years ago

Interesting. I have filled a similar issue at VSCode https://github.com/Microsoft/vscode/issues/30709 but I am not sure if the problem is with VSCode or Typescript.