eslint / rewrite

Monorepo for the new version of ESLint
Apache License 2.0
65 stars 4 forks source link

chore: Simplify type generation #23

Closed nzakas closed 1 month ago

nzakas commented 1 month ago

This simplifies the generation of type definitions.

  1. Uses a // @ts-self-types comment to specify types in the rolled-up packages, eliminating the need for a separate step to add a triple-slash directive.
  2. Eliminates all tsconfig.cjs.json configurations. It turns out we can just copy over index.d.ts to index.d.cts and TypeScript will be happy.
harish-sethuraman commented 1 month ago
  1. Sorry to ask again but I'm kind of confused with so many of these ts configs and stuff. I can still see 3 files index.d.ts type.d.ts and a type.ts file.

in that case why do we have type.d.ts (this seems like exact replica of type.ts)

  1. One more thing that I noticed is I removed all tsconfig.json and built the package just with plain rollup and still can see type.ts in the esm and cjs of dist folder as index.js imports declarations. In that case should we actually remove the copy plugin that does the exact same thing?
nzakas commented 1 month ago

in that case why do we have type.d.ts (this seems like exact replica of type.ts)

tsc generates this. Maybe it's not needed, but I don't see the harm in leaving it. No need to add another step to the process.

2. One more thing that I noticed is I removed all tsconfig.json and built the package just with plain rollup and still can see type.ts in the esm and cjs of dist folder as index.js imports declarations. In that case should we actually remove the copy plugin that does the exact same thing?

I'm guessing that you didn't delete dist before doing this. If you delete dist and try npm run build without Rollup copying over types.ts, you'll get a tsc error.