Skip to content

preProcessFile does not detect "import type" statements #37338

@kitsonk

Description

@kitsonk

TypeScript Version: 3.8.3

Search Terms:

preProcessFile, type only import, ambientExternalModules

Code

import ts from "typescript";

const text = `import type { Func } from "./subdir/types.ts";

const func: Func = t => t;
`;

console.log(ts.preProcessFile(text, true));

Expected behavior:

That the type only import would be referenced somehow. As of TypeScript 3.8, ambientExternalModules was introduced, so I can only assume that is where it should go, but it isn't populated. In addition, ambientExternalModules is of type string[] unlike the other properties which are FileReference[].

Actual behavior:

{
  referencedFiles: [],
  typeReferenceDirectives: [],
  libReferenceDirectives: [],
  importedFiles: [],
  isLibFile: false,
  ambientExternalModules: undefined
}

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions