Thanks to visit codestin.com
Credit goes to github.com

Skip to content

good #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed

good #54

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="https://totaltypescript.com"><img src="https://res.cloudinary.com/total-typescript/image/upload/v1662641493/beginners-typescript-tutorial/github_2x_vxqai9.png" alt="beginner typescript tutorial" /></a>
<a href="https://totaltypescript.com/tutorials/beginners-typescript"><img src="https://res.cloudinary.com/total-typescript/image/upload/v1664461034/beginners-typescript-tutorial/github_2x_himnyi.png" alt="beginner typescript tutorial" /></a>

## Quickstart

Expand Down
503 changes: 459 additions & 44 deletions package-lock.json

Large diffs are not rendered by default.

47 changes: 42 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,60 @@
"version": "1.0.0",
"main": "index.js",
"author": "Matt Pocock <[email protected]>",
"license": "GPL",
"license": "GPL-3.0",
"devDependencies": {
"@types/node": "^18.6.5",
"chokidar": "^3.5.3",
"cross-fetch": "^3.1.5",
"typescript": "^4.8.2",
"typescript": "^4.8.3",
"vitest": "^0.21.1"
},
"scripts": {
"exercise": "node scripts/exercise.js",
"e": "npm run exercise",
"e": "yarn run exercise",
"solution": "SOLUTION=true node scripts/exercise.js",
"s": "npm run solution"
"s": "yarn run solution",
"prepare": "node scripts/prepare-stackblitz.js",
"e-01": "yarn exercise 01",
"s-01": "yarn solution 01",
"e-02": "yarn exercise 02",
"s-02": "yarn solution 02",
"e-03": "yarn exercise 03",
"s-03": "yarn solution 03",
"e-04": "yarn exercise 04",
"s-04": "yarn solution 04",
"e-05": "yarn exercise 05",
"s-05": "yarn solution 05",
"e-06": "yarn exercise 06",
"s-06": "yarn solution 06",
"e-07": "yarn exercise 07",
"s-07": "yarn solution 07",
"e-08": "yarn exercise 08",
"s-08": "yarn solution 08",
"e-09": "yarn exercise 09",
"s-09": "yarn solution 09",
"e-10": "yarn exercise 10",
"s-10": "yarn solution 10",
"e-11": "yarn exercise 11",
"s-11": "yarn solution 11",
"e-12": "yarn exercise 12",
"s-12": "yarn solution 12",
"e-13": "yarn exercise 13",
"s-13": "yarn solution 13",
"e-14": "yarn exercise 14",
"s-14": "yarn solution 14",
"e-15": "yarn exercise 15",
"s-15": "yarn solution 15",
"e-16": "yarn exercise 16",
"s-16": "yarn solution 16",
"e-17": "yarn exercise 17",
"s-17": "yarn solution 17",
"e-18": "yarn exercise 18",
"s-18": "yarn solution 18"
},
"dependencies": {
"@types/express": "^4.17.13",
"express": "^4.18.1",
"zod": "^3.17.10"
}
}
}
29 changes: 29 additions & 0 deletions scripts/prepare-stackblitz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require("fs");
const path = require("path");

/**
* Adds a bunch of scripts, like e-01, e-02 to package.json
* so that StackBlitz can run them programmatically via URL
* commands
*/

const packageJsonPath = path.resolve(__dirname, "../package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
const exercises = fs.readdirSync(path.resolve(__dirname, "../src"));
const exerciseFiles = exercises.filter((exercise) =>
exercise.includes(".problem."),
);
const exerciseNames = exerciseFiles.map((exercise) => exercise.split("-")[0]);

const newPackageJson = Object.assign({}, packageJson);

newPackageJson.scripts = {
...packageJson.scripts,
};

exerciseNames.forEach((exercise) => {
newPackageJson.scripts[`e-${exercise}`] = `yarn exercise ${exercise}`;
newPackageJson.scripts[`s-${exercise}`] = `yarn solution ${exercise}`;
});

fs.writeFileSync(packageJsonPath, JSON.stringify(newPackageJson, null, 2));
45 changes: 0 additions & 45 deletions src/08-function-return-type-annotations.solution.2.ts

This file was deleted.

20 changes: 20 additions & 0 deletions src/09-promises.solution.3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interface LukeSkywalker {
name: string;
height: string;
mass: string;
hair_color: string;
skin_color: string;
eye_color: string;
birth_year: string;
gender: string;
}

export const fetchLukeSkywalker = async () => {
const data: LukeSkywalker = await fetch(
"https://swapi.dev/api/people/1"
).then((res) => {
return res.json();
});

return data;
};
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default defineConfig({
include: ["src/**/*.ts"],
setupFiles: ["scripts/setup.ts"],
passWithNoTests: true,
teardownTimeout: 5000,
},
});