Closed
Description
TypeScript Version:
- typescript@2.8.4 ok
- typescript@2.9.2 bug
- typescript@3.0.0-dev.20180626 bug
Search Terms:
Code
declare const AddressSymbol: unique symbol;
type AddressString = typeof AddressSymbol & string;
function printout(data: AddressString | undefined) {
console.log(data); // type of `data` is always undefined since TS 2.9
}
printout(undefined); // ok
const a = "foo" as AddressString;
printout(a); // broken since TS 2.9
Expected behavior: the code compiles
Actual behavior: since TypeScript 2.9, the compilations fails with:
$ ./node_modules/typescript/bin/tsc example.ts
example.ts:11:10 - error TS2345: Argument of type 'AddressString' is not assignable to parameter of type 'undefined'.
11 printout(a); // broken in TS 2.9
~
Related Issues: #25179