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

[RFC] feature(transformer): Conditional typing #318

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

martinjlowm
Copy link
Contributor

@martinjlowm martinjlowm commented May 10, 2020

edit: After a recent (write-up) discussion (see https://www.notion.so/RFC-Overload-c5a832ca51654f58a5019bf5507013a7), this PR is on hold. It'll add too much complexity in its current state and the project is not ready for such big changes. Feel free to leave a comment here if you have ideas or proposals for how we can approach this.


edit: Moved this PR into draft. It's blocked by a solution to the issue discussed in #313 on how to pass around mock and function identities.

This PR is based on the work done in #303 and #313 and will emit conditional code (from the test) as follows.

ɵRepository.ɵRepository.instance.registerFactory("@TypeName_1", function (t) { return (function () {
    var __0 = (function () {
        var generic = t.find(function (generic) {
            return generic.i.indexOf("@TypeName_1T") >= 0;
        });
        if (generic) {
            return generic.w();
        }
        return null;
    })();
    if (typeof __0 === "string")
        return "string";
    else if (typeof __0 === "number")
        return "number";
    else if (typeof __0 === "boolean")
        return "boolean";
    else if (typeof __0 === "undefined")
        return "undefined";
    else if ((__0 && __0.__ident) === "AA==")
        return "function";
    else if ((__0 && __0.__ident) === "SQ==")
        return "function";
    else if ((__0 && __0.__ident) === "XA==")
        return "function";
    else
        return "object";
})(); });

This is based on the test case on the unsupported types page. Thorough tests are to be added.

@martinjlowm martinjlowm changed the title feature(transformer): Conditional typing [WIP] feature(transformer): Conditional typing May 16, 2020
@martinjlowm martinjlowm marked this pull request as draft May 17, 2020 19:41
… and utilize TypeScript's MethodSignature type
…entifier of a BindingName

E.g.:

```
const [[[[[var]]]]] = ...
```
…yMap and add a comment to why we can do that
@martinjlowm martinjlowm changed the title feature(transformer): Conditional typing [RFC] feature(transformer): Conditional typing May 28, 2020
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