编译模板时出错。装饰器不支持函数表达式

问题描述 投票:0回答:1

我已经在我的离子v4应用程序中实现了信号,在调试测试中一切都很完美但是在生产时,在android和ios中,我都会收到错误并停止编译。

ionic cordova build android --prod --release

ionic cordova build ios --prod

在这两种情况下,终端显示相同的错误

ERROR in app/app.module.ts(66,5): Error during template compile of 'AppModule'
Function expressions are not supported in decorators in 'OneSignal'
'OneSignal' references 'ɵ2'
'ɵ2' contains the error at ../@ionic-native/onesignal/ngx/index.js.ts(64,32)
Consider changing the function expression into an exported function.

这是@ ionic-native / onesignal / ngx / index.js.ts中函数的代码

var OneSignal = /** @class */ (function (_super) {
    __extends(OneSignal, _super);
    function OneSignal() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**
         * constants to use in inFocusDisplaying()
         * @hidden
         */
        _this.OSInFocusDisplayOption = {
            None: 0,
            InAppAlert: 1,
            Notification: 2
        };
        return _this;
    }
    OneSignal.prototype.startInit = function (appId, googleProjectNumber) { return cordova(this, "startInit", { "sync": true }, arguments); };
    OneSignal.prototype.handleNotificationReceived = function () { return cordova(this, "handleNotificationReceived", { "observable": true }, arguments); };
    OneSignal.prototype.handleNotificationOpened = function () { return cordova(this, "handleNotificationOpened", { "observable": true }, arguments); };
    OneSignal.prototype.iOSSettings = function (settings) { return cordova(this, "iOSSettings", { "sync": true, "platforms": ["iOS"] }, arguments); };
    OneSignal.prototype.endInit = function () { return cordova(this, "endInit", { "sync": true }, arguments); };
    OneSignal.prototype.promptForPushNotificationsWithUserResponse = function () { return cordova(this, "promptForPushNotificationsWithUserResponse", { "platforms": ["iOS"] }, arguments); };
    OneSignal.prototype.getTags = function () { return cordova(this, "getTags", {}, arguments); };
    OneSignal.prototype.getIds = function () { return cordova(this, "getIds", {}, arguments); };
    OneSignal.prototype.sendTag = function (key, value) { return cordova(this, "sendTag", { "sync": true }, arguments); };
    OneSignal.prototype.sendTags = function (json) { return cordova(this, "sendTags", { "sync": true }, arguments); };
    OneSignal.prototype.deleteTag = function (key) { return cordova(this, "deleteTag", { "sync": true }, arguments); };
    OneSignal.prototype.deleteTags = function (keys) { return cordova(this, "deleteTags", { "sync": true }, arguments); };
    OneSignal.prototype.registerForPushNotifications = function () { return cordova(this, "registerForPushNotifications", { "sync": true }, arguments); };
    OneSignal.prototype.enableVibrate = function (enable) { return cordova(this, "enableVibrate", { "sync": true }, arguments); };
    OneSignal.prototype.enableSound = function (enable) { return cordova(this, "enableSound", { "sync": true }, arguments); };
    OneSignal.prototype.inFocusDisplaying = function (displayOption) { return cordova(this, "inFocusDisplaying", { "sync": true }, arguments); };
    OneSignal.prototype.setSubscription = function (enable) { return cordova(this, "setSubscription", { "sync": true }, arguments); };
    OneSignal.prototype.getPermissionSubscriptionState = function () { return cordova(this, "getPermissionSubscriptionState", {}, arguments); };
    OneSignal.prototype.postNotification = function (notificationObj) { return cordova(this, "postNotification", {}, arguments); };
    OneSignal.prototype.cancelNotification = function (notificationId) { return cordova(this, "cancelNotification", { "sync": true }, arguments); };
    OneSignal.prototype.promptLocation = function () { return cordova(this, "promptLocation", { "sync": true }, arguments); };
    OneSignal.prototype.syncHashedEmail = function (email) { return cordova(this, "syncHashedEmail", { "sync": true }, arguments); };
    OneSignal.prototype.setLogLevel = function (logLevel) { return cordova(this, "setLogLevel", { "sync": true }, arguments); };
    OneSignal.prototype.setLocationShared = function (shared) { return cordova(this, "setLocationShared", { "sync": true }, arguments); };
    OneSignal.prototype.addPermissionObserver = function () { return cordova(this, "addPermissionObserver", { "observable": true }, arguments); };
    OneSignal.prototype.addSubscriptionObserver = function () { return cordova(this, "addSubscriptionObserver", { "observable": true }, arguments); };
    OneSignal.prototype.setEmail = function (email, emailAuthToken) { return cordova(this, "setEmail", {}, arguments); };
    OneSignal.prototype.logoutEmail = function () { return cordova(this, "logoutEmail", {}, arguments); };
    OneSignal.prototype.addEmailSubscriptionObserver = function () { return cordova(this, "addEmailSubscriptionObserver", { "observable": true }, arguments); };
    OneSignal.prototype.clearOneSignalNotifications = function () { return cordova(this, "clearOneSignalNotifications", { "sync": true }, arguments); };
    OneSignal.prototype.setRequiresUserPrivacyConsent = function (required) { return cordova(this, "setRequiresUserPrivacyConsent", {}, arguments); };
    OneSignal.prototype.provideUserConsent = function (granted) { return cordova(this, "provideUserConsent", {}, arguments); };
    OneSignal.prototype.userProvidedPrivacyConsent = function (callback) { return cordova(this, "userProvidedPrivacyConsent", {}, arguments); };
    OneSignal.pluginName = "OneSignal";
    OneSignal.plugin = "onesignal-cordova-plugin";
    OneSignal.pluginRef = "plugins.OneSignal";
    OneSignal.repo = "https://github.com/OneSignal/OneSignal-Cordova-SDK";
    OneSignal.platforms = ["Amazon Fire OS", "Android", "iOS", "Windows"];
    OneSignal = __decorate([
        Injectable()
    ], OneSignal);
    return OneSignal;
}(IonicNativePlugin));

这是我的环境

Ionic:

ionic (Ionic CLI) : 4.10.3 (/usr/local/lib/node_modules/ionic)

Ionic Framework : @ionic/angular 4.0.0
@angular-devkit/build-angular : 0.12.3
@angular-devkit/schematics : 7.2.3
@angular/cli : 7.2.3
@ionic/angular-toolkit : 1.2.2
Capacitor:
capacitor (Capacitor CLI) : 1.0.0-beta.17
@capacitor/core : 1.0.0-beta.11
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : not available
Cordova Plugins : not available
System:
ios-deploy : 1.9.4
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 6.8.0
OS : macOS High Sierra
Xcode : Xcode 10.1 Build version 10B61
angular7 ionic4 onesignal
1个回答
0
投票

我发布了答案,因为我修复了错误。标志--prod最小化并优化了项目,包括提高性能的AoT(Ahead-of-time)。它是AoT导致与OneSignal插件的冲突。解决方案是在没有--prod的情况下进行编译,只使用标志--release。我正在调查是否有可能使用--prod编译除了AoT,但至少现在,这是一个很好的解决方案,另一方面我的应用程序工作得非常快。

© www.soinside.com 2019 - 2024. All rights reserved.