Property 'xxx' does not exist
Object is possibly 'null'
Argument of type 'xxx' is not assignable to parameter of type 'yyy'
defineProps
, defineEmits
, useStore
)Property 'xxx' does not exist
// ❌ props に型を書いてない
const props = defineProps();
// props.step が存在しないと言われる
const step = props.step;
✅ 解決:必ず型を書く!
const props = defineProps<{ step?: number }>();
const step = props.step ?? 1;
Object is possibly 'null'
const myInput = ref<HTMLInputElement | null>(null);
// ❌ エラー: Object is possibly 'null'
myInput.value.focus();
✅ 解決:オプショナルチェーン (?.
) を使う
myInput.value?.focus(); // ✅
または、確実に存在する場面なら !
で断言:
myInput.value!.focus(); // ✅(ただし慎重に)
Argument of type 'xxx' is not assignable to parameter of type 'yyy'