Skip to content

Commit

Permalink
change modules to ES6; add index.html with type module b00tc4mp#1
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpereiragomez committed Nov 25, 2024
1 parent 613d7e0 commit 1194227
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
14 changes: 14 additions & 0 deletions stuff/ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modules</title>
</head>

<body>
<script type="module" src="./dist/index.js"></script>
</body>

</html>
1 change: 1 addition & 0 deletions stuff/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "![Typescript logo](https://miro.medium.com/v2/resize:fit:1358/0*OJAUWZoGbVq--rNd.png)",
"main": "index.js",

"scripts": {
"build": "tsc",
"build:dev": "tsc -w"
Expand Down
2 changes: 1 addition & 1 deletion stuff/ts/src/classesExample1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import validateHealthAmount from "./validate";
import { validateHealthAmount } from "./validate";

type PlayerKind = "fighter" | "swordman" | "gunman";

Expand Down
4 changes: 4 additions & 0 deletions stuff/ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { sayHello } from "./validate.js";

const sum = (a: number, b: number) => a + b;

const result1 = sum(4, 2);
Expand Down Expand Up @@ -454,3 +456,5 @@ sendNotificationMessage({
phoneNumber: 4322345221,
text: "Helppp",
});

sayHello("Jane");
6 changes: 5 additions & 1 deletion stuff/ts/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ const validateHealthAmount = (amount: number) => {
}
};

export default validateHealthAmount;
function sayHello(name: string): void {
console.log(name);
}

export { validateHealthAmount, sayHello };
6 changes: 3 additions & 3 deletions stuff/ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"moduleDetection": "force" /* Control what method is used to detect module-format JS files. */,

/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
"module": "ES6" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node10" /* Specify how TypeScript looks up a file from a given module specifier. */,
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down Expand Up @@ -105,6 +105,6 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"incstuff/ts/srce": ["src"] /* Files that we want to ts check */,
"exclude": ["**.test.ts"] /* TS will ignore this files*/
"include": ["src/**/*.ts"] /* Files that we want to ts check */,
"exclude": ["**/*.test.ts"] /* TS will ignore this files*/
}

0 comments on commit 1194227

Please sign in to comment.