Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/tsgo-api-file-casing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'svelte-language-server': patch
'svelte-check': patch
---

fix: report Svelte compiler and CSS diagnostics under the file's real path with `--tsgo-experimental-api` on case-insensitive file systems
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ export class SvelteCheckTSGoDiagnosticsProvider implements DiagnosticsProvider {
}

getAllSvelteFiles(): string[] {
return Array.from(this.files.keys()).filter(isSvelteFilePath);
// not the keys, which are lowercase on case-insensitive file systems
return Array.from(this.files.values(), (snapshot) => snapshot.filePath).filter(
isSvelteFilePath
);
}

mapAndFilterDiagnostics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Document } from '../../../../../src/lib/documents';
import ts from 'typescript';
import { getPackageInfo } from '../../../../../src/importPackage';
import assert from 'assert';
import sinon from 'sinon';

const isSvelte5Plus = Number(VERSION.split('.')[0]) >= 5;

Expand Down Expand Up @@ -40,6 +41,32 @@ describe('SvelteCheckTSGoDiagnosticsProvider', function () {
workspaceDir: fixturesDir
});

afterEach(() => sinon.restore());

it('returns Svelte file paths in their original case', async () => {
const syncApi = await import('@typescript/native-preview/unstable/sync');
const tsAst = await import('@typescript/native-preview/unstable/ast');
const tsconfig = path.join(__dirname, '../../testfiles/tsconfig.json');
// The file map lowercases its keys on case-insensitive file systems
sinon.stub(ts.sys, 'useCaseSensitiveFileNames').value(false);
const service = new SvelteCheckTSGoDiagnosticsProvider(
syncApi,
tsAst,
tsconfig,
'svelte2tsx',
(filePath, content) => new Document(pathToUrl(filePath), content)
);
sinon.restore();
try {
await service.getProject();
assert.deepStrictEqual(service.getAllSvelteFiles(), [
normalizePath(path.join(path.dirname(tsconfig), 'Upper.svelte'))
]);
} finally {
service.dispose();
}
});

after(() => {
for (const provider of providerPool.values()) {
provider.dispose();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script lang="ts">
export const value = 1;
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"compilerOptions": { "strict": true, "types": [] }
}