1

新しい Deno プロジェクトを開始しましたが、エラーが発生しました

const users = [
  { name: 'Oby', age: 12 },
  { name: 'Heera', age: 32 },
];

const loggedInUser = users.find((u) => u.name === 'Oby');
console.log(loggedInUser.age);
$ deno run hello.ts
Compile file:///Users/yangshun/Downloads/deno-test/hello.ts
error: TS2532 [ERROR]: Object is possibly 'undefined'.
console.log(loggedInUser.age);

"strictNullChecks": trueこれは、TypeScript 構成が原因です。したがって、独自の (TypeScript 構成) を使用したいのtsconfig.jsonですが、その方法がわかりません。

4

1 に答える 1