-
Notifications
You must be signed in to change notification settings - Fork 207
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
export external types as modules #4560
Comments
For reference, the |
For the record, we were asked to take steps to not compound the problem until there is a solution. AIUI, "not compounding the problem" means something like not adding more type declarations in Is that a correct summary? |
I believe @warner just went through the steps for the SwingSet package of doing a hybrid model. You can still have a You may be able to have the file declaring exported types still |
I run into this again and again. Most recent was having to run CI a couple extra times due to missed type "errors" from packages that were inspecting their dependencies and coming up with different answers due to #4620. With the technique in #5972 I think this will be a day of work and should be scheduled. I've marked it for MN 1.1. |
Running into this,
|
With #6369 landed, we are no longer I hope we still do that so I propose retitling this ticket. WDYT @kriskowal ? |
Whatever works for you. Technically, making a new issue might be better for training our estimator, but I’m all for saving time by reusing a ticket. |
Since we're using a new way of estimating, I'll repurpose. |
refs: #4560 ## Description Exports ERTP types from the package entrypoint. Establishes a pattern for constant enums so the type name matches. Review by commit ### Security Considerations none ### Scaling Considerations none ### Documentation Considerations none ### Testing Considerations ### Upgrade Considerations
At time of writing, we need to use
--maxNodeModulesJsDepth
intsc
commands forlint:types
scripts in most Agoric SDK packages because most of our packages do not provide type definitions and do use ambient types expressed in JSDoc comments.The worst outcome of this is that tools like IDE LSP plugins for tsc can’t see the necessary command line flag, and that flag cannot be expressed in project files like
jsconfig.json
. Consequently, type checking may pass in CI but appear to be failing in IDE’s. Lesser bad outcomes include slow type checking performance. One small upside is that we don’t have to use a build step to keep exported type definitions in sync with the JavaScript code.To eliminate this problem we will need to both migrate away from ambient types and add a build step to generate type definitions to most projects. Packages that do not have internally coherent types will need manually written type definitions.
Migrating away from ambient types involves adding
export {}
to anytypes.js
orexported.js
files that only contain JSDoc comments, and then replacingimport 'types.js'
invocations with use of/** @type {import('./types.js').T} */
style references for individual imported types.It’s also necessary to replace the convention of
exported.js
with an entry in the main module of each package like:Such that
/* @type {import('dep').T */
can be used to refer to all the types exported by packagedep
.Migrating away from ambient types is a breaking change and requires conventional commit ceremony:
That covers ambient types. Then, to remove
--maxNodeModulesJsDepth
, you will need to arrange a differenttsc --build
command with"noEmit": false
in ajsconfig.build.json
and TODO👉 the necessary incantations to put type definition files in the right places 👈TODO and add that build step to the"build"
script inpackage.json
TODO according to conventions yet to be established TODO.The text was updated successfully, but these errors were encountered: