打字稿错误';'预期。 “ EventNameString”仅引用类型,但在此处被用作值

时间:2019-12-25 01:38:15

标签: angular typescript firebase ionic-framework

我正在尝试将Firebase电话身份验证添加到旧的ionic项目中,并遵循一些教程。我设法实现它,但是每次执行ionic serve -l时都会出现此错误:

errors screenshot

但是,我注意到在执行app.modules.ts之后,如果在ionic serve -l中注释了其中一行,则错误消失了:

import { AngularFireModule } from "@angular/fire";
import { AngularFireAuth } from "@angular/fire/auth";

由于错误在node-modules文件夹中,因此我尝试多次将其删除,甚至在另一台PC上尝试了该错误,在这里和那里都遵循了一些答案,但我无法解决。

错误文字:

Typescript Error
';' expected.
gtagName?: string;
/** Sets custom name for `dataLayer` array used by gtag. */
dataLayerName?: string;

Typescript Error
'EventNameString' only refers to a type, but is being used as a value here.
/** Sets custom name for `dataLayer` array used by gtag. */
dataLayerName?: string;

Typescript Error
'never' only refers to a type, but is being used as a value here.
/** Sets custom name for `dataLayer` array used by gtag. */
dataLayerName?: string;

Typescript Error
Cannot find name 'T'.
/** Sets custom name for `dataLayer` array used by gtag. */
dataLayerName?: string;

离子信息:

Ionic Framework: ^3.9.8
Ionic App Scripts: 3.2.4
Angular Core: ^5.2.7
Angular Compiler CLI: ^5.2.7
Node: 12.13.1
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36

app.modules.ts导入的依赖项:

import { ErrorHandler, Injectable, Injector, NgModule } from "@angular/core";
import { IonicApp, IonicErrorHandler, IonicModule } from "ionic-angular";
import { BrowserModule } from "@angular/platform-browser";
import { HttpModule } from "@angular/http";
import { HttpClient, HttpClientModule } from "@angular/common/http";

import { Geolocation } from "@ionic-native/geolocation";
import { NativeGeocoder } from "@ionic-native/native-geocoder";

import { MyApp } from "./app.component";
import { TabsPage } from "../pages/tabs/tabs";
import { Loading } from "../pages/loading/loading";
import { Welcome } from "../pages/welcome/welcome";
import { GeoPage } from "../pages/geo/geo";

import { IonicStorageModule } from "@ionic/storage";
import { StatusBar } from "@ionic-native/status-bar";
import { SplashScreen } from "@ionic-native/splash-screen";

import { APIService } from "../services/api_service";
import { CartService } from "../services/cart_service";
import { PushService } from "../services/push_service";
import { UtilService } from "../services/util_service";
import { OrderHistoryService } from "../services/order_history_service";

import { TranslateLoader, TranslateModule } from "@ngx-translate/core";
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
import { RestaurantsPageModule } from "../pages/catalog/restaurants/restaurants.module";
import { GeoPageModule } from "../pages/geo/geo.module";
import { AngularFireModule } from "@angular/fire";
import { AngularFireAuth } from "@angular/fire/auth";
import { firebaseConfig } from "../config";
import { LoginPage } from "../pages/personal/login/login";
import { AuthService } from "../services/auth.service";
import { NgxErrorsModule } from '@ultimate/ngxerrors';

1 个答案:

答案 0 :(得分:0)

最主要的是,当您尝试将类型设置为=时,必须使用:而不是EventNameStringEventNameString。这就是为什么出现错误“ EventNameString”仅引用类型,但在此处将其用作值的原因。

对于其他人,如我所见,这些主要是语法错误。如@nircraft建议,您应该尝试清洁node_modules,它是cache,然后重新安装。