Skip to content

hbarve1/super-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Super-JS πŸš€

A strict, clean, and efficient superset of JavaScript that enforces ECMA standards with built-in type safety, formatting, linting, and testing capabilities.

License: MIT Node.js Version TypeScript

✨ Features

  • πŸ”’ Type Safety: Static type checking with JavaScript-first approach
  • 🧠 Smart Type Inference: Automatic type inference based on ECMA standard patterns
  • πŸ› οΈ Built-in Tooling: Integrated formatter, linter, and testing framework
  • 🌐 Universal Compilation: Supports both frontend and backend environments
  • ⚑ Zero Configuration: Works out of the box with sensible defaults
  • πŸš€ Fast Compilation: Optimized compilation process for quick development cycles
  • 🎯 JavaScript Version Targeting: Target specific JavaScript versions (ES5 to ES2022)
  • βš›οΈ Native JSX Support: First-class JSX syntax support without external dependencies
  • πŸ”§ Advanced Type System: Conditional types, mapped types, and type guards
  • ⚑ Performance Optimizations: Incremental compilation and parallel processing

πŸš€ Quick Start

Installation

npm install -g superjs

Creating a new project

superjs init my-project
cd my-project

Your first Super.js file

Create a file with the .sjs extension:

// hello.sjs
function greet(name: string): string {
  return `Hello, ${name}!`;
}

const message = greet("World");
console.log(message);

Compiling and running

# Compile the file
superjs build --source hello.sjs

# Run the compiled JavaScript
node hello.js

πŸ“ File Extension

Super.js files use the .sjs extension and support type annotations:

// example.sjs
interface User {
  name: string;
  age: number;
  email?: string; // Optional property
}

class UserAccount {
  constructor(public user: User) {}
  
  updateEmail(newEmail: string): void {
    this.user.email = newEmail;
  }
}

// Type inference
const numbers = [1, 2, 3]; // inferred as number[]
const user = {
  name: "John",
  age: 30
}; // inferred as { name: string, age: number }

🎯 JavaScript Version Targeting

You can target specific JavaScript versions using the --target option:

# Target ES5
superjs build --source file.sjs --target es5

# Target ES2015 (ES6)
superjs build --source file.sjs --target es2015

# Target ES2020
superjs build --source file.sjs --target es2020

# Default (ES2022)
superjs build --source file.sjs

Supported JavaScript versions:

  • es5
  • es2015 (ES6)
  • es2016
  • es2017
  • es2018
  • es2019
  • es2020
  • es2021
  • es2022 (default)

πŸ› οΈ Development Workflow

Development mode with watch

superjs dev

Running tests

superjs test

Formatting code

superjs format

Linting code

superjs lint

πŸ“š Examples

Basic Type Annotations

// hello-world.sjs
const message: string = 'Hello, SuperJS!';
const version: number = 0.1;
const isEnabled: boolean = true;

interface Person {
  name: string;
  age: number;
  email?: string;
}

function greet(person: Person): string {
  return `Hello, ${person.name}! You are ${person.age} years old.`;
}

Classes and Interfaces

// classes.sjs
interface Vehicle {
  brand: string;
  model: string;
  year: number;
  start(): void;
}

class Car implements Vehicle {
  constructor(
    public brand: string,
    public model: string,
    public year: number
  ) {}

  start(): void {
    console.log(`${this.brand} ${this.model} is starting...`);
  }
}

Generics

// generics.sjs
interface Repository<T> {
  find(id: number): T | null;
  save(item: T): void;
  delete(id: number): boolean;
  findAll(): T[];
}

class UserRepository implements Repository<User> {
  private users: User[] = [];

  find(id: number): User | null {
    return this.users.find(user => user.id === id) || null;
  }

  save(user: User): void {
    const existingIndex = this.users.findIndex(u => u.id === user.id);
    if (existingIndex >= 0) {
      this.users[existingIndex] = user;
    } else {
      this.users.push(user);
    }
  }
}

πŸ—οΈ Project Structure

super-js/
β”œβ”€β”€ compiler/          # JavaScript-based compiler implementation
β”œβ”€β”€ docs/             # Documentation site (Docusaurus)
β”œβ”€β”€ examples/         # Example Super.js files
β”œβ”€β”€ llvm/            # LLVM-based compiler implementation
β”œβ”€β”€ prototype/       # TypeScript-based prototype implementation
└── README.md

πŸ“– Documentation

πŸ”§ Development

Prerequisites

  • Node.js >= 14.0.0
  • npm or yarn

Building from source

git clone https://github.com/your-username/super-js.git
cd super-js
npm install
npm run build

Running tests

npm test

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“ž Support

πŸ™ Acknowledgments

  • Built with ❀️ by the Super.js team
  • Inspired by TypeScript and modern JavaScript development practices
  • Thanks to all our contributors and the open-source community

Super-JS - Making JavaScript development safer, faster, and more enjoyable! πŸš€

About

A strict, clean, and efficient superset of JavaScript with built-in type safety.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published