Reputation: 53169
I'm starting out on a new Deno project and ran into errors
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);
This is caused by "strictNullChecks": true
in the TypeScript config. Hence I would like to use my own tsconfig.json
(TypeScript configuration) but am not sure how to go about doing so.
Upvotes: 1
Views: 1058
Reputation: 53169
tsconfig.json
file.{
"compilerOptions": {
"strictNullChecks": false
}
}
deno run
with the -c
configuration argument.$ deno run -c tsconfig.json hello.ts
Compile file:///Users/yangshun/Downloads/deno-test/hello.ts
12
Upvotes: 2