https://github.com/nomadicgopher/typescript_to_javascript
A TS to JS CLI interpreter. Includes features for minification as-well as custom src file path & streaming threshold.
https://github.com/nomadicgopher/typescript_to_javascript
interpreter javascript typescript
Last synced: 12 months ago
JSON representation
A TS to JS CLI interpreter. Includes features for minification as-well as custom src file path & streaming threshold.
- Host: GitHub
- URL: https://github.com/nomadicgopher/typescript_to_javascript
- Owner: nomadicGopher
- License: agpl-3.0
- Created: 2024-12-27T08:28:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-15T05:29:44.000Z (12 months ago)
- Last Synced: 2025-03-15T06:27:03.250Z (12 months ago)
- Topics: interpreter, javascript, typescript
- Language: Go
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## Instructions
1. Download your OS's version of the program from [Releases](https://github.com/nomadicGopher/TypeScript_to_JavaScript/releases).
* **TypeScript_to_JavaScript.exe**: Windows
* **TypeScript_to_JavaScript**: Linux
2. Add a scripts.ts file in the same directory, or remember to set the -file command-line-argument if it is outside the program's directory.
3. Run the program with the following potential flags:
```
-file string
Path to the TypeScript file. (default "scripts.ts")
-minify bool
Minify the JavaScript output.
-stream float64
File streaming minimum threshold in megabytes. (default 2.5)
```
## Sample TypeScript content
```typescript
// Define an interface for a Person
interface Person {
firstName: string;
lastName: string;
age: number;
greet(): string;
}
// Create a class that implements the Person interface
class Student implements Person {
firstName: string;
lastName: string;
age: number;
studentId: number;
constructor(firstName: string, lastName: string, age: number, studentId: number) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.studentId = studentId;
}
// Implement the greet method
greet(): string {
return `Hello, my name is ${this.firstName} ${this.lastName} and I am ${this.age} years old.`;
}
// Additional method to get the student ID
getStudentId(): number {
return this.studentId;
}
}
// Create an instance of the Student class
const student = new Student("John", "Doe", 20, 12345);
// Call the greet method
console.log(student.greet());
// Call the getStudentId method
console.log(`My student ID is ${student.getStudentId()}.`);
```