javascript – 打字稿中的’void’是什么意思?

前端之家收集整理的这篇文章主要介绍了javascript – 打字稿中的’void’是什么意思?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我遇到了网络,我想知道在Typescript中隐含的是什么?

就像这里一样:

private _handleProjectQuerySuccess(data: IProject[]): void  
{
    data.sort(this._projectSort);

    var pathname = this._$location.path();

    var activeSet = false;
    data.forEach((project: IProject) =>
    {
        project.active = pathname == '/' + project.id;
        activeSet      = activeSet || project.active;

        project.name        = this._$sanitize(project.name);
        project.description = this._$sanitize(project.description);
        project.url         = this._$sce.trustAsUrl(project.url);
        project.readme      = this._$sce.trustAsHtml(project.readme);

        project.title = project.name + (project.fork ? ' (fork)' : ' (repo)');

        this._scope.projects.push(project);

        this._projectMap[project.id] = this._scope.projects[this._scope.projects.length - 1];
    });

    if (!activeSet)
    {
        data[0].active = true;
    }
}

在我们宣布私有之后,我们暗示无效……这是什么意思?

解决方法

这只是一种类型,如下所示:

Void

Perhaps the opposite in some ways to ‘any’ is ‘void’,the absence of having any type at all. You may commonly see this as the return type of functions that do not return a value:

function warnUser(): void {
    alert("This is my warning message");
}
原文链接:https://www.f2er.com/js/159721.html

猜你在找的JavaScript相关文章