Search code examples
typescriptjsfiddle

Use of fat arrow functions in JSFiddle with TypeScript


I've had some snippets on JSFiddle for some blog posts using TypeScript, but some of them have stopped working.

Specifically it's when I use the fat arrow notation for function definitions. It have been working before, so maybe I need to set some options on JSFiddle?

Here is a simple example: https://jsfiddle.net/CaveOfCode/3wdme693/1/ With the following snippet:

const fatArrow = () => console.log("fatArrow");
fatArrow();
const functionKeyword = function() { console.log("functionKeyword"); };
functionKeyword();

The fatArrow throws the error.

VM111:2 Uncaught SyntaxError: Unexpected identifier

Solution

  • Their TypeScript integration is broken as you can see on the console

    enter image description here

    Worth contacting them through different channels : http://doc.jsfiddle.net/meta/channels.html

    Your code is correct (as you probably know).