Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Svelte 4 migration #9729

Merged
merged 7 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
dummdidumm committed May 26, 2023
commit 295ef7a1465c9cb813702494894dd50d462d86ba
6 changes: 3 additions & 3 deletions packages/migrate/migrations/svelte-4/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function migrate() {
const svelte_extensions = config.extensions ?? ['.svelte'];
const extensions = [...svelte_extensions, '.ts', '.js'];
// TODO read tsconfig/jsconfig if available? src/** will be good for 99% of cases
const files = glob(`src/**`, { filesOnly: true, dot: true }).map((file) =>
const files = glob('src/**', { filesOnly: true, dot: true }).map((file) =>
file.replace(/\\/g, '/')
);

Expand All @@ -57,8 +57,8 @@ export async function migrate() {

const tasks = [
use_git && cyan('git commit -m "migration to Svelte 4"'),
`Review the migration guide at TODO`,
`Read the updated docs at https://svelte.dev/docs`
'Review the migration guide at TODO',
'Read the updated docs at https://svelte.dev/docs'
].filter(Boolean);

tasks.forEach((task, i) => {
Expand Down
14 changes: 7 additions & 7 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, SourceFile, ts, Node } from 'ts-morph';
import { Project, ts, Node } from 'ts-morph';

/** @param {string} file_path */
export function update_svelte_file(file_path) {
Expand Down Expand Up @@ -56,7 +56,7 @@ function update_transitions(code) {

/**
* Action<T> -> Action<T, any>
* @param {SourceFile} source
* @param {import('ts-morph').SourceFile} source
*/
function update_action_types(source) {
const imports = get_imports(source, 'svelte/action', 'Action');
Expand All @@ -79,7 +79,7 @@ function update_action_types(source) {

/**
* ActionReturn -> ActionReturn<any>
* @param {SourceFile} source
* @param {import('ts-morph').SourceFile} source
*/
function update_action_return_types(source) {
const imports = get_imports(source, 'svelte/action', 'ActionReturn');
Expand All @@ -102,7 +102,7 @@ function update_action_return_types(source) {

/**
* SvelteComponentTyped -> SvelteComponent
* @param {SourceFile} source
* @param {import('ts-morph').SourceFile} source
*/
function update_imports(source) {
const identifiers = find_identifiers(source, 'SvelteComponent');
Expand Down Expand Up @@ -140,7 +140,7 @@ function update_imports(source) {

/**
* typeof SvelteComponent -> typeof SvelteComponent<any>
* @param {SourceFile} source
* @param {import('ts-morph').SourceFile} source
*/
function update_typeof_svelte_component(source) {
const imports = get_imports(source, 'svelte', 'SvelteComponent');
Expand All @@ -165,7 +165,7 @@ function update_typeof_svelte_component(source) {
}

/**
* @param {SourceFile} source
* @param {import('ts-morph').SourceFile} source
* @param {string} from
* @param {string} name
*/
Expand All @@ -178,7 +178,7 @@ function get_imports(source, from, name) {
}

/**
* @param {SourceFile} source
* @param {import('ts-morph').SourceFile} source
* @param {string} name
*/
function find_identifiers(source, name) {
Expand Down