Skip to content

(mostly) stop unioning in Unknown type where there is no type annotation #1240

@DetachHead

Description

@DetachHead

the current default behavior is unsafe, see https://play.ty.dev/b92b01eb-09da-48ea-8e4b-02812d27a803

a = [1] # inferred as list[Unknown | int]
a.append("i'm not an int") # no error
a.pop() + 1 # runtime crash

as mentioned in #1211 (comment):

I do think we will likely add an option to, or even default to, inferring the type of un-annotated generic container literals without the union with Unknown.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions