Skip to content

Comments

fix: resolve TypeScript errors in Vite config#515

Merged
jdhoffa merged 6 commits intomainfrom
fix_ts_errors_in_vite_config
Nov 5, 2025
Merged

fix: resolve TypeScript errors in Vite config#515
jdhoffa merged 6 commits intomainfrom
fix_ts_errors_in_vite_config

Conversation

@jdhoffa
Copy link
Collaborator

@jdhoffa jdhoffa commented Nov 5, 2025

This PR resolves outstanding TypeScript errors in the vite.config.ts file that were first identified in #514.

  • Import PluginContext from 'rollup' instead of 'vite'
  • Add type assertions for plugin configuration literals
  • Convert schema serving logic into a dedicated Vite plugin
  • Fix isClean type conversion in git info fallback

Technical details:

  • Move middleware from configureServer to a dedicated plugin for better type safety
  • Use 'as const' assertions for plugin enforce and apply properties
  • Properly handle boolean conversion for VITE_GIT_CLEAN environment variable
  • Maintain existing schema serving functionality while improving type safety

Relates to #514

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Expected version change and release notes:

1.5.0-dev.17 (v1.5.0-dev.16...fix_ts_errors_in_vite_config ) (2025-11-05T12:56 UTC)

Fixes

  • resolve TypeScript errors in Vite config (78f7ac7)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Vite configuration to improve type safety and code organization. The main changes involve extracting the schema serving middleware into a dedicated plugin function and correcting type imports and annotations.

  • Improved type safety by importing PluginContext from Rollup instead of Vite
  • Fixed type inconsistency in the isClean property from string to boolean
  • Refactored schema serving middleware into a dedicated plugin function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (!relPath) return next(); // no file requested, let Vite handle
const absPath = resolve(baseDir, relPath);
// prevent path traversal
if (!absPath.startsWith(baseDir)) return next();
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The path traversal check using startsWith() is vulnerable on Windows due to case-insensitive paths. An attacker could bypass this check with paths like SRC/SCHEMA/../../etc/passwd. Use path.relative() and check if the result starts with .. for a more robust solution: if (path.relative(baseDir, absPath).startsWith('..')) return next();

Copilot uses AI. Check for mistakes.
// Create a new plugin for serving schema files
function schemaServePlugin(): Plugin {
return {
name: "schema-serve",
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

[nitpick] The plugin name uses single quotes while the rest of the file consistently uses double quotes for strings. Change to \"schema-serve\" for consistency with the codebase style.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net

AlexAxthelm
AlexAxthelm previously approved these changes Nov 5, 2025
Copy link
Collaborator

@AlexAxthelm AlexAxthelm left a comment

Choose a reason for hiding this comment

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

Some open questions, but when testing locally, I don't see any errors coming from the vite config.

Co-authored-by: Alex Axthelm <alex@alexaxthelm.com>
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net

@jdhoffa jdhoffa requested a review from AlexAxthelm November 5, 2025 13:00
@jdhoffa jdhoffa merged commit abae3b1 into main Nov 5, 2025
10 checks passed
@jdhoffa jdhoffa deleted the fix_ts_errors_in_vite_config branch November 5, 2025 13:38
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.

2 participants