fix: resolve TypeScript errors in Vite config#515
Conversation
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
|
There was a problem hiding this comment.
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
PluginContextfrom Rollup instead of Vite - Fixed type inconsistency in the
isCleanproperty 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(); |
There was a problem hiding this comment.
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();
| // Create a new plugin for serving schema files | ||
| function schemaServePlugin(): Plugin { | ||
| return { | ||
| name: "schema-serve", |
There was a problem hiding this comment.
[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.
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net |
AlexAxthelm
left a comment
There was a problem hiding this comment.
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>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net |
This reverts commit aff4790.
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net |
This reverts commit 00ec6d8.
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-515.westus2.2.azurestaticapps.net |
This PR resolves outstanding TypeScript errors in the
vite.config.tsfile that were first identified in #514.PluginContextfrom'rollup'instead of'vite'isCleantype conversion in git info fallbackTechnical details:
configureServerto a dedicated plugin for better type safetyVITE_GIT_CLEANenvironment variableRelates to #514