electrovir / pdf-text-reader

Dead simple pdf text reader
https://electrovir.github.io/pdf-text-reader/
Creative Commons Zero v1.0 Universal
33 stars 4 forks source link

Type errors because of dependency: @augment-vir/common #8

Closed JClackett closed 1 year ago

JClackett commented 1 year ago

It seems when using this package, I now get type errors inside the "@augment-vir/common" package, even though I have skipLibCheck: true and exclude node_modules in my tsconfig.

Any idea how to stop this? or if theres changes needed in this package?

I see that this package import just this:

import { type PartialAndUndefined } from '@augment-vir/common';

if I patch this package to just define it locally the TS errors go away

electrovir commented 1 year ago

I'll take a look! Can you please provide:

JClackett commented 1 year ago
node: v18.12.1
TS: 4.9.5
@augment, currently patching this package, but:

└─┬ pdf-text-reader@4.0.0 -> ./../../node_modules/.pnpm/pdf-text-reader@4.0.0_patch_hash=crw5mrlyq2747knynm57dp2u3u/node_modules/pdf-text-reader
  └── @augment-vir/common@16.4.2 -> ./../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common

There's a lot of errors, but here's some:

../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/boolean.d.ts:6:34 - error TS1139: Type parameter declaration expected.
6 export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
                                   ~~~~~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/boolean.d.ts:6:76 - error TS1005: ',' expected.
6 export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
                                                                             ~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/boolean.d.ts:6:87 - error TS1005: ')' expected.
6 export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
                                                                                        ~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/boolean.d.ts:6:116 - error TS1005: ';' expected.
6 export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
                                                                                                                     ~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/boolean.d.ts:6:183 - error TS1005: ';' expected.
6 export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
                                                                                                                                                                                        ~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/boolean.d.ts:6:231 - error TS1005: ';' expected.
6 export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
                                                                                                                                                                                                                                        ~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/boolean.d.ts:6:232 - error TS1128: Declaration or statement expected.
6 export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
                                                                                                                                                                                                                                         ~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/object/enum.d.ts:7:36 - error TS1139: Type parameter declaration expected.
7 export declare function ensureEnum<const ValueType extends `${EnumType[keyof EnumType]}`, const EnumType extends EnumBaseType>(value: ValueType, checkEnum: EnumType): EnumType[keyof EnumType];
                                     ~~~~~
../../node_modules/.pnpm/@augment-vir+common@16.4.2/node_modules/@augment-vir/common/dist/types/augments/object/enum.d.ts:7:52 - error TS1005: ',' expected.
7 export declare function ensureEnum<const ValueType extends `${EnumType[keyof EnumType]}`, const EnumType extends EnumBaseType>(value: ValueType, checkEnum: EnumType): EnumType[keyof EnumType];
electrovir commented 1 year ago

Ah! I see what it is, thanks for the info. The const type parameter was introduced in TS 5.0: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#const-type-parameters

So despite lib checks being turned off, TS 4.9.5 doesn't know how to parse const in that context.

Is it possible for you to upgrade your TS version?

JClackett commented 1 year ago

Ah yeah, once I pasted my TS version I thought that may be it... this is quite a large client project so upgrading TS just for this feature wasn't really expected haha, will run the patch until we upgrade TS! but thanks for the help

electrovir commented 1 year ago

I'll try to publish a version of this package to support < TS 5.0. Should be easy, so why not?

electrovir commented 1 year ago

v4.0.1 removes the dependency on @augment-vir/common and is now published on npm.

I also published a documentation GitHub Pages site here: https://electrovir.github.io/pdf-text-reader

@JClackett please let me know if this release doesn't fix the issues you are running into!