Comments (2)
A minimal example showing the current discrepancy will be helpful here (I'm unable to view the code linked in the issue)
from wing.
@Chriscbr added you to the endor.w GitHub Repo.
Here is the code:
//Cannot be imported from TS
pub enum DatetimeFormat {
ISO,
MMYYYY,
YYYYMMDD_HHMM
}
pub class Util {
extern "./lib.js" static pub inflight toUtcString(date: std.Datetime): str;
extern "./lib.js" static pub inflight plus(date: std.Datetime, offset: duration): std.Datetime;
extern "./lib.js" static pub inflight minus(date: std.Datetime, offset: duration): std.Datetime;
extern "./lib.js" static pub inflight format(date: std.Datetime, format: DatetimeFormat): str;
extern "./lib.js" static pub inflight parse(date: str, format: DatetimeFormat): std.Datetime;
extern "./lib.js" static pub inflight formatMMYYYY(date: std.Datetime): str;
extern "./lib.js" static pub inflight parseMMYYYY(sd: str): std.Datetime;
extern "./lib.js" static pub inflight formatYYYYMMDD_HHMM(date: std.Datetime): str;
extern "./lib.js" static pub inflight parseYYYYMMDD_HHMM(sd: str): std.Datetime;
static pub inflight gt(left: std.Datetime, right: std.Datetime): bool {
return left.timestampMs > right.timestampMs;
}
static pub inflight gte(left: std.Datetime, right: std.Datetime): bool {
return left.timestampMs >= right.timestampMs;
}
static pub inflight lt(left: std.Datetime, right: std.Datetime): bool {
return left.timestampMs < right.timestampMs;
}
static pub inflight lte(left: std.Datetime, right: std.Datetime): bool {
return left.timestampMs <= right.timestampMs;
}
}
In TypeScript, I need to do this:
//Wing passes enums as strings, hence need extra validation
export function getParser(format: DatetimeFormat | string): ParseDatetime {
const parser = _parser.get(
typeof format == 'string' ?
DatetimeFormat[format as keyof typeof DatetimeFormat]
: format
);
if (!parser) {
throw new Error(`Parser for format ${format} not found`);
}
return parser;
}
export function parse(dateTime: string, format: DatetimeFormat): std.Datetime {
return getParser(format)(dateTime);
}
export function getFormatter(format: DatetimeFormat | string): FormatDatetime {
const formatter = _formatter.get(
typeof format == 'string' ?
DatetimeFormat[format as keyof typeof DatetimeFormat]
: format
);
if (!formatter) {
throw new Error(Formatter for format ${format} not found
);
}
return formatter;
}
export function format(dateTime: std.Datetime, format: DatetimeFormat): string {
return getFormatter(format)(dateTime);
}
from wing.
Related Issues (20)
- Autocomplete breaks inside nested struct fields within if blocks
- Update docusaurus version to 3.x.x from 2.x.x HOT 1
- Animate node expanding/collapsing transitions
- Change direction connections from parent to child so they go from left to right HOT 2
- Allow filtering the logs by the selected node automatically HOT 3
- Add ability to specify a timeout for `http` methods HOT 3
- `aws.region` API HOT 2
- Improve Console endpoints UI HOT 1
- Console not showing compilation errors HOT 3
- Console allows resource interactions while app is loading
- wing test -t sim stopped working after wing update HOT 1
- cdk8s winglib platfrom error when trying to get root node
- RevitalB Test
- Revital's second test
- Omit connections that start from hidden nodes HOT 1
- Automatically center node when it is expanded
- Console: Test runner fails when running more than one test at a time
- Cleaning `root` and `root/Default` from all user-facing data
- New API section in the docs
- Notify Wing console users a new version of the console is out
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wing.