Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
strategy:
matrix:
node-version: [12, 14, 16]
node-version: [12, 14, 16, 18]
platform: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ typings
# next.js build output
.next

*.js
*.js.map
*.d.ts
*.DS_Store
*.lock

dist/
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest',
testEnvironment: 'node',
};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
"build": "tsc --project tsconfig.json",
"dryrun": "npm publish --dry-run",
"lint": "xo && echo 'No lint errors. All good!'",
"test": "node tests/test.js"
"test": "jest tests/test.ts"
},
"dependencies": {
"type-fest": "^2.1.0",
"typescript": "^4.4.2"
},
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/node": "^18.0.0",
"jest": "^29.6.4",
"prettier": "^2.3.2",
"ts-jest": "^29.1.1",
"xo": "^0.44.0"
},
"xo": {
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import fs from 'node:fs';
import typescript from 'typescript';
import type { PackageJson } from 'type-fest';
import type {
Expand Down Expand Up @@ -167,7 +167,7 @@ const ts2gas = (source: string, transpileOptions: Readonly<TranspileOptions> = {
* It use 'createCommentedStatement' to comment-out filtered node
* @param {NodeFilter} nodeFilter The node visitor used to transform.
*/
const ignoreNodeBeforeBuilder: BeforeTransformerFactory = (nodeFilter) => (context) => {
const ignoreNodeBeforeBuilder: BeforeTransformerFactory = (nodeFilter: NodeFilter) => (context) => {
const visitor: Visitor = (node) =>
nodeFilter(node) ? createCommentedStatement(node) : visitEachChild(node, visitor, context);

Expand All @@ -179,7 +179,7 @@ const ts2gas = (source: string, transpileOptions: Readonly<TranspileOptions> = {
* It use applies the 'NoSubstitution' flag on every node
* @param {NodeFilter} nodeFilter The node visitor used to transform (unused here).
*/
const noSubstitutionBeforeBuilder: BeforeTransformerFactory = (nodeFilter) => (context) => {
const noSubstitutionBeforeBuilder: BeforeTransformerFactory = (nodeFilter: NodeFilter) => (context) => {
const visitor: Visitor = (node) => {
if (
nodeFilter(node) && // Node kind is Identifier
Expand All @@ -202,7 +202,7 @@ const ts2gas = (source: string, transpileOptions: Readonly<TranspileOptions> = {
* @param {SyntaxKind} kind the kind of node to filter.
* @param {NodeFilter} nodeFilter The node visitor used to transform.
*/
const ignoreNodeAfterBuilder: AfterTransformerFactory = (kind, nodeFilter) => (context) => {
const ignoreNodeAfterBuilder: AfterTransformerFactory = (kind: SyntaxKind, nodeFilter: NodeFilter) => (context) => {
const previousOnSubstituteNode = context.onSubstituteNode;

context.enableSubstitution(kind);
Expand Down
Loading