What is the main difference between a Compiler and a Transpiler?

They’re essentially the same: take source code and transform it to something else. The difference is that compiler usually produces a directly usable artifact (executable binary of some sort). Example: C (produces binary), C# (produces bytecode). Whereas transpiler produces another form of source code (in another language, for example), which is not directly runnable and … Read more

Compiler vs Interpreter vs Transpiler

Compiler – compiles code to a lower level code. Example: “Developer code” -> “Machine code” PHP -> C Java -> bytecode Transpiler – compiles code to same level of code/abstraction. Example: “Developer code” -> “Another developer code or version” JavaScript ES2015+ -> JavaScript ES5 Interpreter – interprets code, not really in the same class/league/context with … Read more

Maintain src/ folder structure when building to dist/ folder with TypeScript 3

I had a similar problem when initially converting to a TypeScript project. I also set resolveJsonModule: true and the src directory was copied to the output dist directory. The underlying reason is that one of my source files required package.json at the root of the project. Once I removed that, tsc no longer added src … Read more

What is target in tsconfig.json for?

I am quite new to Typescript. What does Target in tsconfig.json signify? target signifies which target of JavaScript should be emitted from the given TypeScript. Examples: target:es5 ()=>null will become function(){return null} as ES5 doesn’t have arrow functions. target:es6 ()=>null will become ()=>null as ES6 has arrow functions. More I also made a quick video … Read more

Extending Error in Javascript with ES6 syntax & Babel

Based on Karel Bílek’s answer, I’d make a small change to the constructor: class ExtendableError extends Error { constructor(message) { super(message); this.name = this.constructor.name; if (typeof Error.captureStackTrace === ‘function’) { Error.captureStackTrace(this, this.constructor); } else { this.stack = (new Error(message)).stack; } } } // now I can extend class MyError extends ExtendableError {} var myerror = … Read more

tech