Problème
Après avoir mis à jour votre application Angular vers Angular 18, vous voyez une erreur de build telle que :
ts_error.txt
✘ [ERROR] TS2349: This expression is not callable.
Type 'typeof import("/home/uli/myproject/node_modules/dayjs/index.d.ts")' has no call signatures. [plugin angular-compiler]
src/app/day-js.service.ts:37:15:
37 │ const d2 = dayjs(d);
╵ ~~~~~
Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.
src/app/day-js.service.ts:3:0:
3 │ import * as dayjs from 'dayjs'Solution
Typescript 5.4 ne supporte plus le import * as X from 'X.
Par conséquent, vous devez changer
namespace_import_bad.ts
import * as dayjs from 'dayjs'en
default_import_fixed.ts
import dayjs from 'dayjs'
Consultez les articles similaires par catégorie :
Angular Typescript
Si cet article vous a aidé, pensez à m'offrir un café ou à faire un don via PayPal pour soutenir la recherche et la publication de nouveaux articles sur TechOverflow