Skip to content

[Bug]: TypeScript Strict Mode Errors in Line Item Price Components #556

@bramdupont

Description

@bramdupont

Package.json file

{
	"name": "joda-sign-next-storefront",
	"version": "0.5.0",
	"description": "A blank template to get started with Payload 3.0",
	"license": "MIT",
	"type": "module",
	"scripts": {
		"build": "cross-env NODE_OPTIONS=--no-deprecation next build",
		"dev": "cross-env NODE_OPTIONS=--no-deprecation next dev --turbopack",
		"devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
		"generate:importmap": "cross-env NODE_OPTIONS=--no-deprecation payload generate:importmap",
		"generate:types": "cross-env NODE_OPTIONS=--no-deprecation payload generate:types",
		"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
		"payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
		"start": "cross-env NODE_OPTIONS=--no-deprecation next start"
	},
	"dependencies": {
		"@headlessui/react": "^2.2.9",
		"@heroicons/react": "^2.2.0",
		"@medusajs/icons": "latest",
		"@medusajs/js-sdk": "latest",
		"@medusajs/ui": "latest",
		"@payloadcms/db-postgres": "^3.69.0",
		"@payloadcms/live-preview-react": "^3.69.0",
		"@payloadcms/next": "^3.69.0",
		"@payloadcms/payload-cloud": "^3.69.0",
		"@payloadcms/plugin-form-builder": "^3.69.0",
		"@payloadcms/plugin-redirects": "^3.69.0",
		"@payloadcms/plugin-search": "^3.69.0",
		"@payloadcms/plugin-seo": "^3.69.0",
		"@payloadcms/richtext-lexical": "^3.69.0",
		"@payloadcms/storage-vercel-blob": "^3.69.0",
		"@payloadcms/translations": "^3.69.0",
		"@payloadcms/ui": "^3.69.0",
		"@radix-ui/react-accordion": "^1.2.12",
		"@radix-ui/react-checkbox": "^1.3.3",
		"@radix-ui/react-icons": "^1.3.2",
		"@radix-ui/react-label": "^2.1.8",
		"@radix-ui/react-select": "^2.2.6",
		"@radix-ui/react-slot": "^1.2.4",
		"@stripe/react-stripe-js": "^3.10.0",
		"@stripe/stripe-js": "^6.1.0",
		"@tailwindcss/postcss": "^4.1.18",
		"add": "^2.0.6",
		"axios": "^1.13.2",
		"class-variance-authority": "^0.7.1",
		"classnames": "^2.5.1",
		"clsx": "^2.1.1",
		"cross-env": "^7.0.3",
		"graphql": "^16.12.0",
		"lodash": "^4.17.21",
		"lucide-react": "^0.483.0",
		"next": "15.4.8",
		"payload": "^3.69.0",
		"pnpm": "^10.26.1",
		"postcss": "^8.5.6",
		"radix-ui": "^1.4.3",
		"react": "19.2.3",
		"react-country-flag": "^3.1.0",
		"react-dom": "19.2.3",
		"react-hook-form": "^7.69.0",
		"sharp": "0.32.6",
		"swiper": "^11.2.10",
		"swr": "^2.3.8",
		"tailwind-merge": "^3.4.0",
		"tailwindcss": "^4.1.18"
	},
	"devDependencies": {
		"@biomejs/biome": "2.2.0",
		"@eslint/eslintrc": "^3.3.3",
		"@medusajs/types": "latest",
		"@medusajs/ui-preset": "latest",
		"@svgr/webpack": "^8.1.0",
		"@types/lodash": "^4.17.21",
		"@types/node": "^22.19.3",
		"@types/react": "19.0.7",
		"@types/react-dom": "19.0.3",
		"eslint": "^9.39.2",
		"eslint-config-next": "15.3.0",
		"prettier": "^3.7.4",
		"typescript": "5.7.3"
	},
	"packageManager": "pnpm@10.26.1",
	"engines": {
		"node": "^18.20.2 || >=20.9.0"
	},
	"pnpm": {
		"onlyBuiltDependencies": [
			"sharp"
		]
	}
}

Node.js version

V24.12.0

Operating system name and version

MacOS 26.1 (25B78)

Browser name

Google Chrome

What happended?

When building a Next.js storefront using the official Medusa starter with TypeScript strict mode enabled, the build fails with TypeScript errors in the line-item price components. The code directly uses total, original_total, and quantity properties from cart/order line items without null checks, but these properties are typed as potentially undefined in @medusajs/types.

Expected behavior

The official starter should build successfully with TypeScript strict mode enabled ("strict": true in tsconfig.json). Line item price components should handle potentially undefined values gracefully without requiring manual fixes from developers.

Actual behavior

TypeScript throws strict null check errors during build:

TS18048: 'total' is possibly 'undefined'
TS18048: 'original_total' is possibly 'undefined'
TS18048: 'quantity' is possibly 'undefined'
TS2322: Type 'number | undefined' is not assignable to type 'number'
The build fails, and developers must manually add null safety checks to these components before they can deploy their application.

Link to reproduction repo

/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions