-
-
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/parser): Fix context of dynamic import type (#9852)
**Related issue:** - Closes #9802
- Loading branch information
Showing
6 changed files
with
1,689 additions
and
1 deletion.
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_parser: patch | ||
--- | ||
|
||
fix(es/parser): Fix context of dynamic import type |
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,41 @@ | ||
import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; | ||
import typia from "typia"; | ||
export const parse = (() => { | ||
const __is = (input: any): input is number => "number" === typeof input; | ||
let errors: any; | ||
let _report: any; | ||
const __validate = (input: any): import("typia").IValidation<number> => { | ||
if (false === __is(input)) { | ||
errors = []; | ||
_report = (__typia_transform__validateReport._validateReport as any)( | ||
errors | ||
); | ||
((input: any, _path: string, _exceptionable: boolean = true) => | ||
"number" === typeof input || | ||
_report(true, { | ||
path: _path + "", | ||
expected: "number", | ||
value: input, | ||
}))(input, "$input", true); | ||
const success = 0 === errors.length; | ||
return success | ||
? { | ||
success, | ||
data: input, | ||
} | ||
: ({ | ||
success, | ||
errors, | ||
data: input, | ||
} as any); | ||
} | ||
return { | ||
success: true, | ||
data: input, | ||
} as any; | ||
}; | ||
return ( | ||
input: string | ||
): import("typia").IValidation<import("typia").Primitive<number>> => | ||
__validate(JSON.parse(input)) as any; | ||
})(); |
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,38 @@ | ||
import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; | ||
export var parse = function() { | ||
var __is = function(input) { | ||
return "number" === typeof input; | ||
}; | ||
var errors; | ||
var _report; | ||
var __validate = function(input) { | ||
if (false === __is(input)) { | ||
errors = []; | ||
_report = __typia_transform__validateReport._validateReport(errors); | ||
(function(input, _path) { | ||
var _exceptionable = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true; | ||
return "number" === typeof input || _report(true, { | ||
path: _path + "", | ||
expected: "number", | ||
value: input | ||
}); | ||
})(input, "$input", true); | ||
var success = 0 === errors.length; | ||
return success ? { | ||
success: success, | ||
data: input | ||
} : { | ||
success: success, | ||
errors: errors, | ||
data: input | ||
}; | ||
} | ||
return { | ||
success: true, | ||
data: input | ||
}; | ||
}; | ||
return function(input) { | ||
return __validate(JSON.parse(input)); | ||
}; | ||
}(); |
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
41 changes: 41 additions & 0 deletions
41
crates/swc_ecma_parser/tests/typescript/issue-9802/input.ts
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,41 @@ | ||
import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; | ||
import typia from "typia"; | ||
export const parse = (() => { | ||
const __is = (input: any): input is number => "number" === typeof input; | ||
let errors: any; | ||
let _report: any; | ||
const __validate = (input: any): import("typia").IValidation<number> => { | ||
if (false === __is(input)) { | ||
errors = []; | ||
_report = (__typia_transform__validateReport._validateReport as any)( | ||
errors | ||
); | ||
((input: any, _path: string, _exceptionable: boolean = true) => | ||
"number" === typeof input || | ||
_report(true, { | ||
path: _path + "", | ||
expected: "number", | ||
value: input, | ||
}))(input, "$input", true); | ||
const success = 0 === errors.length; | ||
return success | ||
? { | ||
success, | ||
data: input, | ||
} | ||
: ({ | ||
success, | ||
errors, | ||
data: input, | ||
} as any); | ||
} | ||
return { | ||
success: true, | ||
data: input, | ||
} as any; | ||
}; | ||
return ( | ||
input: string | ||
): import("typia").IValidation<import("typia").Primitive<number>> => | ||
__validate(JSON.parse(input)) as any; | ||
})(); |
Oops, something went wrong.