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

Improvement to usage docs #223

Open
dmeehan1968 opened this issue Jan 9, 2023 · 2 comments
Open

Improvement to usage docs #223

dmeehan1968 opened this issue Jan 9, 2023 · 2 comments
Labels
help wanted Extra attention is needed pr requested

Comments

@dmeehan1968
Copy link

I found it misleading that the usage docs state that you can call ts-auto-guard on a source file without either specifying --export-all or the requirements for comments to indicate which are exported. It would be clearer for the docs to give the --export-all usage first, then clarify that it can be controlled on a case-by-case basis via comments.

Also, nowhere does it state that the interfaces must be exported. Internal interfaces are a valid use case, but of course the export is required due to the nature of the generated guard implementation. I don't think that can be resolved without inserting the guards into the original source which creates its own issue, so a usage not explicitly stating that only exported interfaces will be processed would be helpful.

@rhys-vdw
Copy link
Owner

Hi there, sorry for the slow reply. Start of the year etc.

It would be clearer for the docs to give the --export-all usage first, then clarify that it can be controlled on a case-by-case basis via comments.

Honestly I'd rather not bring this to the forefront as it's better practice to use the explicit annotation IMO.

Also, nowhere does it state that the interfaces must be exported. Internal interfaces are a valid use case, but of course the export is required due to the nature of the generated guard implementation.

Yes, right now it's only in a comment in the example code. PR welcome.

I don't think that can be resolved without inserting the guards into the original source which creates its own issue, so a usage not explicitly stating that only exported interfaces will be processed would be helpful.

You ought to be adding the guard annotations to the original source, of, if that's not desirable, create a new source file that imports and exports them:

import { Foo } from "./foo";
/** @see {isFoo} ts-auto-guard:type-guard */
export Foo;

An improvement that could be made here is to check every single declaration at document root for the annotation and log a warning/error if it's not exported.

In any case there are surely improvements that could be made to the doc. A PR to prevent confusion in future would be more than welcome.

@rhys-vdw rhys-vdw added help wanted Extra attention is needed pr requested labels Jan 24, 2023
@rhys-vdw
Copy link
Owner

The obvious thing that's missing here is a code snippet for the Person declaration (including export and annotation) in the Usage section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed pr requested
Projects
None yet
Development

No branches or pull requests

2 participants