-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes script and style tags being wrongfully included in the generate…
…d TSX (#905) * chore: changeset * test: add more tests
- Loading branch information
1 parent
1f78295
commit 708167e
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@astrojs/language-server": patch | ||
"@astrojs/check": patch | ||
"astro-vscode": patch | ||
--- | ||
|
||
Fixes script and style tags being wrongfully included in the generated TSX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FullDocumentDiagnosticReport } from '@volar/language-server'; | ||
import { expect } from 'chai'; | ||
import { type LanguageServer, getLanguageServer } from '../server.js'; | ||
|
||
describe('TypeScript - Diagnostics', async () => { | ||
let languageServer: LanguageServer; | ||
|
||
before(async () => (languageServer = await getLanguageServer())); | ||
|
||
it('treats script tags as modules', async () => { | ||
const document = await languageServer.openFakeDocument( | ||
'<script>import * as path from "node:path";path;const hello = "Hello, Astro!";</script><script>console.log(hello);</script>', | ||
'astro' | ||
); | ||
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( | ||
document.uri | ||
)) as FullDocumentDiagnosticReport; | ||
|
||
expect(diagnostics.items).length(2); | ||
}); | ||
|
||
it('treats inline script tags as not isolated modules', async () => { | ||
const document = await languageServer.openFakeDocument( | ||
'<script is:inline>const hello = "Hello, Astro!";</script><script is:inline>console.log(hello);</script>', | ||
'astro' | ||
); | ||
|
||
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( | ||
document.uri | ||
)) as FullDocumentDiagnosticReport; | ||
|
||
expect(diagnostics.items).length(0); | ||
}); | ||
}); |