-
Notifications
You must be signed in to change notification settings - Fork 853
Expand file tree
/
Copy pathtypescript.py
More file actions
56 lines (45 loc) · 1.48 KB
/
typescript.py
File metadata and controls
56 lines (45 loc) · 1.48 KB
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
55
56
from talon import Context, actions, settings
ctx = Context()
ctx.matches = r"""
code.language: typescript
code.language: typescriptreact
# Make typescript win over javascript
mode: command
"""
ctx.lists["user.code_type"] = {
"boolean": "boolean",
"integer": "int",
"string": "string",
"null": "null",
"undefined": "undefined",
"number": "number",
"any": "any",
}
@ctx.action_class("user")
class UserActions:
def code_private_function(text: str):
"""Inserts private function declaration"""
result = "private function {}".format(
actions.user.formatted_text(
text, settings.get("user.code_private_function_formatter")
)
)
actions.user.code_insert_function(result, None)
def code_protected_function(text: str):
result = "protected function {}".format(
actions.user.formatted_text(
text, settings.get("user.code_protected_function_formatter")
)
)
actions.user.code_insert_function(result, None)
def code_public_function(text: str):
result = "public function {}".format(
actions.user.formatted_text(
text, settings.get("user.code_public_function_formatter")
)
)
actions.user.code_insert_function(result, None)
def code_insert_type_annotation(type: str):
actions.insert(f": {type}")
def code_insert_return_type(type: str):
actions.insert(f": {type}")