Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsconfig: Use "solution" tsconfig for more correct type checking #27

Merged
merged 4 commits into from
Feb 24, 2024

Commits on Feb 24, 2024

  1. package.json: Reorder

    philbates35 committed Feb 24, 2024
    Configuration menu
    Copy the full SHA
    dc57445 View commit details
    Browse the repository at this point in the history
  2. Vitest: Use jsdom environment

    As we're building a web app it makes sense to use jsdom environment
    instead of the default node environment, so that we can do things
    such as demonstrated in the test that was added (taken from
    https://vitest.dev/config/#environment), which currently isn't possible.
    philbates35 committed Feb 24, 2024
    Configuration menu
    Copy the full SHA
    34f0039 View commit details
    Browse the repository at this point in the history
  3. TS: Install @types/jsdom and @types/node

    Add a test proving that jsdom types are working as expected, the
    node types will be used in a later commit.
    philbates35 committed Feb 24, 2024
    Configuration menu
    Copy the full SHA
    f455d31 View commit details
    Browse the repository at this point in the history
  4. tsconfig: Use "solution" tsconfig for more correct type checking

    The change in 2aa6462 is resulting in a vite.config.js and
    vite.config.d.ts being generated which we don't want. To fix this,
    lets do the "solution" tsconfig approach as used by the create-vue
    project. This results in things like the following, all of which
    aren't enforced currently:
    
    * tsc allows "process.cwd()" in vite.config.ts and sum.test.ts
      but not in any src files such as app.ts
    * tsc allows document.createElement() in src files such as app.ts
      and in sum.test.ts (because jsdom exists there) but not in
      vite.config.ts which is just pure node environment.
    * Can't import test files into src files
    * Allows using new features such as "".replaceAll() in vite.config.ts
      which should be allowed because we're using node 20.
    
    See:
    * vitejs/vite#15913 (comment)
    * https://github.com/vuejs/create-vue/blob/12bf2889b9ca981bcfed894a7c24fa9db5e7bad5/template/tsconfig/base/tsconfig.app.json
    * https://github.com/vuejs/create-vue/blob/12bf2889b9ca981bcfed894a7c24fa9db5e7bad5/template/tsconfig/base/tsconfig.node.json
    * https://github.com/vuejs/create-vue/blob/12bf2889b9ca981bcfed894a7c24fa9db5e7bad5/template/tsconfig/vitest/tsconfig.vitest.json
    philbates35 committed Feb 24, 2024
    Configuration menu
    Copy the full SHA
    9f4f7b4 View commit details
    Browse the repository at this point in the history