Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow resolve global scoped-imports #11

Merged
merged 2 commits into from
Dec 10, 2019
Merged

allow resolve global scoped-imports #11

merged 2 commits into from
Dec 10, 2019

Conversation

lifeart
Copy link
Owner

@lifeart lifeart commented Dec 10, 2019

import TemplateImported_DidInsert from "@ember/render-modifiers/modifiers/did-insert";
import TemplateImported_And from "ember-truth-helpers/helpers/and";



type EachHelper = < T > ([items]: ArrayLike < T > [], hash ? ) => [T, number];
type LetHelper = < A, B, C, D, E > (items: [A, B, C, D, E], hash ? ) => [A, B, C, D, E];
type AbstractHelper = < T > ([items]: T[], hash ? ) => T;
type AbstractBlockHelper = < T > ([items]: ArrayLike < T > [], hash ? ) => [T];
type HashHelper = < T > (items: any[], hash: T) => T;
type ArrayHelper = < T > (items: ArrayLike < T > , hash ? ) => ArrayLike < T > ;
type OnModifer = ([event, handler]: [string, Function], hash ? ) => void;
type FnHelper = < T extends(...args: any) => any > (func: T, params: Parameters < T > ) => Function;


function TIfHeper < T, U, Y > ([a, b, c]: [T, U ? , Y ? ], hash ? ) {
    return !!a ? b : c;
}




interface IKnownScope {
    ["each"]: EachHelper;
    ["let"]: LetHelper;
    ["hash"]: HashHelper;
    ["array"]: ArrayHelper;
    ["if"]: typeof TIfHeper;
    ["on"]: OnModifer;
    ["fn"]: FnHelper;
    ["did-insert"]: TemplateImported_DidInsert;
    ["and"]: TemplateImported_And;
}

interface IGlobalScope {
    [key: string]: AbstractHelper | AbstractBlockHelper
}

type GlobalScope = IGlobalScope & IKnownScope;

import Component from "./../../components/my-component/component";

export default class Template extends Component {

    globalScope: GlobalScope;
    //@mark-meaningful-issues-start

    //@mark [1,0:3,8]
    "1,0:3,8 - BlockStatement"() {
        return this["1,3:1,6 - PathExpression"]([this["1,7:1,28 - SubExpression"]()]); /*@path-mark 1,0:3,8*/
    };

    //@mark [1,3:1,6]
    "1,3:1,6 - PathExpression" < A,
    B,
    C,
    D,
    E > (params: [A, B ? , C ? , D ? , E ? ], hash ? ) {
        return this.globalScope["let"](params as[A, B, C, D, E], hash); /*@path-mark 1,3:1,6*/
    };

    //@mark [1,7:1,28]
    "1,7:1,28 - SubExpression"() {
        return this["1,8:1,12 - PathExpression"]([], {
            foo: this["1,17:1,27 - PathExpression"]()
        }); /*@path-mark 1,7:1,28*/
    };

    //@mark [1,8:1,12]
    "1,8:1,12 - PathExpression" < T > (params = [], hash: T) {
        return this.globalScope["hash"](params, hash); /*@path-mark 1,8:1,12*/
    };

    //@mark [1,17:1,27]
    "1,17:1,27 - PathExpression"() {
        return this.paets; /*@path-mark 1,17:1,27*/
    };

    //@mark [2,4:2,40]
    "2,4:2,40 - MustacheStatement"() {
        return this["2,6:2,38 - PathExpression"](); /*@path-mark 2,4:2,40*/
    };

    //@mark [2,6:2,38]
    "2,6:2,38 - PathExpression"() {
        return this["1,0:3,8 - BlockStatement"]()[0].foo.name.jake.toExponential; /*@path-mark 2,6:2,38*/
    };

    //@mark [4,5:4,28]
    "4,5:4,28 - ElementModifierStatement"() {
        return this["4,7:4,17 - PathExpression"]([this["4,18:4,26 - PathExpression"]()]); /*@path-mark 4,5:4,28*/
    };

    //@mark [4,7:4,17]
    "4,7:4,17 - PathExpression"(params ? , hash ? ) {
        return this.globalScope["did-insert"](params, hash); /*@path-mark 4,7:4,17*/
    };

    //@mark [4,18:4,26]
    "4,18:4,26 - PathExpression"() {
        return this.foo; /*@path-mark 4,18:4,26*/
    };

    //@mark [5,1:5,26]
    "5,1:5,26 - MustacheStatement"() {
        return this["5,3:5,6 - PathExpression"]([this["5,7:5,15 - PathExpression"](), this["5,16:5,24 - PathExpression"]()]); /*@path-mark 5,1:5,26*/
    };

    //@mark [5,3:5,6]
    "5,3:5,6 - PathExpression"(params ? , hash ? ) {
        return this.globalScope["and"](params, hash); /*@path-mark 5,3:5,6*/
    };

    //@mark [5,7:5,15]
    "5,7:5,15 - PathExpression"() {
        return this.foo; /*@path-mark 5,7:5,15*/
    };

    //@mark [5,16:5,24]
    "5,16:5,24 - PathExpression"() {
        return this.bar; /*@path-mark 5,16:5,24*/
    };
}

@lifeart lifeart merged commit 3218ae8 into master Dec 10, 2019
@lifeart lifeart deleted the globals-resolution branch December 11, 2019 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant