Skip to content

Commit 0a41d52

Browse files
setup(typescript): update (#146)
1 parent 9d9e2d4 commit 0a41d52

File tree

21 files changed

+303
-255
lines changed

21 files changed

+303
-255
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"editor.wordWrapColumn": 100,
88
"[markdown]": {
99
"editor.wordWrap": "off"
10-
}
10+
},
11+
"typescript.experimental.useTsgo": true
1112
}

CONTRIBUTING.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Each codemod resides in its own directory under `recipes/` and should include:
4040
**`src/workflow.ts` example:**
4141
```ts
4242
import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
43+
import type JS from "@codemod.com/jssg-types/langs/javascript";
44+
4345
/**
4446
* Transform function that converts deprecated api.fn calls
4547
* to the new api.fn syntax.
@@ -49,12 +51,15 @@ import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
4951
* 2. api.fn(<args>, { recursive: true })
5052
* ...
5153
*/
52-
export default function transform(root: SgRoot): string | null {
54+
export default function transform(root: SgRoot<JS>): string | null {
5355
const rootNode = root.root();
54-
let hasChanges = false;
5556
const edits: Edit[] = [];
57+
5658
// do some transformation
57-
if (!hasChanges) return null;
59+
edits.push(...);
60+
61+
if (edits.length === 0) return null;
62+
5863
return rootNode.commitEdits(edits);
5964
}
6065
```

package-lock.json

Lines changed: 158 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"pre-commit": "node --run lint:fix; node --run type-check; node --run test",
1010
"test": "npm run test --workspaces --if-present",
1111
"test-legacy": "npm run test-legacy --workspaces --if-present",
12-
"type-check": "tsc"
12+
"type-check": "tsgo --noEmit"
1313
},
1414
"repository": {
1515
"type": "git",
@@ -27,9 +27,9 @@
2727
},
2828
"homepage": "https://nodejs.org/learn/userland-migrations",
2929
"devDependencies": {
30-
"@biomejs/biome": "2.2.4",
31-
"@types/node": "^24.5.0",
32-
"typescript": "^5.9.2"
30+
"@biomejs/biome": "2.1.4",
31+
"@types/node": "^24.2.1",
32+
"@typescript/native-preview": "^7.0.0-dev.20250916.1"
3333
},
3434
"workspaces": [
3535
"./recipes/*",

recipes/create-require-from-path/src/workflow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getNodeImportStatements } from "@nodejs/codemod-utils/ast-grep/import-statement";
22
import { getNodeRequireCalls } from "@nodejs/codemod-utils/ast-grep/require-call";
33
import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
4+
import type JS from "@codemod.com/jssg-types/langs/javascript";
45

56
/**
67
* Transform function that updates code to replace deprecated `createRequireFromPath` usage
@@ -20,7 +21,7 @@ import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
2021
*
2122
* 3. Preserves original variable names and declaration types.
2223
*/
23-
export default function transform(root: SgRoot): string | null {
24+
export default function transform(root: SgRoot<JS>): string | null {
2425
const rootNode = root.root();
2526
const edits: Edit[] = [];
2627
let hasChanges = false;

recipes/fs-access-mode-constants/src/workflow.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default function tranform(root: SgRoot<Js>): string | null {
88
const edits: Edit[] = [];
99
const patterns = ['F_OK', 'R_OK', 'W_OK', 'X_OK'];
1010

11-
// @ts-expect-error - ast-grep types are not fully compatible with JSSG types
1211
const requireStatements = getNodeRequireCalls(root, 'fs');
1312

1413
for (const statement of requireStatements) {
@@ -30,7 +29,6 @@ export default function tranform(root: SgRoot<Js>): string | null {
3029
}
3130
}
3231

33-
// @ts-expect-error - ast-grep types are not fully compatible with JSSG types
3432
const importStatements = getNodeImportStatements(root, 'fs');
3533
let promisesImportName = '';
3634

0 commit comments

Comments
 (0)