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

fix(check): compiler options from workspace members #27009

Conversation

nayeemrmn
Copy link
Collaborator

@nayeemrmn nayeemrmn commented Nov 22, 2024

Closes #24504.
Blocked by denoland/deno_config#143.
Blocked by denoland/deno_graph#565.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add needed deno_config APIs, currently using hacks but it works.

Considering the 2.1 release passed, maybe let's spend the time to do this right before merging?

@nayeemrmn
Copy link
Collaborator Author

Yeah this is not for landing yet

@nayeemrmn nayeemrmn marked this pull request as draft November 23, 2024 02:46
@nayeemrmn nayeemrmn added the ci-draft Run the CI on draft PRs. label Nov 26, 2024
@nayeemrmn nayeemrmn changed the title feat(check): compiler options from workspace members fix(check): compiler options from workspace members Nov 27, 2024
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for deno test and deno bench?

cli/tools/check.rs Outdated Show resolved Hide resolved
cli/tools/check.rs Outdated Show resolved Hide resolved
cli/tools/check.rs Outdated Show resolved Hide resolved
@bartlomieju bartlomieju removed this from the 2.2.0 milestone Dec 3, 2024
@nayeemrmn nayeemrmn requested a review from dsherret January 20, 2025 20:38
Comment on lines +52 to +54
# TODO(nayeemrmn): Use proper version when https://github.com/denoland/deno_graph/pull/565 lands!
[patch.crates-io]
deno_graph = { git = "https://github.com/denoland/deno_graph.git", rev = "70ca7ebbb7fe9bb6cf35115ef9531aa58aadec55" }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To address before landing

Comment on lines +1255 to +1278
impl CliFactoryWithWorkspaceFiles {
#[allow(clippy::type_complexity)]
pub async fn from_flags(
flags: Arc<Flags>,
get_dirs_with_files: impl FnOnce(
&CliOptions,
) -> Result<
Vec<(Arc<WorkspaceDirectory>, FilePatterns)>,
AnyError,
>,
collect_specifiers: impl Fn(
FilePatterns,
Arc<CliOptions>,
Arc<CliFileFetcher>,
) -> std::pin::Pin<
Box<
dyn Future<
Output = Result<Vec<(ModuleSpecifier, SpecifierInfo)>, AnyError>,
>,
>,
>,
extract_doc_files: Option<fn(File) -> Result<Vec<File>, AnyError>>,
watcher_communicator: Option<&Arc<WatcherCommunicator>>,
) -> Result<Self, AnyError> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API serves to hide the currently unintuitive setup sequence of creating a CliOptions, using that get a list of member dirs, patching the CliOptions with them and creating a CliFactory from that. I think it nicely shows what logic is and isn't shared between subcommands at the moment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't get why all these changes are necessary. I'm going to take a look more at the code locally so I can understand what's going on and why this PR isn't just a change in TypeChecker. I made a pretty big change to how deno resolution gets created in #27766, so don't worry about merging that PR. I can handle the conflicts in either that PR or this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a tangled relationship between interpreting the file arguments and factory creation (use file arguments to understand what config scopes to initialise the factory with, and then use the factory to expand them into specifiers). So I wanted a struct that jointly creates and stores these.

I also refactored the test and bench specifier collection so they could be deduped here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I investigated this and I think we don't need to make such foundational changes to do this change. I'm going to open a separate PR that builds off this one so we can discuss further. I think we can make this quite targeted to only TypeChecker.

Copy link
Member

@dsherret dsherret Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we have different behaviour when using a --config flag? Shouldn't it be the same because it discovers the workspace regardless?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the behaviour so that if you pass -c it will only find that config file (and its root if it's not a root itself) and treat everything like it's in that scope.

For example if you have deno.json, member_a/deno.json and member_b/deno.json but you pass -c member_a/deno.json, all files will use { root: "deno.json", member: "member_a/deno.json"}`.

I might have broke this since the last review since there's more reliance on start_dir...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should do that because it differs from other behaviour. In other parts of the CLI it will have the same behaviour no matter which config file in a workspace you provide.

@@ -0,0 +1,8 @@
// We shouldn't get diagnostics from this import under this check scope.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the LSP, we actually do want to see diagnostics under different scopes because they might contribute to errors seen in the current scope. I've updated the next PR to handle this and group/display the diagnostics by config.

@nayeemrmn
Copy link
Collaborator Author

Continuing in #27785.

@nayeemrmn nayeemrmn closed this Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-draft Run the CI on draft PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support compilerOptions in workspace members
3 participants