type/no-generated-empty-object-type
Disallow empty object types generated by type operations.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
No | None |
Applies to: Type information in Vue SFC scripts and templates, for the constructs shown below.
This rule reads type information from your TypeScript project (tsconfig.json), so the configuration sets typeAware: true. typeAware does not turn on opt-in rules by itself.
Bad
Omit drops the only key, so the alias resolves to an empty object type.
<script setup lang="ts">
type Emptied = Omit<{ a: number }, "a">;
</script>
Good
Omit drops a and still leaves b, so the alias is not an empty object type.
<script setup lang="ts">
type Kept = Omit<{ a: number; b: string }, "a">;
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"type/no-generated-empty-object-type": "warn"
},
"typeAware": true
},
});
Then run vp run lint.