TypeStrong / tsify

Browserify plugin for compiling TypeScript
344 stars 75 forks source link

TypeScript types are likely incorrect #270

Open ericmorand opened 3 years ago

ericmorand commented 3 years ago

Compiling, then running the following TypeScript module output undefined:

import tsify from "tsify";

console.log(tsify); // undefined

Of course, passing tsify to Browserify would throw a Cannot find module 'undefined' error.

ericmorand commented 3 years ago

@brianloveswords , you may be interested. I see that you fixed the typings some months ago.

ericmorand commented 3 years ago

I think this types definition is the correct one:

// Note that @types/browserify is not used for a reason:
// https://github.com/TypeStrong/tsify/issues/267

import * as typescript from "typescript";

declare namespace tsify {
    export interface Options {
        exclude?: string[];
        files?: string[];
        global?: boolean;
        include?: string[];
        m?: string;
        p?: string | Record<string, any>;
        project?: string | Record<string, any>;
        t?: string;
        typescript?: string | typeof typescript;
    }

}

declare var tsify: (b: any, opts: tsify.Options) => any;

export = tsify;
ericmorand commented 3 years ago

Also, jsx is missing in Options defintion. As most TypeScript CompilerOptions properties.

cartant commented 3 years ago

I think this types definition is the correct one: ...

Yeah, you are right. If you want to open a PR for the change, that would be appreciated.

As most TypeScript CompilerOptions properties.

IMO it's unrealistic to support every project and compiler option via command line and plugin options. Use a tsconfig.json file.