• FAQs
  • Common "Bugs" That Aren't Bugs
  • Common Feature Requests
  • Type System Behavior
  • What is structural typing?
  • What is type erasure?
  • Why are getters without setters not considered read-only?
  • Why are function parameters bivariant?
  • Why are functions with fewer parameters assignable to functions that take more parameters?
  • Why are functions returning non-void assignable to function returning void?
  • Why are all types assignable to empty interfaces?
  • Can I make a type alias nominal?
  • How do I prevent two types from being structurally compatible?
  • How do I check at run-time if an object implements some interface?
  • Why doesn't this incorrect cast throw a runtime error?
  • Why don't I get type checking for (number) => string or (T) => T?
  • Why am I getting an error about a missing index signature?
  • Why am I getting Supplied parameters do not match any signature error?
  • Functions
  • Why can't I use x in the destructuring function f({ x: number }) { /* ... */ }?
  • Classes
  • Why do these empty classes behave strangely?
  • When and why are classes nominal?
  • Why does this get orphaned in my instance methods?
  • What's the difference between Bar and typeof Bar when Bar is a class?
  • Why do my derived class property initializers overwrite values set in the base class constructor?
  • What's the difference between declare class and interface?
  • What does it mean for an interface to extend a class?
  • Why am I getting "TypeError: [base class name] is not defined in __extends?
  • Why am I getting "TypeError: Cannot read property 'prototype' of undefined" in __extends?
  • Why doesn't extending built-ins like Error, Array, and Map work?
  • Generics
  • Why is A<string> assignable to A<number> for interface A<T> { }?
  • Why doesn't type inference work on this interface: interface Foo<T> { }?
  • Why can't I write typeof T, new T, or instanceof T in my generic function?
  • Modules
  • Why are imports being elided in my emit?
  • Why don't namespaces merge across different module files?
  • Enums
  • What's the difference between enum and const enums?
  • Type Guards
  • Why doesn't x instanceof Foo narrow x to Foo?
  • Why doesn't isFoo(x) narrow x to Foo when isFoo is a type guard?
  • Decorators
  • Decorators on function declarations
  • What's the difference between @dec and @dec()? Shouldn't they be equivalent?
  • JSX and React
  • I wrote declare var MyComponent: React.Component;, why can't I write <MyComponent />?
  • Things That Don't Work
  • You should emit classes like this so they have real private members
  • You should emit classes like this so they don't lose this in callbacks
  • You should have some class initialization which is impossible to emit code for
  • External Tools
  • How do I write unit tests with TypeScript?
  • Commandline Behavior
  • Why did adding an import or export modifier break my program?
  • How do I control file ordering in combined output (--out)?
  • What does the error "Exported variable [name] has or is using private name [name]" mean?
  • Why does --outDir moves output after adding a new file?
  • tsconfig.json Behavior
  • Why is a file in the exclude list still picked up by the compiler?
  • How can I specify an include?
  • Why am I getting the error TS5055: Cannot write file 'xxx.js' because it would overwrite input file. when using JavaScript files?
  • Comments
  • Why some comments are not preserved in emitted JavaScript even when --removeComments is not specified?
  • Why Copyright comments are removed when --removeComments is true?
  • Glossary and Terms in this FAQ
  • Dogs, Cats, and Animals, Oh My
  • "Substitutability"
  • Trailing, leading, and detached comments
  • GitHub Process Questions
  • What do the labels on these issues mean?
  • I disagree with the outcome of this suggestion