Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

moveToNewFile: Infer quote preference#24652

Merged
1 commit merged into
mastermicrosoft/TypeScript:masterfrom
moveToNewFile_inferQuoteStylemicrosoft/TypeScript:moveToNewFile_inferQuoteStyleCopy head branch name to clipboard
Jun 7, 2018
Merged

moveToNewFile: Infer quote preference#24652
1 commit merged into
mastermicrosoft/TypeScript:masterfrom
moveToNewFile_inferQuoteStylemicrosoft/TypeScript:moveToNewFile_inferQuoteStyleCopy head branch name to clipboard

Conversation

@ghost

@ghost ghost commented Jun 4, 2018

Copy link
Copy Markdown

Fixes #24605

@ghost ghost requested a review from amcasey June 4, 2018 17:35
if (moduleExportsChangedToDefault) {
for (const importingFile of program.getSourceFiles()) {
fixImportOfModuleExports(importingFile, sourceFile, changes, preferences);
fixImportOfModuleExports(importingFile, sourceFile, changes, getQuotePreference(importingFile, preferences));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the other preferences? why aren't we pass the other ones too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're currently not using any other preferences; if we did we would need to create a ProcessedPreferences interface since we don't want to pass raw preferences, we want preferences with quote style inferred.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so shouldn't it be :

{...preferences, quotePreference: getQuotePreference(prefrences)} 

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quotePreference in UserPreferences is a different type than QuotePreference -- and it should be, because we want the type checker to ensure that we've processed the preferences.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we are leaving behind all other preferences.. the next user preference we add will not be passed through.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, which means we would have to change the code to pass more parameters if that turned out to be necessary. Or I could create ProcessedPreferences interface right now if you prefer?

Comment thread src/services/utilities.ts
return createLiteral(text, quotePreference === QuotePreference.Single);
}

export const enum QuotePreference { Single, Double }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code also lists auto as an option. I asked @mhegazy about it and there seemed to be some confusion about how to distinguish between "figure it out for me" and "keep it in its current state". I don't think sorting that out will require changes to this code, but it's something to keep in mind.

/// <reference path='fourslash.ts' />

// @Filename: /a.ts
////import 'unrelated';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naively, I would have expected to see a test for each possible inference (i.e. one single, one double).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most other moveToNewFile tests are using double quotes, since that's the default inference.

@ghost ghost merged commit 0fefaf2 into master Jun 7, 2018
@ghost ghost deleted the moveToNewFile_inferQuoteStyle branch June 7, 2018 19:10
@mhegazy

mhegazy commented Jun 7, 2018

Copy link
Copy Markdown
Contributor

Please port to release-2.9 as well.

ghost pushed a commit that referenced this pull request Jun 7, 2018
ghost pushed a commit that referenced this pull request Jun 7, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.