Skip to content

Instantly share code, notes, and snippets.

View sudomaxime's full-sized avatar

Maxime Nadeau sudomaxime

View GitHub Profile
import GoodBoyEvaluator from "./GoodBoyEvaluator";
class Dog {
private gotCookie: boolean;
public name: string;
constructor (name) {
this.name = name;
}
interface AnimalCompare {
isDog (): boolean
}
class Cat implements AnimalCompare {...};
class Dog implements AnimalCompare {...};
const animals = [
new Cat,
new Dog,
import express, { Request, Response } from "express";
const app = express();
interface Request {
isDogRequest: boolean
}
app.use("/dogs", (req: Request, res: Response, next) => {
req.isDogRequest = true; // <-- does not cause an error
next();
interface Point { x: number; }
interface Point { y: number; }
const point: Point = { x: 1, y: 2 };
// Great to express "something" in your app.
type Point = {
x: number
y: number
}
// Great to make your function params easy to understand
function drawPoint (point: Point) {
// do stuff
}
class Dog {
isDog () {
return true;
}
}
// This is fine
var dog: Dog;
// This is wrong, Syntax error 'Dog' has already been declared.
var Dog;
type Cat = { name: string, purrVelocity: number };
var Cat = { slideStuffOffTheTable = true };
import * as vegetalLib from "some-weird-vegetal-lib";
let eatable = [
"banana", "apple", "watermelon", "tomato", "carrot",
"cucumber", "lettuce", "kiwi", "orange"
];
function isWidelyAcceptedVegetable (eatable) {
let validLexically = vegetableLib.lexicalCheck(eatable);
let isTomato = vegetableLib.isTomato(eatable);
import * as vegetalLib from "some-weird-vegetal-lib";
let eatables = ["banana", "apple", "watermelon", "tomato", "carrot", "cucumber", "lettuce", "kiwi", "orange"];
function findWidelyAcceptedAsVegetable (eatables) {
return eatables.filter(eatable => vegetableLib.lexicalCheck(eatable) && vegetableLib.debatable(eatable) ? !vegetableLib.isTomato(eatable) : true);
}
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="600" >
<tr>
<td style="background-color: #ffffff;">
<img src="https://sudo-website-production.s3.ca-central-1.amazonaws.com/email-thumbnails/line.jpg" width="500" height="20" alt="alt_text" border="0" style="width: 600px; height: auto; background: white; font-family: sans-serif; font-size: 15px; line-height: 15px; color: white; margin: auto; display: block; text-align: left;" class="g-img">
</td>
</tr>
<!-- Clear Spacer : BEGIN -->
<tr>