TypeStrong / tsify

Browserify plugin for compiling TypeScript
344 stars 75 forks source link

Fix types in index.d.ts #264

Closed brianloveswords closed 4 years ago

brianloveswords commented 4 years ago

In the current version of (4.0.2) importing tsify in a TypeScript project causes the following compilation error:

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 | undefined' is not assignable to type 'string | undefined'.
      Type 'CompilerOptions' is not assignable to type 'string'.

   export interface Options extends CustomOptions, CompilerOptions {
                    ~~~~~~~

node_modules/tsify/index.d.ts:5:24 - error TS1340: Module 'typescript' does not refer to a type, but is used as a type here. Did you mean 'typeof import('typescript')'?

   typescript?: string | import("typescript");
                         ~~~~~~~~~~~~~~~~~~~~

node_modules/tsify/index.d.ts:13:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

   function tsify(b: BrowserifyObject, opts: Options): any;
   ~~~~~~~~

node_modules/tsify/index.d.ts:15:1 - error TS2309: An export assignment cannot be used in a module with other exported elements.

   export = tsify;
   ~~~~~~~~~~~~~~~

Found 4 errors.

This change fixes those errors in a way that maintains compatibility with TypeScript >= 2.8.

Testing

I'm not sure how best to include automated tests for this change in this repository. You can review my manual testing strategy at brianloveswords/tsify-repro-types-issue.

cartant commented 4 years ago

Thanks. I'll try to get this merged and published, later today.

cartant commented 4 years ago

Version 5.0.0 should be available, now, and should include your fix.

brianloveswords commented 4 years ago

Thank you for the quick review, merge, and release!