forked from leekib/git-typo-hunter-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.ts
54 lines (47 loc) · 1.3 KB
/
example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Single-line comment: TypeScript example file
/**
* TSDoc style comment block
* This is a simple TypeScript program that
* demonstrate different comment styles
* @packageDocumentation
*/
/*
* Multi-line comment block
* explaining the interface
*/
interface Person {
name: string; // The person's name
}
/**
* Class representing greeter
* @remarks This is an detailed explanation of the Greeter class
*/
class GreeterTypeScript {
/* Block comment:
Private member declaration */
private readonly person: Person; // Using Person interface
/**
* Create an instance of Greeter
* @param name - The name to use in greetings
*/
constructor(name: string) {
// Initialize person object
this.person = { name }; // Object literal assignment
}
/**
* Returns a greeting message
* @returns A string containing the greeting
* @throws Never throws an error
*/
public greet(): string {
// Using string interpolation
return `Hello, ${this.person.name}!`;
}
/*
* TODO: Add localizations support
* FIXME: Add proper errors handling
*/
}
// Create instance and use it
const greeterTypeScript: GreeterTypeScript = new GreeterTypeScript('World');
console.log(greeter.greet()); // Outputs: Hello, World!