Type Error when building package that uses @prismicio/helpers

My project is a nextjs typescript project with the following package.json excerpt:

{
// ...
"dependencies": {
  // ...
  "@prismicio/client": "^6.4.2",
  "@prismicio/helpers": "^2.3.3",
  "@prismicio/next": "^0.1.2",
  "@prismicio/react": "^2.2.0",
  "@prismicio/slice-simulator-react": "^0.2.1",
},
"devDependencies": {
  "@babel/core": "^7.18.2",
  "@types/node": "17.0.23",
  "@types/react": "17.0.43",
  "@types/react-dom": "17.0.14",
  "@prismicio/types": "^0.2.3",
  "typescript": "4.6.3",
  "slice-machine-ui": "^0.3.8",
  // ....
},
"resolutions": {
  "@types/react": "17.0.30"
}
}

I'm getting this error upon yarn build:

app:build: ../../node_modules/@prismicio/helpers/dist/index.d.ts:386:2
app:build: Type error: '?' expected.
app:build: 
app:build:   384 |     embed_url: string;
app:build:   385 |     html: string | null;
app:build: > 386 | }) ? {
app:build:       |  ^
app:build:   387 |     [x: string]: never;
app:build:   388 | } | (Data & {
app:build:   389 |     embed_url: string;

Any suggestions?

1 Like

Would like to point out my tsconfig.json is as follows:
(i am excluding node_modules)

{
  "extends": "tsconfig/nextjs.json",
  "compilerOptions": {},
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

Hi @webadmin

Thanks for reaching out.

For your reference, It seems that it is the same issue as this one

I'm still not sure about the fix, I will do some research and get back to you.

It seems that updating your TypeScript to the latest version should solve the issue. Can you try and let us know?

Hi there, to touch base on this, we still have this problem.
Working:

β”œβ”€β”€ @prismicio/client@6.5.1
β”œβ”€β”€ @prismicio/helpers@2.3.0
β”œβ”€β”€ @prismicio/types@0.1.27
β”œβ”€β”€ apollo-link-prismic@1.1.1
β”œβ”€β”€ prismic-dom@2.2.7
β”œβ”€β”€ typescript@4.8.3

Upgrading, breaks:

TypeScript

β”œβ”€β”€ @prismicio/client@6.7.1
β”œβ”€β”€ @prismicio/helpers@2.3.3
β”œβ”€β”€ @prismicio/types@0.2.3
β”œβ”€β”€ apollo-link-prismic@1.1.1
β”œβ”€β”€ prismic-dom@2.2.7
β”œβ”€β”€ typescript@4.8.3

Using @stencil/core@2.17.4 but it should have any impact
tsconfig.json

{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"declaration": false,
"experimentalDecorators": true,
"lib": [
"dom",
"es2019"
],
"moduleResolution": "node",
"module": "esnext",
"target": "es2017",
"noUnusedLocals": true,
"noUnusedParameters": true,
"jsx": "react",
"jsxFactory": "h",
"resolveJsonModule" : true,
"removeComments": true,
"skipLibCheck": true
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}

Ok, I'm checking with our dev team, and I will get back to you.

Hi, well, I've checked with our dev team, and for us upgrading TypeScript should have fixed the issue, but it’s possible you have multiple versions of TypeScript installed.

The wrong version might be used to build the website.

We have written a fix for @prismicio/helpers that should solve this issue regardless of TypeScript versions, but it’ll need to be reviewed before merging and publishing. We should be able to publish a fix in the next week or 2.

1 Like

Ok, thanks. No, I am using the right version used in the package.json, no global installation
Could you let me know how I could trace when the fix is released ?

Seems last helpers update solved the issue @Pau @Fares

β”œβ”€β”€ @prismicio/client@6.7.1
β”œβ”€β”€ @prismicio/helpers@2.3.4
β”œβ”€β”€ @prismicio/next@0.1.5
β”œβ”€β”€ @prismicio/react@2.5.0
β”œβ”€β”€ @prismicio/slice-simulator-react@0.2.2
β”œβ”€β”€ @prismicio/types@0.2.3
β”œβ”€β”€ @tailwindcss/aspect-ratio@0.4.2
β”œβ”€β”€ autoprefixer@10.4.11
β”œβ”€β”€ clsx@1.2.1
β”œβ”€β”€ concurrently@7.4.0
β”œβ”€β”€ eslint-config-next@12.3.1
β”œβ”€β”€ eslint@8.23.1
β”œβ”€β”€ flag-icons@6.6.6
β”œβ”€β”€ next@12.3.1
β”œβ”€β”€ node-fetch@3.2.10
β”œβ”€β”€ postcss@8.4.16
β”œβ”€β”€ prettier-plugin-tailwindcss@0.1.13
β”œβ”€β”€ prettier@2.7.1
β”œβ”€β”€ prismic-ts-codegen@0.1.5
β”œβ”€β”€ react-dom@18.2.0
β”œβ”€β”€ react@18.2.0
β”œβ”€β”€ slice-machine-ui@0.4.2
└── tailwindcss@3.1.8

1 Like

Yes, effectively, Updating to the latest version, v2.3.5 should solve the issue.

npm install @prismicio/helpers@latest

If that doesn't work, they may need to update @prismicio/helpers in dependencies as well:

npm update @prismicio/helpers@latest