Created basic files; still incomplete

This commit is contained in:
fkereki
2018-03-24 15:52:52 -03:00
parent c989356391
commit 21289fcd9b
7 changed files with 140 additions and 68 deletions
+11
View File
@@ -0,0 +1,11 @@
[ignore]
[include]
[libs]
[lints]
[options]
[strict]
+11
View File
@@ -0,0 +1,11 @@
[ignore]
[include]
[libs]
[lints]
[options]
[strict]
+1 -1
View File
@@ -26,7 +26,7 @@
"node": true
},
"extends": ["eslint:recommended", "plugin:flowtype/recommended"],
"plugins": ["flowtype"],
"plugins": ["babel", "flowtype"],
"rules": {
"no-console": "off"
}
+2
View File
@@ -1,3 +1,5 @@
// @flow
class ExtDate extends Date {
fullDate() {
const months = [
+3 -7
View File
@@ -24,7 +24,7 @@ class Person {
}
}
pp = new Person("Erika", "Mustermann");
let pp = new Person("Erika", "Mustermann");
console.log(pp); // Person {first: "Erika", last: "Mustermann"}
console.log(pp.initials()); // "EM"
console.log(pp.fullName()); // "Erika Mustermann"
@@ -44,7 +44,7 @@ class Developer extends Person {
}
}
window.dd = new Developer("John", "Doe", "JS");
let dd = new Developer("John", "Doe", "JS");
console.log(dd); // Developer {first: "John", last: "Doe", language: "JS"}
console.log(dd.initials()); // "JD"
console.log(dd.fullName()); // "John Doe, JS dev"
@@ -70,14 +70,11 @@ const countKeysMixin = base =>
}
}
p2m = new PersonWithTwoMixins("Jane", "Roe");
let p2m = new PersonWithTwoMixins("Jane", "Roe");
console.log(p2m);
console.log(p2m.toJson()); // NEW TOJSON {"first":"Jane","last":"Roe"}
console.log(p2m.countKeys()); // 2
class ExtDate extends Date {
fullDate() {
const months = [
@@ -104,7 +101,6 @@ const countKeysMixin = base =>
);
}
static getMonthName(m) {
const months = [
"JAN",
+19
View File
@@ -0,0 +1,19 @@
/* @flow */
/* eslint-disable no-unused-vars */
let flag: number | boolean;
flag = true; // OK
flag = 1; // also OK
flag = "1"; // error: wrong type
let traffic: "red" | "amber" | "green"; // traffic is implicitly string
traffic = "yellow"; // error: not allowed
type numberOrString = number | string;
function addTwo(x: numberOrString, y: numberOrString) {
return x + y;
}
const fs: any = require("fs");
fs.readFile("/somefilename.ext", processData);
+33
View File
@@ -0,0 +1,33 @@
/* @flow */
/* eslint-disable no-unused-vars */
let someFlag: boolean;
let greatTotal: number;
let firstName: string;
function toString(x: number): string {
return String(x);
}
function addTwo(x: number | string, y: number | string) {
return x + y;
}
function showValue(z: mixed): void {
// not returning anything
console.log("Showing... ", z);
}
let numbersList: Array<number>;
numbersList = [22, 9, 60]; // OK
numbersList[1] = "SEP"; // error; cannot assign a string to a number
let anotherList: number[];
let sealedObject: { name: string, age?: number };
sealedObject.name = "Ivan Horvat"; // OK
sealedObject.id = 229; // error: key isn't defined in the data type
sealedObject = { age: 57 }; // error: mandatory field is missing
let unsealedObject = {};
unsealedObject.id = 229; // OK