Vite - `declare const` to prevent typescript from flagging defines doesn't actually work
https://vitejs.dev/config/shared-options.html#define advises to "add the type declarations in the env.d.ts or vite-env.d.ts file to get type checks and Intellisense."
the value gets replaced correctly, but typescript still complains
vite.config.js
const web_describe = execSync("git describe --dirty").toString().trim();
const meta_describe = execSync("git -C ./path/to/submodule describe --dirty").toString().trim();
export default defineConfig({
plugins: [vue()],
// ...
define: {
__WEB_GIT_DESCRIBE__: JSON.stringify(web_describe),
__META_GIT_DESCRIBE__: JSON.stringify(meta_describe),
},
});
tsconfig.json - template from tsc, only thing i changed is strictNullChecks
. adding it didn't change anything.
Comments
Post a Comment