Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36,751 Commits
36,751 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Operator Overloading + Implicit this TypeScript Fork

Installation

npm install -D typescript@npm:@operated/typescript

And for VS Code:

  • Ctrl/⌘+Shift+P
  • Open Settings
  • Type in Search "tsdk"
  • Put path ./node_modules/typescript/lib/
  • Restart VS Code

Usage

When operators are run on objects, TypeScript checks whether there is a method to call, instead of an operator. In final JS, it would look like an object method was called. (a + b => a.plus(b))

Along with a compiler, "Go To Definition" feature was supported for IDE: click on an operator between the objects to jump to method, that will be invoked.

Operator Method Name
+, += plus
-, -= minus
*, *= times
/, /= div, invDiv*
%, %= rem
^. ^= pow
==, != equals
===, !== exactEquals
a() run

* — invDiv is inverted division, needed when divided type is not an object. For example, 2 / vec2(1, 0) will result in vec2(1, 0).invDiv(2)

Implicit this.

As another feature, this fork supports referencing properties/methods inside class, which is a usual feature in Java/C#/C++/etc. For example:

class Class {
  property1 = 123
  method() {
    property1++
    console.log(property1)
  }
}

Additionally, you can also add these settings to VS Code to highlight references with implicit this:

"editor.semanticTokenColorCustomizations": {
  "enabled": true,
  "rules": {
    "property.local:typescript": { "foreground": "#9cdcfe" },
    "member.local:typescript":   { "foreground": "#dcdcaa" }
  }
}

About

TypeScript fork with operator overloading and implicit this features.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.