Skip to content

Code used to work but doesn't in nightly #12584

Closed
@basarat

Description

@basarat

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

Code

interface CSSProps  {
  color?: string
}
interface NestedCSSProps extends CSSProps {
  nested?: NestedSelector
}
interface NestedSelector  {
  [selector: string]: CSSProps | undefined;
}

let stylen: NestedCSSProps;


// ok
stylen = {
  nested: {
    '&:hover': {
      color: 'red'
    }
  }
}


// does error
stylen = {
  nested: {
    '&:hover': {
      colour: 'red'
    }
  }
}

Works in playground http://www.typescriptlang.org/play/#src=interface%20CSSProps%20%20%7B%0A%20%20color%3F%3A%20string%0A%7D%0Ainterface%20NestedCSSProps%20extends%20CSSProps%20%7B%0A%20%20nested%3F%3A%20NestedSelector%0A%7D%0Ainterface%20NestedSelector%20%20%7B%0A%20%20%5Bselector%3A%20string%5D%3A%20CSSProps%20%7C%20undefined%3B%0A%7D%0A%0Alet%20stylen%3A%20NestedCSSProps%3B%0A%0A%0A%2F%2F%20ok%0Astylen%20%3D%20%7B%0A%20%20nested%3A%20%7B%0A%20%20%20%20'%26%3Ahover'%3A%20%7B%0A%20%20%20%20%20%20color%3A%20'red'%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0A%0A%2F%2F%20does%20error%0Astylen%20%3D%20%7B%0A%20%20nested%3A%20%7B%0A%20%20%20%20'%26%3Ahover'%3A%20%7B%0A%20%20%20%20%20%20colour%3A%20'red'%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D

Expected behavior:
Works in nightly

Actual behavior:
Doesn't work in nightly. You don't get an error for the colour typo

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions