musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

Consolidate typing syntax / @type #106

Closed iccir closed 8 years ago

iccir commented 8 years ago

@typedef and @struct were originally designed to mimic their C counterparts. However, as we convert more of our source base to --no-implicit-any, the mismatch between C-style and TypeScript-style type annotation is causing confusion. We also lack the ability to declare a function type (#105).

I'd like to switch @typedef and @struct to the following:

@type AnimationCallback = function(completed: BOOL): void;
@type Point = { x: Number, y: Number };
@type FooArray = Array<Foo>;

Which could be extended in the future to allow more complex types:

@type Tuple = [ String, Number, Number ];
@type StringOrNumber = String | Number;

@typedef and @struct would likely be deprecated in favor of the new syntax (this is requires-major if so).

iccir commented 8 years ago

Needs documentation

iccir commented 8 years ago

Documented.