Untyped imports

TypeScript has traditionally been overly strict about how you can import modules.This was to avoid typos and prevent users from using modules incorrectly.

However, a lot of the time, you might just want to import an existing module that may not have its own .d.ts file.Previously this was an error.Starting with TypeScript 2.1 this is now much easier.

With TypeScript 2.1, you can import a JavaScript module without needing a type declaration.A type declaration (such as declare module "foo" { … } or node_modules/@types/foo) still takes priority if it exists.

An import to a module with no declaration file will still be flagged as an error under —noImplicitAny.

Example
  1. // Succeeds if `node_modules/asdf/index.js` exists, or if `node_modules/asdf/package.json` defines a valid "main" entry point
  2. import { x } from "asdf";