R
Railway2y ago
mina

Typescript build fails - incorrect type inference

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?
36 Replies
Percy
Percy2y ago
Project ID: N/A
mina
minaOP2y ago
N/A This issue happens locally as well as on Codebuild/Flightcontrol
jr
jr2y ago
Interesting. What version of Nixpacks did it last work?
alex
alex2y ago
Locally with nixpacks?
jr
jr2y ago
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
mina
minaOP2y ago
Yes
alex
alex2y ago
Ah ok but it’s fine building with tsc in a local environment? What node version are you using
mina
minaOP2y ago
So builds locally without NixPacks Fails to build locally with NixPacks
alex
alex2y ago
What node version
mina
minaOP2y ago
Without NixPacks 18.15 or 18.16 work With NixPacks I can only get 18.12
alex
alex2y ago
Do you use any global packages Dockerfile will fix that issue
mina
minaOP2y ago
You mean build using Dockerfile? Yeah sure, but this is not my goal coming here 😅
Brody
Brody2y ago
thats fair, might be best to fix the code issue than
alex
alex2y ago
Yeah I mean that will fix the problem but like jr said if you need a specific version it might be a code issue
Brody
Brody2y ago
or code incompatibilities
alex
alex2y ago
Yeah Can you send the typescript error you’re getting Please
Brody
Brody2y ago
alex sleeps and breaths ts
alex
alex2y ago
Heheheha
alex
alex2y ago
Nice gitignore
alex
alex2y ago
@Brody ^
Brody
Brody2y ago
oof
mina
minaOP2y ago
@alex and @Brody Here is the correct type of an object:
alex
alex2y ago
What is the error tho
mina
minaOP2y ago
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.
#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.
alex
alex2y ago
skeletonconfused look again later
mina
minaOP2y ago
exactly, it something very odd and does not make sense
jr
jr2y ago
This is due to the Nixpkgs archive being an older version. You can change it via a nixpacks.toml file. For example
[phases.setup]
nixpkgsArchive = 'f2e9a130461950270f87630b11132323706b4d91'
[phases.setup]
nixpkgsArchive = 'f2e9a130461950270f87630b11132323706b4d91'
Although I don't know why the node version would be causing a TypeScript error
alex
alex2y ago
It shouldn’t That’s the thing Any 18.xx should be compatible with any 18.xx code
mina
minaOP2y ago
would that bring a new Node version @jr, I can try it But as @alex mentioned, I do not think it is a node verion 18.12 builds fine outside NixPacks
jr
jr2y ago
Could it be an environment variable? Nixpacks sets the following for now - NODE_ENV=production - NPM_CONFIG_PRODUCTION=false
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jr
jr2y ago
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 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
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
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
mina
minaOP2y ago
I was able to reproduce the issue here:
FROM node:18-buster

WORKDIR /app

COPY . /app

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

RUN pnpm run build --filter web
FROM node:18-buster

WORKDIR /app

COPY . /app

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

RUN pnpm run build --filter web
I am getting the same error as NixPacks
alex
alex2y ago
Core pack is installed by default isn’t it?
jr
jr2y ago
If so, that is great to know! I was scratching my head for this one
Want results from more Discord servers?
Add your server