-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Proof of concept] The ultimate TypeScript setup rework #1975
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 5c5c972. Reverted for the cae a different suggestion with a fix for that script is accepted.
Fixes type errors revealed after enabling useUnknownInCatchVariables
The checkJs TSConfig option will be used instead. (Most of the directives were misplaced anyway.)
In the test file, an aggregating import (import * as commander) was used to allegedly import the default export. That is not the same as actually importing the default export (import commander). Fixing the import revealed the following error: TS1192: Module '".../commander.js/typings/index"' has no default export. The reason is that the default export is not publicly declared because it is deprecated, and so should not be used. The test was therefore unnecessary.
The aggregated import (import * as commander) doesn't deliver all expected functions when "esModuleInterop": true is set in TSConfig, including when set implicitly because "module" is set to "node16" or "nodenext", like is now the case in our TSConfig after the last commit. The new test block covers that.
- Generate typings automatically from JSDoc (npm run build) - Modularize TSConfig: use separate config files - for lib (with typings generation) - for Jest tests (with Jest types, checks are opt-in for now) - for tsd tests - Use project references in root TSConfig (so that only one tsc run is needed) - Remove typescript-checkJS script. Add typecheck, typecheck-jest and typecheck-all instead
Inspired by SvelteKit (https://github.com/sveltejs/kit) Motivation: - the entry points are indeed part of the library source code - simplifies lint:javascript script and files field in package.json - elimintates the need for "rootDir": ".." in TSConfig for lib (there are no more typings emitted for untracked JS files in the root directory, for example config files and files with quick tests/demos)
aweebit
force-pushed
the
feature/typescript-workflow
branch
from
August 17, 2023 08:46
c0e79ae
to
7bb970b
Compare
The original, manually written typings are kept in the repo for now because they still have to be moved to JSDoc which currently differs from them in a lot of places.
aweebit
force-pushed
the
feature/typescript-workflow
branch
from
August 17, 2023 08:54
7bb970b
to
f384ecf
Compare
This was referenced Aug 15, 2023
Closed
This is an interesting refactor, but not something I think we would adopt. If we went all-in on typing then I think it is more likely we would switch to TypeScript implementation. We do certainly have parallel JSDoc and TSDoc, but a benefit is tailoring the two interfaces separately. (Although I wouldn't recommend this in a new program!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Core components of this PR
.d.ts
typings automatically from JSDoc (see TypeScript docs) withnpm run build
lib
, Jest tests and tsd tests)typescript-checkJS
script. Addtypecheck
,typecheck-jest
andtypecheck-all
instead (Jest tests are currently not included intypecheck
)test-typings
script now also includes a typecheckindex.js
andesm.mjs
tolib
where they belong (tolib/exports
, to be precise)@api private
with@package
although unfortunately both mean nothing to TypeScript, more information at On@api
JSDoc tag #1949Why generate
.d.ts
from JSDoc?.d.ts
and JSDoc like currently.d.ts
.d.ts
is required@package
outside Commander is not prevented by TypeScript, but that has little to do with this PR. See #1949 (comment) for detailsTODO
.d.ts
.d.ts
files to `.gitignore? (Svelte does that for example)See also