AdamC
AdamC

Reputation: 71

typescript error: Property 'log' does not exist on type {...} - Console.log()

I have typescript files that are compiled into JavaScript files which ultimately run within a web application. My ultimate aim is to have timers in these compiled JavaScript files so I can log how long it's taking for blocks of code to execute. In order to do this, I need to learn how to output data to a log file, and this (at its most basic) requires me to have some sort of Console.log('Whatever I want to log') statement in my JavaScript. I'm starting off small and then building off the baby steps.

Since the typescript is compiled into JavaScript, I have to put any logging and timer code into the typescript first so that it will compile to JavaScript.

I tried putting Console.log("...") into the typescript so that it would compile to the JavaScript and ultimately output "..." when the JS code was run. But during compiling, I got an error:

"Property 'log' does not exist on type '{ new (): Console; prototype: Console; }'"

  1. Why is this happening?
  2. What can I do to make sure that any "javascript code" that I have to first write in typescript gets compiled correctly?

Obviously, I'm a complete newbie with any of this but my task remains nonetheless.

Upvotes: 1

Views: 2589

Answers (1)

basarat
basarat

Reputation: 275947

Console.log("...") should be console.log("...") (lowercase c). This is TypeScript helping you preventing a mistake.

Upvotes: 6

Related Questions