小编Smi*_*mit的帖子

当从LocalStorage为对象赋值时,如何在typescript对象中创建实例方法

我是Java开发人员,但我正在尝试使用打字稿来玩游戏.

这是我的用户对象:

export class User
{
    id: string;
    name: string;
    email?: string;
    unit: string;
    street: string;
    postalcode: string;
    paymentmode: string;

    public isComplete(): boolean
    {
        if(this.id != null && this.email != null && this.isAddress()){ return true}
        else return false;
    }

    public isAddress(): boolean
    {
        if(this.street != null && this.postalcode != null){ return true}
        else return false
    }


}
Run Code Online (Sandbox Code Playgroud)

还有另一种打字稿......

var user = new User();
user = this.loginService.getLocalUser();
Run Code Online (Sandbox Code Playgroud)

我假设localStorage被解析为用户!

我无法以这种方式访问​​isComplete方法

user.isComplete()
Run Code Online (Sandbox Code Playgroud)

相反,我需要将它用作静态对象

User.isComplete
Run Code Online (Sandbox Code Playgroud)

我的getLocaluser:

getLocalUser(): User {
        var user = new User(); …
Run Code Online (Sandbox Code Playgroud)

typescript angular

15
推荐指数
4
解决办法
3125
查看次数

运行 Spring Boot 应用程序时出现兼容版本问题,但在 pom 中只有版本

应用程序未启动,但我只添加了一个版本的resilience4j

<dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-spring-boot2</artifactId>
            <version>1.3.1</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

这是日志:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    io.github.resilience4j.circuitbreaker.configure.CircuitBreakerConfiguration.createCircuitBreakerRegistry(CircuitBreakerConfiguration.java:141)

The following method did not exist:

    io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry.of(Ljava/util/Map;Lio/github/resilience4j/core/registry/RegistryEventConsumer;Lio/vavr/collection/Map;)Lio/github/resilience4j/circuitbreaker/CircuitBreakerRegistry;

The method's class, io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry, is available from the following locations:

    jar:file:/Users/Smit/.m2/repository/io/github/resilience4j/resilience4j-circuitbreaker/1.1.0/resilience4j-circuitbreaker-1.1.0.jar!/io/github/resilience4j/circuitbreaker/CircuitBreakerRegistry.class

It was loaded from the following location:

    file:/Users/Smit/.m2/repository/io/github/resilience4j/resilience4j-circuitbreaker/1.1.0/resilience4j-circuitbreaker-1.1.0.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry


Process finished …
Run Code Online (Sandbox Code Playgroud)

java maven spring-boot resilience4j

5
推荐指数
2
解决办法
9086
查看次数

打字稿错误:无法分配给类型参数(相同类型不同文件夹)

我目前正在开发 aws cdk,其中使用 Typescript 进行设置。我有一个问题,我有相同的库,但它们被称为不同类型。

编译错误:

Argument of type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/core/lib/cfn-output").CfnOutput' is not assignable to parameter of type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/aws-codestarnotifications/node_modules/@aws-cdk/core/lib/cfn-output").CfnOutput'.
  Types have separate declarations of a private property '_description'.
Run Code Online (Sandbox Code Playgroud)
Argument of type 'CdkCloudFormationAppreciationDashboardStage' is not assignable to parameter of type 'Stage'.
  Types of property '_assemblyBuilder' are incompatible.
    Type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/cx-api/lib/cloud-assembly").CloudAssemblyBuilder' is not assignable to type 'import("/Users/Smit/Documents/Dev/aws-cdk/cdk-cloud-formation-appreciation-dashboard/node_modules/@aws-cdk/aws-codestarnotifications/node_modules/@aws-cdk/cx-api/lib/cloud-assembly").CloudAssemblyBuilder'.
      Types have separate declarations of a private property 'artifacts'.ts(2345)
Run Code Online (Sandbox Code Playgroud)

代码:

 // This is where we add the application stages
   const preprod = new CdkCloudFormationAppreciationDashboardStage(this, 'PreProd', {
    env: …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services typescript aws-cdk

1
推荐指数
1
解决办法
1235
查看次数