Skip to content

Commit

Permalink
Add non-new constructors for Number, String & Date
Browse files Browse the repository at this point in the history
This allows typescript code such as:

```typescript
var n = Number("123.45");
```

and similarly for `String(...)` and `Date(...)`
  • Loading branch information
bobrippling committed Jul 21, 2023
1 parent 9a1d5b6 commit 954cff2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/jswrap_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ JsVar *jswrap_date_from_milliseconds(JsVarFloat time) {
"typescript" : [
"new(): Date;",
"new(value: number | string): Date;",
"new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;"
"new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;",
"(arg?: any): string;"
]
}
Creates a date object
Expand Down
6 changes: 5 additions & 1 deletion src/jswrap_number.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ This is the built-in JavaScript class for numbers.
"params" : [
["value","JsVarArray","A single value to be converted to a number"]
],
"return" : ["JsVar","A Number object"]
"return" : ["JsVar","A Number object"],
"typescript" : [
"new(...value: any[]): Number;",
"(value: any): number;"
]
}
Creates a number
*/
Expand Down
6 changes: 5 additions & 1 deletion src/jswrap_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ them.
"params" : [
["str","JsVarArray","A value to turn into a string. If undefined or not supplied, an empty String is created."]
],
"return" : ["JsVar","A String"]
"return" : ["JsVar","A String"],
"typescript" : [
"new(...str: any[]): any;",
"(arg?: any): string;"
]
}
Create a new String
*/
Expand Down

0 comments on commit 954cff2

Please sign in to comment.