Skip to content

Recursive data structure type alias "circularly references itself" only if used before declaration #1936

@jeffreymorlan

Description

@jeffreymorlan

var x: StringTree;

type StringTree = string | StringTreeArray;
interface StringTreeArray extends Array<StringTree> {}

This code gets a "Type alias 'StringTree' circularly references itself." error. I believe it should be allowed per the spec, since the Type Aliases section doesn't say that an interface type depends on its base interfaces.

If I move the variable declaration below the type and interface, then the error goes away, but the language service still reports that x has type any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueSpecIssues related to the TypeScript language specification

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions