@bikky/compiler 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,9 +7,12 @@ type UnionToIntersection<U> =
7
7
  type AllConstraints<Super, Constraints> = UnionToIntersection<Constraints> extends never ? Super : Super & UnionToIntersection<Constraints>;
8
8
 
9
9
  type Class<T> = (new (...args: any[]) => T);
10
+ type ClassStatic<T> = T extends {[name: string]: any} ? Omit<T, "prototype" | "new"> : never;
10
11
  type AbstractClass<T> = Function & { prototype: T };
12
+ type AnyClass<T> = Class<T> | AbstractClass<T>;
11
13
  type ClassObject<T> = T extends (new (...args: any[]) => infer C) ? C : never;
12
- type AbstractClassObject<T> = T extends (Function & { prototype: infer C }) ? C : never;
14
+ type AbstractClassObject<T> = T extends AbstractClass<infer C> ? C : never;
15
+ // type AbstractClassObject<T> = T extends (Function & { prototype: infer C }) ? C : never;
13
16
  type AbstractClassArguments<T> = T extends abstract new (...args: infer A) => any ? A : never;
14
17
  type ClassArguments<T> = T extends (new (...args: infer C) => any) ? C : never;
15
18
 
@@ -17,6 +20,9 @@ type ConstructArguments<T> = T extends (new (...args: infer C) => any) ? C : nev
17
20
  type Prototype<T> = (Function & { prototype: T });
18
21
  type ObjectType<T> = T extends (new (...args: any[]) => infer C) ? C : never;
19
22
 
23
+ declare const _super: any;
24
+ declare const ERROR_INFO: string[];
25
+
20
26
  //Unfortunately Typescript doesn't currently support the following typing (as in the decorator's typing
21
27
  // information will not properly alter typescript's typing information):
22
28
  //First set of params are the ones supplied in the decorator, like: @mixin(common, extra1, extra2);
@@ -24,34 +30,40 @@ declare function mixin<
24
30
  Super extends Object,
25
31
  Extras extends Prototype<any>[]
26
32
  >(common: Prototype<Super>, ...constraints: Extras): (
27
- //Second set of params are the class the decorator is decorating, in this case the mixin.
28
- <
29
- MixinClass extends Function & { prototype: Object },
30
- Mixin extends Prototype<MixinClass>,
31
- ConstructorArgs extends ConstructArguments<Mixin>,
33
+ //Second set of params are the class the decorator is decorating, in this case the mixin.
34
+ <
35
+ MixinClass extends Function & { prototype: Object },
36
+ Mixin extends Prototype<MixinClass>,
37
+ ConstructorArgs extends ConstructArguments<Mixin>,
38
+ >
39
+ (mixin: MixinClass) => MixinClass & {
40
+ //We return a mix function that takes the class that the mixin
41
+ // is to be mixed onto. We want to ensure that the new class
42
+ // fulfills all the requirements listed with the decorator.
43
+ mix: <
44
+ Core extends AllConstraints<Super, GetConstraints<Extras>>
32
45
  >
33
- (mixin: MixinClass) => MixinClass & {
34
- //We return a mix function that takes the class that the mixin
35
- // is to be mixed onto. We want to ensure that the new class
36
- // fulfills all the requirements listed with the decorator.
37
- mix: <
38
- Core extends AllConstraints<Super, GetConstraints<Extras>>
39
- >
40
- (core: Prototype<Core>) =>
41
- //Lastly we return a function that requires the mixin's constructor arguments and returns
42
- // an object which is a combination of the mixin and the provided core class.
43
- (new (...args: ConstructorArgs) => Core & Mixin);
46
+ (core: Prototype<Core>) =>
47
+ //Lastly we return a function that requires the mixin's constructor arguments and returns
48
+ // an object which is a combination of the mixin and the provided core class.
49
+ (new (...args: ConstructorArgs) => Core & Mixin);
44
50
  });
45
51
 
46
52
  //This is the same code as the .mix property added by the decorator above. Since the decorator doesn't properly update
47
53
  // typing information we'll need to continue calling makeMixer manually (for now). This should be removed once typescript's
48
54
  // decorators are updated.
49
55
  declare function makeMixer<
50
- MixinClass extends (new (...args: any[]) => object),
56
+ MixinClass extends (Class<object> & {[name: string]: any}),
51
57
  Mixin extends ClassObject<MixinClass>,
52
58
  ConstructorArgs extends ConstructArguments<MixinClass>,
53
- Super extends Object, Extras extends Prototype<any>[]>
54
- (mixin: MixinClass, common: Prototype<Super>, ...constraints: Extras): (
55
- <Core extends AllConstraints<Super, GetConstraints<Extras>>>(core: { new(...args: any[]): Core } ) =>
56
- (new (...args: ConstructorArgs) => Core & Mixin));
59
+ Ancestor extends Object,
60
+ Extras extends Prototype<any>[],
61
+ >
62
+ (mixin: MixinClass, common: Prototype<Ancestor>, ...constraints: Extras): (
63
+ <ParentObject extends AllConstraints<Ancestor, GetConstraints<Extras>>,
64
+ ParentStatic extends ({[name: string]: any})>(core: Class<ParentObject> & ParentStatic) =>
65
+ ((new (...args: ConstructorArgs) =>
66
+ (ParentObject & Mixin)) & ClassStatic<ParentStatic> & ClassStatic<MixinClass>
67
+ )
68
+ );
57
69
 
@@ -23,7 +23,7 @@ var Crawler;
23
23
  function Crawl(start, callback) {
24
24
  let crawlArray = (array) => {
25
25
  for (let i = 0; i < array.length; i++) {
26
- array[i] = ts.visitEachChild(array[i], crawl, context);
26
+ array[i] = ts.visitNode(array[i], crawl);
27
27
  }
28
28
  array = array.flat(1);
29
29
  return array;
@@ -1,3 +1 @@
1
- import * as ts from "typescript";
2
- export default function (program: ts.Program, pluginOptions: {}): (context: ts.TransformationContext) => (sourceFile: ts.SourceFile) => ts.Node;
3
1
  //# sourceMappingURL=MacroTransformer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MacroTransformer.d.ts","sourceRoot":"","sources":["MacroTransformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAySjC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,aAC7C,GAAG,qBAAqB,kBAEpB,GAAG,UAAU,aAYlC"}
1
+ {"version":3,"file":"MacroTransformer.d.ts","sourceRoot":"","sources":["MacroTransformer.ts"],"names":[],"mappings":""}