Search code examples
javascriptangulartypescript

Error TS1383: Only named exports may use 'export type'


Could someone please help me with this error?

Error: node_modules/date-fns/index.d.ts:246:1 - error TS1383: Only named exports may use 'export type'.

246 export type * from "./types.js";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typescript version
"typescript": "^4.9.3"
npm version
10.5.0
angular 16
"@angular/material": "^15.2.9",

I use the latest version of typescript but it causes other problems.


Solution

  • This is a known issue of date-fns. There are two options to fix the error:

    1. Downgrade date-fns to v3.1.0
    2. Update TypeScript to v5. For this you will need to update Angular to v16, see the version compatibility table