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)
- Custom resource icons are not used in log panel
- Weird json schema created from struct HOT 1
- Directories named "internal" and files named "internal.w" should apply internal access modifier to their contents HOT 2
- Confusing error message if you try to access an internal enum
- Multiple errors when you extend an internal interface
- Support importing values/constants through `extern` HOT 3
- Inflight code bundles the whole winglang sdk HOT 1
- Add new docs: Wing for application engineers
- Add new docs: Wing for platform engineers
- Add new docs: Tutorial - First wing application
- New section in docs: Cloud fundamentals
- New guide in docs: Creating custom platforms
- Review and reduce the number of links in the navigation menu
- Review the opengraph information for the docs site.
- `json` can be mutated
- `mutJson` can't be mutated
- Unable to define "json structs" with enums HOT 1
- Wing Console doesn't indicate that a container failed to start HOT 1
- Return type inference doesn't work for optionals HOT 1
- interactive learning tutorial doesn't work due to possible change in inflight HOT 1
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.