@bryanchu10/create-template-ts 1.1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ shellEmulator: true
2
+
3
+ allowBuilds:
4
+ esbuild: true
@@ -0,0 +1,20 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { greet } from "./index";
3
+
4
+ describe("greet", () => {
5
+ it("defaults to English", () => {
6
+ expect(greet()).toBe("Hello, World!");
7
+ });
8
+
9
+ it("greets in English", () => {
10
+ expect(greet("en")).toBe("Hello, World!");
11
+ });
12
+
13
+ it("greets in Chinese", () => {
14
+ expect(greet("zh")).toBe("你好,世界!");
15
+ });
16
+
17
+ it("greets in Japanese", () => {
18
+ expect(greet("ja")).toBe("こんにちは、世界!");
19
+ });
20
+ });
@@ -0,0 +1,19 @@
1
+ import { ok } from "neverthrow";
2
+ import { match } from "ts-pattern";
3
+
4
+ type Language = "en" | "zh" | "ja";
5
+
6
+ function buildGreeting(language: Language) {
7
+ return match(language)
8
+ .with("en", () => ok("Hello, World!"))
9
+ .with("zh", () => ok("你好,世界!"))
10
+ .with("ja", () => ok("こんにちは、世界!"))
11
+ .exhaustive();
12
+ }
13
+
14
+ export function greet(language: Language = "en"): string {
15
+ return buildGreeting(language).match(
16
+ msg => msg,
17
+ () => "Hello, World!",
18
+ );
19
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "paths": {
4
+ "@/*": ["./src/*"]
5
+ },
6
+ "declaration": true,
7
+ "isolatedDeclarations": true
8
+ },
9
+ "include": ["src"]
10
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm"],
6
+ dts: true,
7
+ outExtensions: () => ({ js: ".js", dts: ".d.ts" }),
8
+ });
@@ -1,2 +1,4 @@
1
1
  node_modules
2
- dist
2
+ dist
3
+
4
+ .DS_store
@@ -30,6 +30,7 @@ export default antfu(
30
30
  newIsCap: true,
31
31
  properties: true,
32
32
  }],
33
+ "no-shadow": "error",
33
34
  },
34
35
  },
35
36
  {
@@ -4,5 +4,6 @@
4
4
  "@/*": ["./src/*"]
5
5
  },
6
6
  "types": ["node"]
7
- }
7
+ },
8
+ "include": ["src"]
8
9
  }