TheTechsTech / node-7z-archive

ESM front-end to 7-Zip, featuring alternative 7z CLI tool, binaries for Linux, Windows, Mac OSX, and seamlessly create 7zip SFX self extracting archives targeting different platforms.
MIT License
13 stars 7 forks source link

feat: convert to TypeScript #12

Closed aminya closed 2 years ago

TheTechsTech commented 2 years ago

Nice work!

There are enough changes to require major version update in package.json to v2.0.0, and update contributors. There also needs to be some type change log added, or update readme.

aminya commented 2 years ago

Thank you

There are enough changes to require major version update in package.json to v2.0.0

The code is backwards compatible. I didn't change the logic or API, so I don't think it is needed to bump the major version. But it is up to you if you like.

TheTechsTech commented 2 years ago

There are issues when i just published this might need to revert.

> node-7z-archive@1.1.0 build C:\Users\Lenovo\Documents\node-7z-archive
> tsc -p ./ || echo done

src/createSfx.ts:131:25 - error TS2345: Argument of type '(resolve: (arg0: string) => void, reject: (arg0: string) => void, progress: (arg0: any) => any) => void' is not assignable to parameter of type '(resolve: (value: string) => void, reject: (reason: any) => void) => void'.
131     return when.promise(function (
                            ~~~~~~~~

src/createSfx.ts:140:33 - error TS2345: Argument of type 'string | null' is not assignable to parameter of type 'string'.
  Type 'null' is not assignable to type 'string'.

140         let SfxDirectory = join(directory, 'SfxPackages');
                                    ~~~~~~~~~

src/createSfx.ts:191:14 - error TS2339: Property 'progress' does not exist on type 'Promise<unknown>'.

191             .progress((data: any) => {
                 ~~~~~~~~

src/index.ts:20:10 - error TS2339: Property 'progress' does not exist on type 'Promise<unknown>'.

20         .progress(function (data: any) {
            ~~~~~~~~

src/index.ts:29:18 - error TS2339: Property 'progress' does not exist on type 'Promise<unknown>'.

29                 .progress(function (data: any) {
                    ~~~~~~~~

src/index.ts:64:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) => any) => any' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

64             return when.promise(function (
                                   ~~~~~~~~

src/index.ts:176:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) 
=> any) => any' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

176             return when.promise(function (
                                    ~~~~~~~~

src/index.ts:239:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) 
=> any) => any' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

239             return when.promise(function (
                                    ~~~~~~~~

src/index.ts:299:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) 
=> any) => void' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

299             return when.promise(function (
                                    ~~~~~~~~

src/index.ts:356:46 - error TS2345: Argument of type '{ date: Date; attr: string; size: number; name: string; }' is not assignable to parameter of type 'string'.

356                                 entries.push(e);
                                                 ~

src/index.ts:367:22 - error TS2339: Property 'progress' does not exist on type 'Promise<unknown>'.

367                     .progress(function (data: string) {
                         ~~~~~~~~

src/index.ts:379:34 - error TS2339: Property 'progress' does not exist on type 'Promise<unknown>'.

379                                 .progress(function (data: string) {
                                     ~~~~~~~~

src/index.ts:420:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) 
=> any) => any' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

420             return when.promise(function (
                                    ~~~~~~~~

src/index.ts:487:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) 
=> any) => any' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

487             return when.promise(function (
                                    ~~~~~~~~

src/index.ts:546:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) 
=> any) => any' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

546             return when.promise(function (
                                    ~~~~~~~~

src/index.ts:609:33 - error TS2345: Argument of type '(resolve: (value: any) => void, reject: (reason: any) => void, progress: (arg0: any) 
=> any) => any' is not assignable to parameter of type '(resolve: (value: any) => void, reject: (reason: any) => void) => void'.

609             return when.promise(function (
                                    ~~~~~~~~

src/utility.ts:88:25 - error TS2345: Argument of type '(fulfill: (arg0: string[]) => void, reject: (arg0: Error) => void, progress: (arg0: 
any) => void) => void' is not assignable to parameter of type '(resolve: (value: string[]) => void, reject: (reason: any) => void) => void'.

88     return when.promise(function (
                           ~~~~~~~~

src/utility.ts:180:23 - error TS7030: Not all code paths return a value.

180         let onerror = (data: string) => {
aminya commented 2 years ago

I added || echo done after the build command because of that. It will ignore these errors. TypeScript will transpile that code without any issues. We have to address these type errors later, but it is not necessary for a functional code.