-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/module): Allow TypeScript nodes for
Rewriter
(#9606)
**Related issue:** - Closes #9592
- Loading branch information
Showing
6 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
swc_core: patch | ||
swc_ecma_transforms_module: patch | ||
--- | ||
|
||
fix(es/modules): Allow TypeScript nodes for `Rewriter` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"$schema": "https://swc.rs/schema.json", | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true, | ||
"dynamicImport": true, | ||
"dts": true, | ||
"tsx": false | ||
}, | ||
"target": "es5", | ||
"baseUrl": "./", | ||
"preserveAllComments": false, | ||
"experimental": { | ||
"emitIsolatedDts": true | ||
}, | ||
"paths": { | ||
"@lib/*": [ | ||
"src/*" | ||
], | ||
"@tests/*": [ | ||
"tests/*" | ||
] | ||
}, | ||
"loose": false | ||
}, | ||
"module": { | ||
"type": "commonjs", | ||
"strict": true, | ||
"strictMode": true, | ||
"lazy": false, | ||
"noInterop": false | ||
}, | ||
"minify": false, | ||
"isModule": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type SafeResult<T> = { data: T; error: undefined } | { data: undefined; error: any }; | ||
|
||
export const safe = <T>(fn: () => T): SafeResult<T> => { | ||
try { | ||
const data = fn(); | ||
return { data, error: undefined }; | ||
} catch (error) { | ||
return { data: undefined, error }; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type SafeResult<T> = { | ||
data: T; | ||
error: undefined; | ||
} | { | ||
data: undefined; | ||
error: any; | ||
}; | ||
export declare const safe: <T>(fn: () => T) => SafeResult<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "safe", { | ||
enumerable: true, | ||
get: function() { | ||
return safe; | ||
} | ||
}); | ||
var safe = function(fn) { | ||
try { | ||
var data = fn(); | ||
return { | ||
data: data, | ||
error: undefined | ||
}; | ||
} catch (error) { | ||
return { | ||
data: undefined, | ||
error: error | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters