Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 2.26 KB

start-loose.md

File metadata and controls

62 lines (47 loc) · 2.26 KB

Item 83: Don't Consider Migration Complete Until You Enable noImplicitAny

Things to Remember

  • Don't consider your TypeScript migration done until you adopt noImplicitAny. Loose type checking can mask real mistakes in type declarations.
  • Fix type errors gradually before enforcing noImplicitAny. Give your team a chance to get comfortable with TypeScript before adopting stricter checks.## Code Samples
class Chart {
  indices: any;

  // ...
}

💻 playground


class Chart {
  indices: number[];

  // ...
}

💻 playground


getRanges() {
  for (const r of this.indices) {
    const low = r[0];
    //    ^? const low: any
    const high = r[1];
    //    ^? const high: any
    // ...
  }
}

💻 playground


getRanges() {
  for (const r of this.indices) {
    const low = r[0];
    //          ~~~~ Element implicitly has an 'any' type because
    //               type 'Number' has no index signature
    const high = r[1];
    //           ~~~~ Element implicitly has an 'any' type because
    //                type 'Number' has no index signature
    // ...
  }
}

💻 playground