I'm working on a simple TypeScript program that looks like this -
const users = [{ name: "Ahmed" }, { name: "Gemma" }, { name: "Jon" }];
// We're trying to find a user named "jon".
const jon = users.find(u => u.name === "jon");
However, when I try to compile the program, I encounter the following error -
p2@6190:~/projects/typescript$ tsc functions.ts
functions.ts:4:19 - error TS2339: Property 'find' does not exist on type '{ name: string; }[]'.
4 const jon = users.find(u => u.name === "jon");
~~~~
Found 1 error.
Despite the error, I can still see the output file being generated as functions.js.
var users = [{ name: "Ahmed" }, { name: "Gemma" }, { name: "Jon" }];
// We're going to look to see if we can find a user named "jon".
var jon = users.find(function (u) { return u.name === "jon"; });
From a JavaScript perspective, this seems like correct code.
Shouldn't TypeScript wait to generate the output until all errors are fixed?