Skip to content

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Oct 13, 2025

Description

Commits:

  1. Update tsconfig files to enable isolatedDeclarations, and tweak the files/scripts to properly segment which files should enforce isolatedDeclarations. We don't want it for test files for example.
  2. Ran https://github.com/microsoft/ts-fix. Ugly command but works:
ts-fix -t packages/vite/src/node/tsconfig.json -e 9007 -e 9008 -e 9009 -e 9010 -e 9011 -e 9012 -e 9013 -e 9014 -e 9015 -e 9016 -e 9017 -e 9018 -e 9019 -e 9020 -e 9021 -e 9022 -e 9023 -e 9024 -e 9025 -e 9026 --write --ignoreGitStatus
ts-fix -t packages/vite/src/module-runner/tsconfig.json -e 9007 -e 9008 -e 9009 -e 9010 -e 9011 -e 9012 -e 9013 -e 9014 -e 9015 -e 9016 -e 9017 -e 9018 -e 9019 -e 9020 -e 9021 -e 9022 -e 9023 -e 9024 -e 9025 -e 9026 --write --ignoreGitStatus
ts-fix -t packages/vite/src/shared/tsconfig.json -e 9007 -e 9008 -e 9009 -e 9010 -e 9011 -e 9012 -e 9013 -e 9014 -e 9015 -e 9016 -e 9017 -e 9018 -e 9019 -e 9020 -e 9021 -e 9022 -e 9023 -e 9024 -e 9025 -e 9026 --write --ignoreGitStatus
ts-fix -t packages/plugin-legacy/tsconfig.json -e 9007 -e 9008 -e 9009 -e 9010 -e 9011 -e 9012 -e 9013 -e 9014 -e 9015 -e 9016 -e 9017 -e 9018 -e 9019 -e 9020 -e 9021 -e 9022 -e 9023 -e 9024 -e 9025 -e 9026 --write --ignoreGitStatus
  1. and rest of commits, fix formatting/linting and make the types look nicer.

@bluwy bluwy marked this pull request as ready for review October 15, 2025 17:52
Comment on lines +394 to +396
export const buildEnvironmentOptionsDefaults: Readonly<
Partial<BuildEnvironmentOptions>
> = _buildEnvironmentOptionsDefaults
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and other similar setups are kinda funky to handle with isolated declarations, and they all relate to configDefaults, since our source code depends on satisifies and the inferred type. But it is an issue if we one day export configDefaults and its type, so the hoops here are as if we're tackling that now as isolated declarations don't know if the exported type is public

eslint.config.js Outdated
'n/prefer-node-protocol': 'error',

'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-generic-constructors': 'off',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this setting?

      '@typescript-eslint/consistent-generic-constructors': [
        'error',
        'type-annotation',
      ],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting that has 101 errors. I think in some cases type-annotation makes sense for exported types with isolated declaration, but nested code that doesn't need it writes better if the type is in the constructor instead. Probably typescript-eslint needs a new option (or tweak constructor) that balances for isolated declarations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. It seems typescript-eslint has languageOptions.parserOptions.isolatedDeclarations: true for that purpose.
https://github.com/typescript-eslint/typescript-eslint/pull/11351/files#diff-7ca46a3da27e8ad890168dc27f592c83d7f9e12334428396e11b8ca2a6a850adR52-R56

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! That option actually seems to work and we don't have to disable this rule

@sapphi-red sapphi-red added the p1-chore Doesn't change code behavior (priority) label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p1-chore Doesn't change code behavior (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants