Skip to content

Commit

Permalink
fix quote behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
iisaduan committed Oct 12, 2024
1 parent f918071 commit 0f55561
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/services/codefixes/importFixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ function createImportAdderWorker(sourceFile: SourceFile | FutureSourceFile, prog

function writeFixes(changeTracker: textChanges.ChangeTracker, oldFileQuotePreference?: QuotePreference) {
let quotePreference: QuotePreference;
if (isFullSourceFile(sourceFile) && sourceFile.imports.length === 0 && oldFileQuotePreference !== undefined) {
// If the target file has no imports, we must use the same quote preference as the file we are importing from.
if (sourceFile.imports !== undefined && sourceFile.imports.length === 0 && oldFileQuotePreference !== undefined) {
// If the target file (including future files) has no imports, we must use the same quote preference as the file we are importing from.
quotePreference = oldFileQuotePreference;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/fourslash/moveToNewFile_inferQuoteStyle2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

verify.moveToNewFile({
newFileContents: {
"/newFile.ts":
`import { x } from "./a";
"/newFile.ts": // module specifier should have the same quotes as import in the original file
`import { x } from './a';
x;
`,
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/moveToNewFile_moveNamedImport2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ verify.moveToNewFile({
`export const a = 0;`,

"/x.ts":
`import { foo as oFoo } from "./other";
`import { foo as oFoo } from './other';
export const x = oFoo();
`
Expand Down

0 comments on commit 0f55561

Please sign in to comment.