Skip to content

preProcessFile does not detect "import type" statements #37338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kitsonk opened this issue Mar 11, 2020 · 2 comments · Fixed by #37508
Closed

preProcessFile does not detect "import type" statements #37338

kitsonk opened this issue Mar 11, 2020 · 2 comments · Fixed by #37508
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Mar 11, 2020

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
}
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 11, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.9.0 milestone Mar 11, 2020
@RyanCavanaugh
Copy link
Member

Also pinging @andrewbranch for opinions on what the best behavior here is

@sheetalkamat
Copy link
Member

Its definitely bug and it should return importedFiles to contain the actual file form import type

@sheetalkamat sheetalkamat added Bug A bug in TypeScript and removed Needs Investigation This issue needs a team member to investigate its status. labels Mar 11, 2020
@sheetalkamat sheetalkamat added the Fix Available A PR has been opened for this issue label Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants