electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 99 forks source link

Typescript imports cannot work correctly with typescript definition files #294

Open kestred opened 6 years ago

kestred commented 6 years ago

Using electron-prebuilt-compile, typescript does not correctly support default imports.

I had expected that this would work: import Vue from 'vue'; but, it returns undefined.

Using import Vue as * from 'vue'; works, however it is incompatible with typescript linters and the typescript compiler itself would refuse to compile the same code (b.c. of type errors).


I had assumed that it was an issue with the _compilerc and tsconfig.json files, however after trying every variation that I could find, I've given up on solving it through configuration.

Here are two example configs, both which do not appear to work:

{
  "compilerOptions": {
    // this aligns with Vue's browser support
    "target": "es5",
    // this enables stricter inference for data properties on `this`
    "strict": true,
    // if using webpack 2+ or rollup, to leverage tree shaking:
    "module": "es2015",
    "moduleResolution": "node"
  }
}

and

  "compilerOptions": {
        "removeComments": false,
        "preserveConstEnums": true,
        "sourceMap": true,
        "declaration": true,
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "suppressImplicitAnyIndexErrors": true,
        "strictNullChecks": true,
        "noUnusedLocals": true,
        "noImplicitThis": true,
        "noUnusedParameters": true,
        "importHelpers": true,
        "noEmitHelpers": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "pretty": true,
        "target": "es2015",
        "typeRoots": ["./types"]
},
justinneff commented 6 years ago

Did anyone figured out the correct way to configure compilerc to correct this problem?