Skip to content

Add rule to enforce correct type of optional constructor injection parameters #3

@ajafff

Description

@ajafff
@Injectable()
class Foo {
  constructor(
    bar: Bar, // ok, no Optional
    @Optional() baz: Baz, // error, needs 'null' in type
    @Optional() bas: Bas | null, // ok
    @Optional() foobar?: FooBar, // error, the fallback value is 'null', not 'undefined'
  ) {}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions