title: TypeScript won't import index.js when index.d.ts is present
body: <p>I'm having strange behavior in TypeScript right now. In a folder separate from my source folder I have generated JS (protobufjs) with type definitions. When I try to import the index file from that folder I get the error <code>[foldername]/index.d.ts is not a module</code>. This even happens if I explicitly import <code>[folder]/index</code> or even <code>[folder]/index.js</code>.</p>
  
  <p>Any idea what could be causing this?</p>
  
  <p>tsconfig looks like this:</p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es2017",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
      "module": "commonjs",
      "declaration": true,                   /* Generates corresponding '.d.ts' file. */
      "declarationMap": true,                /* Generates a sourcemap for each corresponding '.d.ts' file. */
      "sourceMap": true,                     /* Generates corresponding '.map' file. */
      "outDir": "./dist",                        /* Redirect output structure to the directory. */
      "rootDir": "./src",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
      "composite": true,                     /* Enable project compilation */information */
      "removeComments": true,                /* Do not emit comments to output. */
      "strict": true,                           /* Enable all strict type-checking options. */
      "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
      "strictNullChecks": true,              /* Enable strict null checks. */
      "strictFunctionTypes": true,           /* Enable strict checking of function types. */
      "strictBindCallApply": true,           /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
      "strictPropertyInitialization": true,  /* Enable strict checking of property initialization in classes. */
      "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
      "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */
      "noUnusedLocals": true,                /* Report errors on unused locals. */
      "noUnusedParameters": true,            /* Report errors on unused parameters. */
      "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
      "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */
      "esModuleInterop": true                   /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    },
    "include": [ "src" ],
    "exclude": [ "test" ]
  }
  </code></pre>
  
  <p>And possibly of note, the generated file I'm importing is under <code>proto</code>, in the same parent folder as <code>src</code>, and imported via e.g. <code>import * as protos from "../../proto";</code>.</p>
  
  <p>I'm also fairly certain this worked until recently, so some configuration might have changed or a module version updated that I haven't caught as this is a team project. Node 13.9.0, TypeScript 3.7.2.</p>