-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specifically
Milestone
Description
TypeScript Version: 2.8.1
Search Terms:
jsdoc, casting
Code
utils.d.ts
declare namespace utils {
export type PartialTypeGuard<T, U extends T> = (value: T) => value is U;
export type TypeGuard<T> = PartialTypeGuard<any, T>;
}test.js
// @ts-check
/// <reference path="./utils.d.ts" />
/**
* @type {utils.TypeGuard<string>}
*/
let pass = ((a)=>typeof a === 'string');
/**
* @type {utils.TypeGuard<string>}
*/
let fail = (a)=>typeof a === 'string';Expected behavior:
They both throw error due to casting between item with incompatible signature without explicit casting
Actual behavior:
The first one pass for unknown reason , the second one failed as expect
Playground Link:
Related Issues:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specifically