-
Notifications
You must be signed in to change notification settings - Fork 1
prototype: annotate-twoslash #1
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
base: main
Are you sure you want to change the base?
prototype: annotate-twoslash #1
Conversation
| yarn workspace anno-type-test annotate:twoslash:examples \!\! | ||
| ``` | ||
|
|
||
| > **Note**: Interactive shells often require escaping each `\!` in a command line input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additions:
-
To run
annotate-twoslashcommands with a specifiedworkspace:# Resolving paths ahead of time is the current design choice. # This ensures that platform specificity is in tact without additional dependencies. yarn workspace anno-type-test annotate-twoslash -al -o=output/temp $(realpath test/sources/examples/*.[tj]s)
Note: Wildcards are handled by the interactive shell or by the package manager for package scripts, while the workspace package names and paths are always handled by the package manager itself.
-
To run
annotate-twoslashcommands with package-root-relative paths:# … yarn annotate-twoslash -al -o=test/output/temp test/sources/examples/*.[tj]s
Note: Bare paths are always resolved relative to the package root and will throw if this cannot be resolved.
-
To run
annotate-twoslashcommands with working-directory-relative paths:# … yarn annotate-twoslash -al -o=../output/temp ./examples/*.[tj]s
Note: Interactive shells commonly retain the
.or..in a command line input.
A section on path resolution would outline the design choices and clarify how they are intended to mitigate ambiguities with some practical use cases.
Based on what was encountered so far the following seems like a good starting point which can be revised down the road with enough testing in feedback:
- An implicit or explicit
root-pathis used to simplify the resolution semantics with the following rules:- any bare-specifier is expected to be package-root-relative.
- any relative-specifier is expected to be working-directory-relative.
- any absolute-specifier is expected to be nested relative to an implicit or explicit
--root-path.
- An implicit
root-pathwill default to:- the resolved package-root for a given bare-specifier or package-scoped-absolute-specifier.
- the specifier-relative-root for a given relative-specifier.
- the parent-directory for a non-package-scoped-absolute-specifier.
- The package-root is always resolved once for each unique specifier using the
require.resolveirrespective of package-scope.Note: Edge cases where the
createRequire(packageRoot).resolveresolution is overridden are firmly out of scope. At this point, this is neither checked for nor restricted intentionally, however the normal path checking rules may still reject some paths without guarantees.
Those would then clarify what changes need to take place to iron out the obscurities in the implementation to make it stable enough to use.
This is a prototype of the twoslash-inspired type-checking solution.
Tasks:
Considerations:
ava) for tests.typescriptversions.satisfiesoperator).Motivation: