Skip to content

A Warn intrinsic type #235

@kaleidawave

Description

@kaleidawave

There could be a new intrinsic type that allows the argument but raises an error when it is matched.

This would enable the technically correct, but unideal behaviour of functions like Math.sin

type NumberLike = number | Warn<any, "implicit cast">;
//                         ^^^^

interface Math {
	sin(x: NumberLike): number;
}

declare const Math: Math;

// Warning (not error): "2.2" is allowed but is a "implicit cast"
Math.sin("2.2") 

This is aimed at avoiding false positives in constraint inference #197 #35

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestinferenceRelated to inferring the restriction of poly typesneeds-investigationFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions