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

error TS4060: Return type of exported function has or is using private name #5284

Closed
tommyZZM opened this issue Oct 16, 2015 · 2 comments
Closed

Comments

@tommyZZM
Copy link

namespace game{
    class Stage{
        constructor(canvas:HTMLElement) {

        }
    }

    function checkCanvasVaild(canvas:HTMLElement) {
        return canvas.hasAttribute(HTMLData.id)
    }

    export function startUpAt(canvas:HTMLElement) {
        if (!CentralCore.instance.isStartUp) {
            CentralCore.instance.startUp();
        }

        var id = checkCanvasVaild(canvas);

        if (id) {

        } else {

        }

        return new Stage(canvas);
    }
}

solution

namespace game{
    export interface IStage{

    }

    class Stage implements IStage{
        constructor(canvas:HTMLElement) {

        }
    }

    function checkCanvasVaild(canvas:HTMLElement) {
        return canvas.hasAttribute(HTMLData.id)
    }

    export function startUpAt(canvas:HTMLElement):IStage {
        if (!CentralCore.instance.isStartUp) {
            CentralCore.instance.startUp();
        }

        var id = checkCanvasVaild(canvas);

        if (id) {

        } else {

        }

        var stage:IStage = new Stage(canvas);

        return stage;
    }
}
@tommyZZM tommyZZM reopened this Oct 16, 2015
@tommyZZM tommyZZM changed the title error TS4060: Return type of exported function has or is using private name 'Main' error TS4060: Return type of exported function has or is using private name Oct 16, 2015
@huan
Copy link

huan commented Aug 31, 2017

Why don't you just do an export?

-     class Stage{
+     export class Stage{

@pie6k
Copy link

pie6k commented Mar 1, 2018

Sometimes you want to check against some interface, but you don't want to export interface itself as implementation detail.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants