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

Bump to v1.0.6, bump vitest, mv {js,ts}config.json #21

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

mbland
Copy link
Owner

@mbland mbland commented Jan 15, 2024

After doing more research, it appears tsconfig.json is more broadly supported by editors and IDEs than jsconfig.json. For example, IntelliJ IDEA/WebStorm won't recognize it unless added to Settings > Editor > File Types > TypeScript.

After switching, the @types/chai dependency actually caused a conflict; somehow the necessary types were found via vitest that weren't before. I also had to add "WebWorker" to "compilerOptions.lib" in tsconfig.json.

Fixed the problems with vitest.config.js and ci/vitest.config.js such that the // @ts-nocheck directive is no longer necessary. Moved a bunch of compiler options from the pnpm typecheck script into tsconfig.json.

Added the rimraf npm to make sure pnpm prepack generates a new types/ directory without stale content.

Bumped vitest to 1.2.0.

Finally, it seems IntelliJ IDEA's JSDoc type checking is stronger than TypeScript and VSCode. Fixed a few JSDoc type parameters to eliminate warnings in IntelliJ as well.

After doing more research, it appears tsconfig.json is more broadly
supported by editors and IDEs than jsconfig.json. For example, IntelliJ
IDEA/WebStorm won't recognize it unless added to Settings > Editor >
File Types > TypeScript.

After switching, the @types/chai dependency actually caused a conflict;
somehow the necessary types were found via vitest that weren't before. I
also had to add "WebWorker" to "compilerOptions.lib" in tsconfig.json.

Fixed the problems with vitest.config.js and ci/vitest.config.js such
that the `// @ts-nocheck` directive is no longer necessary. Moved a
bunch of compiler options from the `pnpm typecheck` script into
tsconfig.json.

Added the `rimraf` npm to make sure `pnpm prepack` generates a new
`types/` directory without stale content.

Bumped vitest to 1.2.0.

Finally, it seems IntelliJ IDEA's JSDoc type checking is stronger than
TypeScript and VSCode. Fixed a few JSDoc type parameters to eliminate
warnings in IntelliJ as well.
@mbland mbland self-assigned this Jan 15, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 7534713478

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 7463204870: 0.0%
Covered Lines: 249
Relevant Lines: 249

💛 - Coveralls

@mbland mbland merged commit af6cbb6 into main Jan 15, 2024
3 checks passed
@mbland mbland deleted the update-type-checking branch January 15, 2024 22:49
mbland added a commit to mbland/test-page-opener that referenced this pull request Jan 16, 2024
Most of this message is copied from:

- mbland/jsdoc-cli-wrapper#21
  mbland/jsdoc-cli-wrapper@e0d287d
- mbland/rollup-plugin-handlebars-precompiler#7
  mbland/rollup-plugin-handlebars-precompiler@eb5b9a8
- mbland/rollup-plugin-handlebars-precompiler#8
  mbland/rollup-plugin-handlebars-precompiler@8b36b2a

After doing more research, it appears tsconfig.json is more broadly
supported by editors and IDEs than jsconfig.json. For example, IntelliJ
IDEA/WebStorm won't recognize it unless added to Settings > Editor >
File Types > TypeScript.

Related changes include:

- Fixed the problems with vitest.config.js and ci/vitest.config.js such
  that the `// @ts-nocheck` directive is no longer necessary. Used
  `...(configDefaults.coverage.exclude || [])` to avoid type errors due
  to configDefaults.coverage.exclude potentially being undefined.

- Moved a bunch of compiler options from the `pnpm typecheck` script
  into tsconfig.json.

- Added the `rimraf` npm to make sure `pnpm prepack` generates a new
  `types/` directory without stale content.

- Added @types/{jsdom,istanbul-lib-coverage} as production dependencies.

- Bumped vitest to 1.2.0.

- Set .eslintrc to disable the no-undefined-types rule by extending
  "plugin:jsdoc/recommended-typescript-flavor-error". This is because
  the Handlebars types in lib/parser.js weren't trivial to replicate,
  and TypeScript finds those types just fine. This was based on advice
  from:

  > ...the config plugin:jsdoc/recommended-typescript-error should
  > disable the jsdoc/no-undefined-types rule because TypeScript itself
  > is responsible for reporting errors about invalid JSDoc types.
  >
  > - gajus/eslint-plugin-jsdoc#888 (comment)

  And:

  > If you are not using TypeScript syntax (your source files are still
  > .js files) but you are using the TypeScript flavor within JSDoc
  > (i.e., the default "typescript" mode in eslint-plugin-jsdoc) and you
  > are perhaps using allowJs and checkJs options of TypeScript's
  > tsconfig.json), you may use:
  >
  > ```json
  > {
  >   "extends": ["plugin:jsdoc/recommended-typescript-flavor"]
  > }
  > ```
  >
  > ...or to report with failing errors instead of mere warnings:
  >
  > ```json
  > {
  >   "extends": ["plugin:jsdoc/recommended-typescript-flavor-error"]
  > }
  > ```
  >
  > - https://github.com/gajus/eslint-plugin-jsdoc#eslintrc

  More background:

  - https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md
  - gajus/eslint-plugin-jsdoc#99
  - gajus/eslint-plugin-jsdoc#1098
  - jsdoc/jsdoc#1537

- At the same time, extending "recommended-typescript-flavor-error"
  required adding the `// eslint-disable-next-line no-unused-vars`
  directive before each set of imports from lib/types.js. (Or adding
  `// eslint-disable-line no-unused-vars` on the same line if possible.)

- Added 'jsdoc-plugin-typescript' to the build to handle the TypeScript
  `import().Type` directives. This ended up pulling in the 'es-abstract'
  module, which blew up the pnpm-lock.yaml file. If I get an itch, I'll
  implement my own plugin one day and replace it.

- Finally, it seems IntelliJ IDEA's JSDoc type checking is stronger than
  TypeScript and VSCode. Fixed a few JSDoc type parameters to eliminate
  warnings in IntelliJ as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants