Skip to content

Commit

Permalink
chore: upgrade to ts-morph 23 (#12607)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Oct 9, 2024
1 parent 571f731 commit dde7c60
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-rabbits-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-migrate': patch
---

chore: upgrade to ts-morph 23
9 changes: 7 additions & 2 deletions packages/migrate/migrations/svelte-4/migrate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'node:fs';
import { Project, ts, Node } from 'ts-morph';
import { Project, ts, Node, SyntaxKind } from 'ts-morph';
import { log_migration, log_on_ts_modification, update_pkg } from '../../utils.js';

export function update_pkg_json() {
Expand Down Expand Up @@ -201,7 +201,12 @@ function update_imports(source, is_ts) {
return (
(Node.isImportSpecifier(parent) &&
!parent.getAliasNode() &&
parent.getParent().getParent().getParent().getModuleSpecifier().getText() === 'svelte') ||
parent
.getParent()
.getParent()
.getParentIfKind(SyntaxKind.ImportDeclaration)
?.getModuleSpecifier()
.getText() === 'svelte') ||
!is_declaration(parent)
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/migrate/migrations/sveltekit-2/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export function update_svelte_config_content(code) {
namedImport
.getParent()
.getParent()
.getParent()
.setModuleSpecifier('@sveltejs/vite-plugin-svelte');
.getParentIfKind(SyntaxKind.ImportDeclaration)
?.setModuleSpecifier('@sveltejs/vite-plugin-svelte');
} else {
namedImport.remove();
const vps = source.getImportDeclaration(
Expand Down
2 changes: 1 addition & 1 deletion packages/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"prompts": "^2.4.2",
"semver": "^7.5.4",
"tiny-glob": "^0.2.9",
"ts-morph": "^22.0.0",
"ts-morph": "^23.0.0",
"typescript": "^5.3.3",
"zimmerframe": "^1.1.2"
},
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dde7c60

Please sign in to comment.