Skip to content

Commit 072f214

Browse files
authored
chore: fix type-checks for rolldown-vite and run type check in our ci (#1156)
1 parent a494b03 commit 072f214

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ jobs:
124124
run: pnpm playwright install chromium
125125
- name: run tests
126126
run: pnpm test
127+
- name: types
128+
if: (${{ success() }} || ${{ failure() }})
129+
run: pnpm check:types
127130
- name: archive tests temp directory
128131
if: failure()
129132
shell: bash

packages/vite-plugin-svelte/src/plugins/configure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { buildIdFilter, buildIdParser } from '../utils/id.js';
1414
import { createCompileSvelte } from '../utils/compile.js';
1515

16-
// @ts-expect-error rolldownVersion
16+
// @ts-ignore rolldownVersion
1717
const { version: viteVersion, rolldownVersion } = vite;
1818

1919
/**

packages/vite-plugin-svelte/src/plugins/setup-optimizer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { toESBuildError, toRollupError } from '../utils/error.js';
77
import { safeBase64Hash } from '../utils/hash.js';
88
import { normalize } from '../utils/id.js';
99
import * as vite from 'vite';
10-
// @ts-expect-error not typed on vite
10+
// @ts-ignore not typed on vite
1111
const { rolldownVersion } = vite;
1212

1313
/**
@@ -42,7 +42,7 @@ export function setupOptimizer(api) {
4242
// Currently, a placeholder as more information is needed after Vite config is resolved,
4343
// the added plugins are patched in configResolved below
4444
if (rolldownVersion) {
45-
//@ts-expect-error rolldown types not finished
45+
//@ts-ignore rolldown types not finished
4646
optimizeDeps.rollupOptions = {
4747
plugins: [
4848
placeholderRolldownOptimizerPlugin(optimizeSveltePluginName),

packages/vite-plugin-svelte/src/preprocess.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const {
66
preprocessCSS,
77
resolveConfig,
88
transformWithEsbuild,
9-
//@ts-expect-error rolldown types don't exist
9+
//@ts-ignore rolldown types don't exist
1010
rolldownVersion,
11-
//@ts-expect-error rolldown types don't exist
11+
//@ts-ignore rolldown types don't exist
1212
transformWithOxc
1313
} = vite;
1414
/**
@@ -72,8 +72,10 @@ function viteScript() {
7272
function viteScriptOxc() {
7373
return {
7474
async script({ attributes, content, filename = '' }) {
75-
const lang = /** @type {string} */ (attributes.lang);
76-
if (!supportedScriptLangs.includes(lang)) return;
75+
if (typeof attributes.lang !== 'string' || !supportedScriptLangs.includes(attributes.lang)) {
76+
return;
77+
}
78+
const lang = /** @type {'ts'} */ (attributes.lang);
7779
const { code, map } = await transformWithOxc(content, filename, {
7880
lang,
7981
target: 'esnext'

0 commit comments

Comments
 (0)