TypeStrong / tsify

Browserify plugin for compiling TypeScript
344 stars 75 forks source link

Compiler Opions Error - updating to 4.0.2 from 4.0.1 #266

Closed DaveO-Home closed 4 years ago

DaveO-Home commented 4 years ago

Error: TypeScript error: /home/ng/public/node_modules/tsify/index.d.ts(4,18): Error TS2430: Interface 'Options' incorrectly extends interface 'CompilerOptions'. Types of property 'project' are incompatible. Type 'string | CompilerOptions' is not assignable to type 'string'. Type 'CompilerOptions' is not assignable to type 'string'.

cartant commented 4 years ago

https://github.com/TypeStrong/tsify/pull/264

DaveO-Home commented 4 years ago

@cartant 5.0.0 breaks with Error: TypeScript error: /home/ng/public/node_modules/tsify/index.d.ts(2,8): Error TS1259: Module '"/home/ng/public/node_modules/typescript/lib/typescript"' can only be default-imported using the 'esModuleInterop' flag

Using typescript: 3.9.7

config:

{
    "name": "browserify",
    "compilerOptions": {
        "sourceMap": true,
        "typeRoots": [
            "./types",
            "../node_modules/@types"
        ],
        "lib": ["es6", "dom"],
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "isolatedModules": false,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noUnusedLocals": true,
        "noImplicitUseStrict": false,
        "removeComments": false,
        "preserveConstEnums": true,
        "suppressImplicitAnyIndexErrors": false,
        "allowJs": true,
        "types": [
            "jqueryfn",
            "jquery",
            "jasmine",
            "node"
        ]
    },
    "exclude": [
      "loader/**/*",
      "modules/**/*",
      "node_modules"
    ],
    "compileOnSave": true,
    "buildOnSave": false
}
cartant commented 4 years ago

Can you verify that this is the only change required?

import * as typescript from "typescript";
import { CompilerOptions, ModuleKind, ScriptTarget } from "typescript";

I don't have the time to do this myself.

DaveO-Home commented 4 years ago

Got:

Error: TypeScript error: /home/daveo/NetBeans/acceptance-tests-ng/public/node_modules/tsify/index.d.ts(9,2): Error TS2411: Property 'typescript' of type 'string | typeof ts' is not assignable to string index type 'string | number | boolean | string[] | (string | number)[] | TsConfigSourceFile | MapLike<string[]> | PluginImport[] | ProjectReference[]'.

Removed the | ... and it got past typescript, but of coarse the bundle was not usable.

cartant commented 4 years ago

That error was effected by @types/browserify being missing. 5.0.1 has been published with the change I mentioned above.

... and it got past typescript, but of coarse the bundle was not usable.

If that's the case, it sounds like you have additional problems. No changes other than those made to the types were made in 4.0.2 or 5.0.0.

DaveO-Home commented 4 years ago

5.0.1 works for typescript, however looks like jquery is not being resolved any more. Will have to dig deeper..., for now I'm reverting back to 4.0.1.

DaveO-Home commented 4 years ago

Ok, your change does have an impact on existing code; Any import like import * jquery from "jquery" must now be: import jquery from "jquery"