-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this
Milestone
Description
Bug Report
π Search Terms
preProcessFile, ts.preProcessFile, template literal types
π Version & Regression Information
- This is the behavior in every version I tried (tried v4.1.5, v4.5.4 and nightly).
β― Playground Link
Playground link with relevant code
π» Code
/*
THIS IS CORRECTLY IGNORED
```
import * as react from 'react';
```
*/
type Foo = `${string}`;
/**
THIS IS NOT IGNORED
```
import {Get} from 'type-fest';
import * as lodash from 'lodash';
```
*/Or, as a quick node example:
> ts.preProcessFile(`\
... type Foo = \`\${string}\`;
... /**
... \`\`\`
... import {Get} from 'type-fest';
... import * as lodash from 'lodash';
... \`\`\`
... */
... `)
{
referencedFiles: [],
typeReferenceDirectives: [],
libReferenceDirectives: [],
importedFiles: [
{ fileName: 'type-fest', pos: 50, end: 59 },
{ fileName: 'lodash', pos: 87, end: 93 }
],
isLibFile: false,
ambientExternalModules: undefined
}
π Actual behavior
ts.preProcessFile parses the imports within comments after the template literal type.
π Expected behavior
The imports within the comment are ignored correctly after the template literal type.
Might be related to #30878?
Original report: microsoft/TypeScript-Website#2243
This causes issues with the TS playground because it will over-fetch types based on the pre-process result. This can cause startup delays, esp with packages like lodash which have a huge numbers of files to fetch.
Hotell and a-tarasyuk
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this