#Typescript build fails - incorrect type inference

53 messages · Page 1 of 1 (latest)

dull quarry
#

Hello, trying to build the project https://github.com/datner/renu with NixPaxks 1.6.1. It used to be working fine. But recently started to get Typescript errors that do not happen on local build. Typescript is inferring wrong types to variables.
Anyone familiar with something like that?

outer orchidBOT
#

Project ID: N/A

dull quarry
#

N/A

#

This issue happens locally as well as on Codebuild/Flightcontrol

hot talon
#

Interesting. What version of Nixpacks did it last work?

scenic gate
hot talon
#

I am having issues building the repo locally (without Nixpacks).
It seems like the repo needs a very specific version Node (18.13 doesn't work but 18.15 gets further in the build?). I see the typescript error when using Nixpacks locally, but being unable to get it to build locally without Nixpacks makes me think that it is a code issue

dull quarry
scenic gate
#

What node version are you using

dull quarry
dull quarry
#

With NixPacks I can only get 18.12

scenic gate
#

Do you use any global packages

scenic gate
dull quarry
hearty blaze
#

thats fair, might be best to fix the code issue than

scenic gate
hearty blaze
#

or code incompatibilities

scenic gate
#

Yeah

#

Can you send the typescript error you’re getting

#

Please

hearty blaze
#

alex sleeps and breaths ts

scenic gate
#

Heheheha

#

Nice gitignore

#

@hearty blaze ^

hearty blaze
#

oof

dull quarry
#

@scenic gate and @hearty blaze
Here is the correct type of an object:

scenic gate
#

What is the error tho

dull quarry
#

here is the error:

#13 2.761 web:build: info  - Linting and checking validity of types...
#13 14.64 web:build: Failed to compile.
#13 14.64 web:build:
#13 14.64 web:build: ./pages/menu/[restaurant].tsx:74:81
#13 14.64 web:build: Type error: Property 'id' does not exist on type '{ readonly content: readonly { readonly locale: "en" | "he"; readonly name: string; readonly description: Option<string>; }[]; readonly modifiers: readonly {}[]; }'.
#13 14.64 web:build:
#13 14.64 web:build:   72 |             <Category.Section key={category.id} category={category}>
#13 14.64 web:build:   73 |               <Category.Items>
#13 14.64 web:build: > 74 |                 {category.categoryItems.map((ci) => <Category.Item key={ci.item.id} item={ci} />)}
#13 14.64 web:build:      |                                                                                 ^
#13 14.64 web:build:   75 |               </Category.Items>
#13 14.64 web:build:   76 |             </Category.Section>
#13 14.64 web:build:   77 |           ))}
#13 14.81 web:build:  ELIFECYCLE  Command failed with exit code 1.
#13 14.83
#13 14.83  Tasks:    1 successful, 2 total
#13 14.83 Cached:    0 cached, 2 total
#13 14.83   Time:    14.374s
#13 14.83
#13 14.83 web:build: ERROR: command finished with error: command (/app/apps/web) pnpm run build exited (1)
#13 14.83 command (/app/apps/web) pnpm run build exited (1)
#13 14.83  ERROR  run failed: command  exited (1)
#13 14.84  ELIFECYCLE  Command failed with exit code 1.
scenic gate
#

I’ll look again later

dull quarry
#

exactly, it something very odd and does not make sense

hot talon
#

Although I don't know why the node version would be causing a TypeScript error

scenic gate
#

That’s the thing

#

Any 18.xx should be compatible with any 18.xx code

dull quarry
#

But as @scenic gate mentioned, I do not think it is a node verion

#

18.12 builds fine outside NixPacks

hot talon
#

Could it be an environment variable? Nixpacks sets the following for now

  • NODE_ENV=production
  • NPM_CONFIG_PRODUCTION=false
stuck citrus
#

nope, already tried those env vars, work fine outside nixpacks

#

not sure what you need clarification on, but it builds fine outside nixpacks with NODE_ENV=production NPM_CONFIG_PRODUCTION=false

#

spent a long time trying to make sure everything is exactly the same

#

it's like this advanced TS is just falling over inside docker. some type of resource constraint?

hot talon
#

Hmm I'm really not sure. I still suspect it is a version issue. TypeScript is completing successfully, but it just has the wrong information and is reporting an error when it shouldn't

hot talon
#

Do you have a Dockerfile that works to build the project? I am trying

FROM node:18-alpine

WORKDIR /app

COPY . /app

RUN npm install -g corepack && corepack enable
RUN pnpm i --frozen-lockfile

RUN pnpm run build

But am seeing this error

Hashing error: cannot find package-file hash for eslint-config-custom#*.config.mjs!db/**/*.ts!integrations/**/*.ts!mailers/**/*.ts!package.json!pages/**/*.ts!*.config.js!pages/**/*.tsx!src/**/*.js!src/**/*.jsx!src/**/*.ts!src/**/*.tsx!tsconfig.json
#10 26.52 Hashing error: cannot find package-file hash for tsconfig#*.config.mjs!db/**/*.ts!integrations/**/*.ts!mailers/**/*.ts!package.json!pages/**/*.ts!*.config.js!pages/**/*.tsx!src/**/*.js!src/**/*.jsx!src/**/*.ts!src/**/*.tsx!tsconfig.json
dull quarry
#

I am getting the same error as NixPacks

scenic gate
#

Core pack is installed by default isn’t it?

hot talon