-
Notifications
You must be signed in to change notification settings - Fork 133
jsr publish --fix
#15
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
Comments
Why would |
@KnorpelSenf I don't want jsr to mess with my shit by default |
Not necessarily implied by the description, but I too suspect modifying code on-the-fly while publishing might not be a good idea. This could open a can of worms where the code in the repo and the published code start to diverge, if not all modifications are bijective transformations and the published code is ever used as the repo code. Maybe unlikely to occur, but one could imagine some scenario where the published code is used to restore a repo that was somehow deleted or lost. Maintaining this subtle contract might be difficult as TypeScript and JavaScript evolve over the years, as it takes only one non-bijective transformation to break it. I'd prefer if it modified the local copy of the code such that it can be committed to the repo and publish can remain a simple upload of the exact local code. |
So it seems like implementing this in |
If the |
|
Personally, I really want to see some level of inference for untyped variables, without the use of linter or a code-generator. Take the following basic example where
{
"name": "@yabadaba/doo",
"version": "0.1.0",
"exports": "./mod.ts"
}
/** module comment.
*
* @module
*/
/** doc comment of `abcFactory`. */
export const abcFactory = (): string => ("") // <- fully typed
/** doc comment of `xyzClass`. */
export class XyzClass {} // <- fully typed
/** doc comment of `defaultAbc`. */
export const defaultAbc = abcFactory() // <- jsr complains about slow-type, and deno-doc fails to infer, despite being easily inferable
/** doc comment of `defaultAbc`. */
export const defaultXyz = new XyzClass() // <- jsr complains about slow-type, but deno-doc infers correctly Now if I were to publish this via
It will complain that both So now, I'll have to either:
If jsr publishing would permit even a tiny-level of type-inference, many of these inconveniences will fade away. My personal approach for type-inference of untyped exports would have been to collect all untyped exports, run them through the type checker, and for the symbols that could be inferred, store their inferred types in a json-like object (in-memory, so that nothing is generated on the filesystem), then ship it with the package generated for |
I think that we can auto fix the majority of slow types diagnostics (missing return types, and explicit class types) by using TSC inference and then fixing up the source code with the explicit types gotten from TSC.
This is a bit of work, but would make supporting types in your package a matter of
jsr publish --fix
(ordeno lint --fix
). Right now the wall of slow types errors could be a bit daunting.The text was updated successfully, but these errors were encountered: