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: Fix TypeScript plugin compatibility with TS 5.0 #532

Merged
merged 4 commits into from May 11, 2023
Merged

Conversation

Princesseuh
Copy link
Member

@Princesseuh Princesseuh commented May 10, 2023

Changes

Our plugin was broken in TS 5.0+ due to internal changes to TS. This PR fixes this by using the recommended method for patching language services inside TypeScript plugins and patching the right method for resolving modules

Fix #519

Testing

Tests should pass!

Docs

N/A

@Princesseuh Princesseuh requested a review from a team as a code owner May 10, 2023 17:03
@changeset-bot
Copy link

changeset-bot bot commented May 10, 2023

🦋 Changeset detected

Latest commit: b5bc090

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@astrojs/ts-plugin Patch
astro-vscode Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Princesseuh Princesseuh changed the title fix: proxy language service to fix compatibility with TS 5.0 fix: Fix TypeScript plugin compatibility with TS 5.0 May 10, 2023
@@ -10,19 +10,46 @@ import { decorateGetImplementation } from './implementation.js';
import { decorateLineColumnOffset } from './line-column-offset.js';
import { decorateRename } from './rename.js';

const astroPluginPatchSymbol = Symbol('astroPluginPatchSymbol');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Approved on the spot.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately not my code, copied that part from Svelte's TS plugin, sorry to disappoint

@Princesseuh Princesseuh merged commit ae15420 into main May 11, 2023
4 checks passed
@Princesseuh Princesseuh deleted the fix/ts-plugin branch May 11, 2023 17:44
@space-otter
Copy link

Unfortunately, the error persists. Export and import statments in .ts files don't recognize .astro files.

Cannot find module './Perk.astro' or its corresponding type declarations.

@Princesseuh
Copy link
Member Author

Unfortunately, the error persists. Export and import statments in .ts files don't recognize .astro files.

Cannot find module './Perk.astro' or its corresponding type declarations.

Do you have a project I can look at?

@space-otter
Copy link

Unfortunately, the error persists. Export and import statments in .ts files don't recognize .astro files.

Cannot find module './Perk.astro' or its corresponding type declarations.

Do you have a project I can look at?

For example an actual repo (https://github.com/prismaticweb/mmw-webpage/blob/main/src/components/PerkCollection/index.ts). I tried to install the ts-plugin and add it manually, without the plugin, switching pre-release, etc.

@Princesseuh
Copy link
Member Author

Thank you, I'll take a look!

@Princesseuh
Copy link
Member Author

Found the issue, will send out a fix as soon as possible. The plugin actually does work, I think there's just a packaging error

@space-otter
Copy link

Found the issue, will send out a fix as soon as possible. The plugin actually does work, I think there's just a packaging error

Uh, perfect! Thank you for the quick replay and fix.

@Princesseuh
Copy link
Member Author

This PR should fix the issue: #538. Sorry for the inconvenience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import type from astro file to typescript file
3 participants