Skip to content

Conversation

@IllusionMH
Copy link
Contributor

Fixes #33680

Should process template literals in all positions where TS support them. Should correctly return full list when ts.preProcessFile is called.

I also tried to write test like https://github.com/microsoft/TypeScript/blob/98cf317005d62a9b275e1f1b37a18b7f5b457e74/tests/cases/fourslash/shims-pp/getPreProcessedFile.ts
but when I use dynamic imports

/// <reference path="fourslash.ts" />
// @module: esnext
// @target: esnext

// @Filename: main.ts
// @ResolveReference: true
//// const a = import(/*1*/`wrong`/*2*/);

goTo.file("main.ts");
verify.numberOfErrorsInCurrentFile(1);
verify.errorExistsBetweenMarkers("1", "2");

I receive 3 errors

Unexpected error(s) found.  Error list is:
  global, message: Cannot find global value 'Promise'.

  from: 0:10, to: 0:25, message: A dynamic import call in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.

  from: 0:17, to: 0:24, message: Cannot find module 'wrong'.

Actual number of errors (3) does not match expected number (1)

Where only 3rd error was expected.

Setting module to commonjs or target to es2015 doesn't help.

Do I need to add tests for error reporting on wrong references (3rd error)? Any suggestions how to avoid unexpected errors?

@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed 'preProcess.ts' in some way. Please ensure that any changes here don't break consumers with unique project systems such as Visual Studio. Pinging @sheetalkamat, @amcasey, and @minestarks so they are aware of the changes.

@joscha
Copy link
Contributor

joscha commented Jan 31, 2020

references #36546

@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 1, 2020
@sandersn sandersn closed this Mar 12, 2020
@sandersn sandersn reopened this Mar 12, 2020
@sandersn
Copy link
Member

I closed/re-opened the PR to re-run tests, just to see whether tests still pass after sitting for 6 months.

@IllusionMH
Copy link
Contributor Author

Should I rebase on top of master?

@sandersn
Copy link
Member

It would be nice -- I didn't know you were still paying attention to this PR @IllusionMH!

@IllusionMH IllusionMH force-pushed the preprocess-template-literals-33680 branch from b216757 to 15de3ad Compare March 12, 2020 22:31
@IllusionMH
Copy link
Contributor Author

Rebased. Sorry for delay - local test/lint took 28mins

I didn't know you were still paying attention to this PR @IllusionMH!

I didn't know when/if it will be reviewed/merged, so decided to avoid unnecessary notification spam on pushes.
Unfortunately there are no notifications for project board moves and I've missed changes few days ago.

@sandersn
Copy link
Member

(I treat no-notifications as a feature so I can move things around all over the place without spamming people.)

@sandersn
Copy link
Member

Everything but node 10 and node 8 on Travis is done, so I'm going to merge this.

@sandersn sandersn merged commit c6cfd66 into microsoft:master Mar 12, 2020
@IllusionMH
Copy link
Contributor Author

Thanks!

Yeah, it's great that there are no labels/project spam all the time for sure :)

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

ts.getPreProcessedFileInfo doesn't detect imported files from import(template) and require(tempalte)

5 participants