Skip to content

Missing 'used before declaration' error with IIFE #29135

@ajafff

Description

@ajafff

TypeScript Version: 3.2.1

Search Terms:

Code

class C {
    a = (() => this.b)();
    b = '';
}

Expected behavior:

Error Property 'b' is used before its initialization.
Control flow analysis inlines IIFEs, but it seems the use-before-declare check doesn't.

Actual behavior:

No error

Playground Link: https://agentcooper.github.io/typescript-play/#code/MYGwhgzhAEDC0G8BQ1XTNAvNAFDglFgHzQAuAFgJYQB0ARvgQNwpp1bQDknLAvkA

Related Issues: Found while investigating #29125

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions