Javascript AOT生成错误:修饰符中不支持函数调用
我有一个问题,我不知道如何解决它,我已经读了很多关于错误的帖子,但我仍然被卡住了。我用这个软件包创建了我的,星云软件包工作得非常好 我正在使用angular创建一个库。此库用于ionic 3项目中。当我想用ionic应用程序脚本3.2.3构建ionic项目时,我遇到了一个错误: “键入脚本错误 decorators中不支持“AppModule”函数调用的模板编译过程中出错,但“RestClient”中不支持 有人打电话来。 " 代码如下: 应用程序模块Javascript AOT生成错误:修饰符中不支持函数调用,javascript,angular,angular-aot,Javascript,Angular,Angular Aot,我有一个问题,我不知道如何解决它,我已经读了很多关于错误的帖子,但我仍然被卡住了。我用这个软件包创建了我的,星云软件包工作得非常好 我正在使用angular创建一个库。此库用于ionic 3项目中。当我想用ionic应用程序脚本3.2.3构建ionic项目时,我遇到了一个错误: “键入脚本错误 decorators中不支持“AppModule”函数调用的模板编译过程中出错,但“RestClient”中不支持 有人打电话来。 " 代码如下: 应用程序模块 /** * @license * Co
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { APP_BASE_HREF } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { HttpClientModule, HTTP_INTERCEPTORS, HttpRequest } from '@angular/common/http';
import { CoreModule } from './@core/core.module';
import { environment } from '../environments/environment';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { ThemeModule } from './@theme/theme.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NgxAuthModule } from './auth/auth.module';
import { NbOAuth2AuthStrategy , NbOAuth2GrantType, NbOAuth2ClientAuthMethod, NbAuthModule, NbAuthOAuth2JWTToken, NbAuthJWTInterceptor, NB_AUTH_TOKEN_INTERCEPTOR_FILTER } from '@nebular/auth';
import { AuthGuard } from './auth/auth-guard.service';
import { ApolloModule } from 'apollo-angular';
import { HttpLinkModule } from 'apollo-angular-link-http';
//import { WebClientModule, RestClient, GraphQLClient } from './web-client';
import { WebClientModule, RestClient, GraphQLClient } from 'service-consumer';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
AppRoutingModule,
NgbModule.forRoot(),
ThemeModule.forRoot(),
CoreModule.forRoot(),
ApolloModule,
HttpLinkModule,
NgxAuthModule,
NbAuthModule.forRoot({
strategies: [
NbOAuth2AuthStrategy.setup({ //// IT WORKS !
name: '*****',
baseEndpoint: '******',
clientId: '******',
clientSecret: '******',
clientAuthMethod: NbOAuth2ClientAuthMethod.REQUEST_BODY,
token: {
endpoint: '/internal/jwt/oauth2/token',
grantType: NbOAuth2GrantType.PASSWORD,
class: NbAuthOAuth2JWTToken,
},
refresh: {
endpoint: '/internal/jwt/oauth2/refresh',
grantType: NbOAuth2GrantType.REFRESH_TOKEN,
},
})
],
forms: {},
}),
WebClientModule.forRoot({
clients: [
RestClient.setup({ //// IT DOES NOT WORK ! WHY ?
name: 'admin',
endpoint: environment.BASE_URI + environment.ENDPOINT_CONFIGS.ADMIN,
}),
GraphQLClient.setup({
name: 'graphql',
endpoint: environment.BASE_URI + environment.ENDPOINT_CONFIGS.GRAPHQL,
})
]
})
],
bootstrap: [AppComponent],
providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: HTTP_INTERCEPTORS, useClass: NbAuthJWTInterceptor, multi: true},
{ provide: NB_AUTH_TOKEN_INTERCEPTOR_FILTER, useValue: function (req: HttpRequest<any>) {
if (req.url === '/api/auth/refresh-token') { // url to define to refresh token
return true;
}
return false;
},
},
//{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
AuthGuard,
],
})
export class AppModule {
}
/**
*@许可证
*版权所有Akveo。版权所有。
*根据麻省理工学院许可证授权。有关许可证信息,请参阅项目根目录中的License.txt。
*/
从“@angular/common”导入{APP_BASE_HREF};
从“@angular/platform browser”导入{BrowserModule};
从“@angular/platform browser/animations”导入{BrowserAnimationsModule};
从“@angular/core”导入{NgModule};
从'@angular/common/HTTP'导入{HttpClientModule,HTTP_拦截器,HttpRequest};
从“/@core/core.module”导入{CoreModule};
从“../environments/environment”导入{environment};
从“./app.component”导入{AppComponent};
从“./app routing.module”导入{AppRoutingModule};
从“/@theme/theme.module”导入{ThemeModule};
从'@ng bootstrap/ng bootstrap'导入{NgbModule};
从“./auth/auth.module”导入{NgxAuthModule};
从“@nebular/AUTH”导入{NbOAuth2AuthStrategy,NbOAuth2GrantType,NBOAuth2Client方法,NbAuthModule,NbAuthOAuth2JWTToken,NbAuthJWTInterceptor,NB_AUTH_TOKEN_INTERCEPTOR_FILTER};
从“./auth/auth-guard.service”导入{AuthGuard};
从'apollo angular'导入{apollo Module};
从'apollo angular link http'导入{HttpLinkModule};
//从“/web客户端”导入{WebClientModule,RestClient,GraphQLClient};
从“服务使用者”导入{WebClientModule,RestClient,GraphQLClient};
@NGD模块({
声明:[
应用组件,
],
进口:[
浏览器模块,
BrowserAnimationsModule,
HttpClientModule,
批准模块,
NgbModule.forRoot(),
ThemeModule.forRoot(),
CoreModule.forRoot(),
阿波罗舱,
HttpLinkModule,
Ngxauth模块,
NbAuthModule.forRoot({
战略:[
NbOAuth2AuthStrategy.setup({///它可以工作!
名称:'******',
baseEndpoint:“*******”,
客户ID:“*******”,
客户机密:'******',
clientAuthMethod:NbOAuth2ClientAuthMethod.REQUEST\u BODY,
代币:{
端点:'/internal/jwt/oauth2/token',,
grantType:NbOAuth2GrantType.PASSWORD,
类别:NbAuthOAuth2JWTToken,
},
刷新:{
端点:'/internal/jwt/oauth2/refresh',
grantType:NbOAuth2GrantType.REFRESH\u令牌,
},
})
],
表格:{},
}),
WebClientModule.forRoot({
客户:[
RestClient.setup({///它不工作!为什么?
名称:'管理员',
端点:environment.BASE\u URI+environment.endpoint\u CONFIGS.ADMIN,
}),
GraphQLClient.setup({
名称:“graphql”,
端点:environment.BASE_URI+environment.endpoint_CONFIGS.GRAPHQL,
})
]
})
],
引导:[AppComponent],
供应商:[
{提供:APP_BASE_HREF,useValue:'/'},
{提供:HTTP_拦截器,useClass:NbAuthJWTInterceptor,multi:true},
{provide:NB\u AUTH\u TOKEN\u INTERCEPTOR\u FILTER,useValue:function(req:HttpRequest){
if(req.url=='/api/auth/refresh-token'){//url来定义刷新令牌
返回true;
}
返回false;
},
},
//{provide:HTTP_拦截器,useClass:JwtInterceptor,multi:true},
AuthGuard,
],
})
导出类AppModule{
}
web客户端/web客户端.模块
import { Injector, ModuleWithProviders, NgModule, TestabilityRegistry } from '@angular/core';
import { CommonModule } from '@angular/common';
import {
Client,
ClientOptions,
RestClient,
GraphQLClient
} from './clients';
import {
CLIENT_SERVICE_OPTIONS,
CLIENTS_SERVICE,
ClientServiceOptions,
ClientClass
} from './web-client-options';
import { ClientService } from './services/client.service';
import { HttpClient, HttpClientModule, HttpHeaders } from '@angular/common/http';
import { Apollo, ApolloModule } from 'apollo-angular';
import { HttpLink, HttpLinkModule } from 'apollo-angular-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
/**
* Rest client factory function
*
* @param options rest client options
* @param injector angular injector service
*/
export function webClientFactory(clientServiceOptions: ClientServiceOptions, injector: Injector): Client[] {
const clients = [];
clientServiceOptions.clients
.forEach(([clientClass, clientOptions]: [ClientClass, ClientOptions]) => {
if(clientClass == RestClient) {
const client: Client = new clientClass(injector.get(HttpClient));
client.setOptions(clientOptions);
clients.push(client);
}
if(clientClass == GraphQLClient) {
const client: Client = new clientClass(injector.get(Apollo), injector.get(HttpLink));
client.setOptions(clientOptions);
clients.push(client);
}
// https://github.com/akveo/nebular/issues/682
// const client: Client = injector.get(clientClass);
// client.setOptions(clientOptions);
// clients.push(client);
});
return clients;
}
@NgModule({
imports: [
CommonModule
],
declarations: [
],
exports: [
],
})
export class WebClientModule {
static forRoot(clientServiceOptions?: ClientServiceOptions): ModuleWithProviders {
return <ModuleWithProviders> {
ngModule: WebClientModule,
providers: [
{ provide: CLIENT_SERVICE_OPTIONS, useValue: clientServiceOptions },
{ provide: CLIENTS_SERVICE, useFactory: webClientFactory, deps:[CLIENT_SERVICE_OPTIONS, Injector] },
ClientService,
RestClient
],
};
}
}
从“@angular/core”导入{Injector,ModuleWithProviders,NgModule,TestabilityRegistry};
从“@angular/common”导入{CommonModule};
进口{
客户
ClientOptions,
RestClient,
GraphQLClient
}来自“./客户”;
进口{
客户服务选项,
客户服务,
ClientServiceOptions,
客户端类
}从“/web客户端选项”;
从“./services/client.service”导入{ClientService};
从'@angular/common/http'导入{HttpClient,HttpClientModule,HttpHeaders};
从'Apollo angular'导入{Apollo,Apollo Module};
从'apollo angular link http'导入{HttpLink,HttpLinkModule};
从'apollo cache inmemory'导入{InMemoryCache};
/**
*Rest客户端工厂函数
*
*@param options rest客户端选项
*@param喷油器角喷油器服务
*/
导出函数WebClient Factory(clientServiceOptions:clientServiceOptions,injector:injector):客户端[]{
const clients=[];
clientServiceOptions.clients
.forEach(([clientClass,clientOptions]:[clientClass,clientOptions])=>{
if(clientClass==RestClient){
const client:client=newclientclass(injector.get(HttpClient));
client.setOptions(clientOptions);
客户机。推送(客户机);
}
if(clientClass==GraphQLClient){
const client:client=newclientclass(injector.get(Apollo)、injector.get(HttpLink));
client.setOptions(clientOptions);
客户机。推送(客户机);
}
// https://github.com/akveo/nebular/issues/682
//const client:client=injector.get(clientClass);
//client.setOptions(clientOptions);
//客户机。推送(客户机);
});
返回客户;
}
@NGD模块({
进口:[
公共模块
],
声明:[
],
出口:[
],
})
导出类WebClient模块{
静态forRoot(clientServiceOptions?:clientServiceOptions):ModuleWithProviders{
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Client } from '../client';
import { ClientClass } from '../../web-client-options';
import { HTTP_VERB } from '../client-request';
import { RestClientRequest } from './rest-client-request';
import { RestClientOptions } from './rest-client-options';
@Injectable()
export class RestClient extends Client {
// the setup function called in app.module
static setup(options: RestClientOptions): [ClientClass, RestClientOptions] {
return [RestClient, options];
}
constructor(private httpClient: HttpClient) {
super();
}
/**
* Create a Rest Client Request
*
* @return RestClientRequest
*/
createRequest(httpVerb: HTTP_VERB, path?: string, queryParams: object = {}, content: object = {}): RestClientRequest {
const request = new RestClientRequest(this.getUriAction(path), queryParams, content);
request.setHttpVerb(httpVerb);
return request;
}
/**
* Execute the given request
*
* @param request
*/
doRequest(request?: RestClientRequest) : Observable<Object>
{
switch(request.getHttpVerb()) {
case HTTP_VERB.GET: {
return this.get(request);
}
case HTTP_VERB.POST: {
return this.post(request);
}
case HTTP_VERB.PUT: {
return this.put(request);
}
case HTTP_VERB.PATCH: {
return this.patch(request);
}
case HTTP_VERB.DELETE: {
return this.delete(request);
}
default: {
throw new TypeError(`Invalid HTTP_VERB ${request.getHttpVerb()} given`);
}
}
}
/**
* GET http request
*
* @param request
*/
private get(request: RestClientRequest): Observable<Object> {
return this.httpClient.get(request.getUri() + request.getQueryParams());
}
/**
* POST http request
*
* @param path
* @param body
*/
private post(request: RestClientRequest): Observable<Object> {
throw new TypeError(`Not implemented yet`);
}
/**
* PUT http request
*
* @param request
*/
private put(request: RestClientRequest): Observable<Object> {
throw new TypeError(`Not implemented yet`);
}
/**
* PATCH http request
*
* @param request
*/
private patch(request: RestClientRequest): Observable<Object> {
throw new TypeError(`Not implemented yet`);
}
/**
* DELETE http request
*
* @param request
*/
private delete(request: RestClientRequest): Observable<boolean> {
throw new TypeError(`Not implemented yet`);
}
}