mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: TypeScript 4.8+ support and NativeClass decorator improvements (#10081)
This commit is contained in:
@@ -8,8 +8,9 @@ import ts from 'typescript';
|
||||
export default function (ctx: ts.TransformationContext) {
|
||||
function isNativeClassExtension(node: ts.ClassDeclaration) {
|
||||
return (
|
||||
node.decorators &&
|
||||
node.decorators.filter((d) => {
|
||||
ts.canHaveDecorators(node) &&
|
||||
ts.getDecorators(node) &&
|
||||
ts.getDecorators(node).filter((d) => {
|
||||
const fullText = d.getFullText().trim();
|
||||
return fullText.indexOf('@NativeClass') > -1;
|
||||
}).length > 0
|
||||
@@ -24,14 +25,14 @@ export default function (ctx: ts.TransformationContext) {
|
||||
|
||||
function createHelper(node: ts.Node) {
|
||||
// we remove the decorator for now!
|
||||
return ts.createIdentifier(
|
||||
return ts.factory.createIdentifier(
|
||||
ts
|
||||
.transpileModule(
|
||||
node.getText().replace(/@NativeClass(\((.|\n)*?\))?/gm, ''),
|
||||
{
|
||||
compilerOptions: {
|
||||
noEmitHelpers: true,
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
module: ts.ModuleKind.ESNext,
|
||||
target: ts.ScriptTarget.ES5,
|
||||
},
|
||||
}
|
||||
@@ -44,7 +45,7 @@ export default function (ctx: ts.TransformationContext) {
|
||||
}
|
||||
|
||||
return (source: ts.SourceFile) =>
|
||||
ts.updateSourceFileNode(
|
||||
ts.factory.updateSourceFile(
|
||||
source,
|
||||
ts.visitNodes(source.statements, visitNode)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user