12

I'm working in an Electron project with checkjs: true set in my jsconfig.json and have created a file with custom typings in ProjectRoot/typings/index.d.ts.

I'd like to have those typings available in all JS files. Unfortunately I have to reference them manually:

enter image description here

Without the manual reference, it won't recognize the type:

enter image description here

My Project structure looks like this:

enter image description here

Here's the content of typings/index.d.ts:

interface LauncherItem {
    name: string,
    icon: string,
    cmd: string,
    args: string,
}

interface AppConfig {
    items: LauncherItem[],
    appIconSize: number,
}

And jsconfig.json:

{
    "compilerOptions": {
        "target": "es6",
        "checkJs": true
    },
    "typeAcquisition": {
        "include": [
            "./typings/index.d.ts"
        ]
    },
    "include": [
        "**/*.js",
        "*.d.ts"
    ]
}

Not sure if the explicit typeAcquisition and include of *.d.ts is usually necessary. They're just a result of my tests but obviously didn't work...

suamikim
  • 5,350
  • 9
  • 40
  • 75
  • did you manage with this? if you remember :) – Samih A Nov 19 '18 at 13:28
  • No, I have not found a way around this. Please keep me posted if you do ;) – suamikim Nov 28 '18 at 07:29
  • 2
    Short update: I just removed the manual `reference path` from the js file and the `typeAcquisition` in `jsconfig.json` and it still recognizes the correct type for `AppConfig`. So it seems like this had been an issue in VSCode and had been fixed in one of the updates since Jun... – suamikim Nov 28 '18 at 07:43
  • Thanks for the update – Samih A Dec 15 '18 at 13:43

0 Answers0