-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 3.0.0-dev.20180712, 3.0-rc, 2.9. Our original code worked fine in 2.8 with strictNullChecks
enabled.
Search Terms: strictNullChecks, branding, enum, optional, intersection, undefined
Code
// strictNullChecks must be enabled to see this problem
enum Brand {}
type BrandedString = string & Brand;
export const fromString = (s:string) => s as BrandedString
interface ComplexType {
optional?: BrandedString;
}
const example: ComplexType = {
optional: fromString("foo")
};
Expected behavior: Example type checks
Actual behavior: Example does not type check TypeScript thinks optional
is has type undefined
.
Playground Link: Ensure strictNullChecks is enabled. Link here
Related Issues: #25179 looks similarish
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug