Skip to content

Ensure paths-based resolution does not generate module specifiers with .. in the middle #53957

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

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

andrewbranch
Copy link
Member

Fixes #53369

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Apr 21, 2023
@andrewbranch andrewbranch merged commit 818c980 into microsoft:main Apr 21, 2023
@andrewbranch andrewbranch deleted the bug/53369 branch April 21, 2023 22:04
lewisl9029 added a commit to lewisl9029/highlight that referenced this pull request May 5, 2023
Contains fix for auto imports containing ..

microsoft/TypeScript#53957
Vadman97 pushed a commit to highlight/highlight that referenced this pull request May 5, 2023
## Summary

<!--
Ideally, there is an attached GitHub issue that will describe the "why".

If relevant, use this section to call out any additional information
you'd like to _highlight_ to the reviewer.
-->

I noticed that import specifiers of the form `@/../../packages/ui/src`
were sneaking into the code and breaking Reflame deploys. I figured
nobody in their right mind would manually write an import statement like
this, so it must be coming from auto import. Was able to verify this:

<img width="781" alt="Screenshot 2023-05-05 at 9 09 13 AM"
src="https://user-images.githubusercontent.com/6934200/236518523-e8c4344d-3bf3-4f8e-85a3-c06dd760f7f3.png">

We already had the `non-relative` import specifier setting in our VSCode
config, so this shouldn't be happening. Turns out this was a Typescript
bug that was very recently fixed in
microsoft/TypeScript#53957

I took this chance to upgrade us to the latest typescript 5.1.0-dev
build that included this change (5.1.0-beta didn't include this
unfortunately), and configure VSCode to use this build instead of its
built in version, which fixed the issue:

<img width="753" alt="Screenshot 2023-05-05 at 9 08 36 AM"
src="https://user-images.githubusercontent.com/6934200/236519308-d442e03a-6fb4-4386-b00a-d03e40599b0f.png">

A few other new errors showed up after the upgrade as well, so I added
some quick workarounds for them too.

Note that this only upgrades us to 5.1.0 in the frontend package and
project root (version used by vscode). The rest are still left as is to
minimize scope. This might result in errors that show up in VSCode but
not in `yarn tsc` or vice versa. Though this was already the case
previously since the latest built-in Typescript version was 5.0.4, and
all of our packages were on 4.x.x.

We should look into converging every package onto a single typescript
version going forward.

## How did you test this change?

Tried to auto import `Box`, resulted in `@highlight-run/ui` as the top
suggestion.

Ran `yarn tsc` in frontend. No errors remaining.

<!--
Frontend - Leave a screencast or a screenshot to visually describe the
changes.
-->

## Are there any deployment considerations?

<!--
 Backend - Do we need to consider migrations or backfilling data?
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-import suggestions prioritize aliased relative paths over package imports
3 participants