Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript build error on Node14.x #252

Closed
claridgicus opened this issue Aug 4, 2022 · 4 comments
Closed

Typescript build error on Node14.x #252

claridgicus opened this issue Aug 4, 2022 · 4 comments

Comments

@claridgicus
Copy link

claridgicus commented Aug 4, 2022

Node v14.19.1 - v14.20.0
Typescript 4.3.x - 4.7.4
Angular 12.x - 14.x

Repro steps

Install fresh Angular
Install Prismic client and helpers
Reference the prismic client in a service or component
Serve the project
Receive the below messages and an exception that kills the build

I've tried a totally fresh install of 14, going back to angular 12, and numerous TS versions.

I believe this is a straight typescript behaviour and something similar is referenced here microsoft/TypeScript#47357


Error: node_modules/@prismicio/helpers/dist/index.d.ts:310:400 - error TS2536: Type 'P' cannot be used to index type 'EmptyImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, EmptyImageFieldImage | FilledImageFieldImage>'.

310 }, ThumbnailNames extends Exclude<keyof Field, number | symbol | "url" | "dimensions" | "alt" | "copyright">>(field: Field | ((_prismicio_types.EmptyImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage> extends infer T ? { [P in keyof T]: (_prismicio_types.EmptyImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage>)[P]; } : never) | (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage> extends infer T_1 ? { [P_1 in keyof T_1]: (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage>)[P_1]; } : never)) | null | undefined) => field is _prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.FilledImageFieldImage> extends infer T_2 ? { [P_2 in keyof T_2]: (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.FilledImageFieldImage>)[P_2]; } : never;
                                                                                                                                                                                                                                                                                                                                                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Error: node_modules/@prismicio/helpers/dist/index.d.ts:310:935 - error TS2536: Type 'P_1' cannot be used to index type 'FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, EmptyImageFieldImage | FilledImageFieldImage>'.

310 }, ThumbnailNames extends Exclude<keyof Field, number | symbol | "url" | "dimensions" | "alt" | "copyright">>(field: Field | ((_prismicio_types.EmptyImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage> extends infer T ? { [P in keyof T]: (_prismicio_types.EmptyImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage>)[P]; } : never) | (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage> extends infer T_1 ? { [P_1 in keyof T_1]: (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage>)[P_1]; } : never)) | null | undefined) => field is _prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.FilledImageFieldImage> extends infer T_2 ? { [P_2 in keyof T_2]: (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.FilledImageFieldImage>)[P_2]; } : never;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Error: node_modules/@prismicio/helpers/dist/index.d.ts:310:1463 - error TS2536: Type 'P_2' cannot be used to index type 'FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, FilledImageFieldImage>'.

310 }, ThumbnailNames extends Exclude<keyof Field, number | symbol | "url" | "dimensions" | "alt" | "copyright">>(field: Field | ((_prismicio_types.EmptyImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage> extends infer T ? { [P in keyof T]: (_prismicio_types.EmptyImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage>)[P]; } : never) | (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage> extends infer T_1 ? { [P_1 in keyof T_1]: (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.EmptyImageFieldImage | _prismicio_types.FilledImageFieldImage>)[P_1]; } : never)) | null | undefined) => field is _prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.FilledImageFieldImage> extends infer T_2 ? { [P_2 in keyof T_2]: (_prismicio_types.FilledImageFieldImage & Record<ThumbnailNames extends string ? Exclude<ThumbnailNames, "url" | "dimensions" | "alt" | "copyright"> : never, _prismicio_types.FilledImageFieldImage>)[P_2]; } : never;

Error: node_modules/@prismicio/helpers/dist/index.d.ts:399:2 - error TS1005: '?' expected.

399 }) ? {
     ~


Error: node_modules/@prismicio/helpers/dist/index.d.ts:409:2 - error TS1005: '?' expected.

409 }) ? Data_1 & {
@claridgicus
Copy link
Author

When looking at the actual source file itself, typescript lights up like a Christmas tree complaining about this singular section of the file.

@angeloashmore
Copy link
Member

Hi @claridgicus, thanks for reporting this issue. It should be fixed now as of v6.6.4. Can you upgrade to the latest version and let me know if it works in your project?

You can upgrade to the latest version using the following command:

npm run install @prismicio/client@latest

If you're curious what the underlying issue was, you can find details in this PR here: prismicio/prismic-helpers#56

I'm going to close the issue since it should be fixed, but let me know if it doesn't and I'll reopen it and reinvestigate. Thanks again! 🙂

@claridgicus
Copy link
Author

@angeloashmore

The issue was fixed after upgrading to "@prismicio/helpers": "2.3.3"

Thanks

@angeloashmore
Copy link
Member

Ah, yes, I should have mentioned you'll need to upgrade @prismicio/helpers separately if you have it installed alongside @prismicio/client. Thanks for the insight! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants