• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import {
17    global,
18    passNode,
19    passNodeArray,
20    unpackNonNullableNode,
21    unpackNode,
22    unpackNodeArray,
23    assertValidPeer,
24    AstNode,
25    Es2pandaAstNodeType,
26    KNativePointer,
27    nodeByType,
28    ArktsObject,
29    unpackString
30} from "../../reexport-for-generated"
31
32import { TypedAstNode } from "./TypedAstNode"
33import { Es2pandaTSSignatureDeclarationKind } from "./../Es2pandaEnums"
34import { FunctionSignature } from "./FunctionSignature"
35import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration"
36import { Expression } from "./Expression"
37import { TypeNode } from "./TypeNode"
38export class TSSignatureDeclaration extends TypedAstNode {
39     constructor(pointer: KNativePointer) {
40        assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_TS_SIGNATURE_DECLARATION)
41        super(pointer)
42
43    }
44    static createTSSignatureDeclaration(kind: Es2pandaTSSignatureDeclarationKind, signature?: FunctionSignature): TSSignatureDeclaration {
45        return new TSSignatureDeclaration(global.generatedEs2panda._CreateTSSignatureDeclaration(global.context, kind, passNode(signature)))
46    }
47    static updateTSSignatureDeclaration(original: TSSignatureDeclaration | undefined, kind: Es2pandaTSSignatureDeclarationKind, signature?: FunctionSignature): TSSignatureDeclaration {
48        return new TSSignatureDeclaration(global.generatedEs2panda._UpdateTSSignatureDeclaration(global.context, passNode(original), kind, passNode(signature)))
49    }
50    get typeParams(): TSTypeParameterDeclaration | undefined {
51        return unpackNode(global.generatedEs2panda._TSSignatureDeclarationTypeParamsConst(global.context, this.peer))
52    }
53    get params(): readonly Expression[] {
54        return unpackNodeArray(global.generatedEs2panda._TSSignatureDeclarationParamsConst(global.context, this.peer))
55    }
56    get returnTypeAnnotation(): TypeNode | undefined {
57        return unpackNode(global.generatedEs2panda._TSSignatureDeclarationReturnTypeAnnotationConst(global.context, this.peer))
58    }
59    get kind(): Es2pandaTSSignatureDeclarationKind {
60        return global.generatedEs2panda._TSSignatureDeclarationKindConst(global.context, this.peer)
61    }
62}
63export function isTSSignatureDeclaration(node: AstNode): node is TSSignatureDeclaration {
64    return node instanceof TSSignatureDeclaration
65}
66if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_SIGNATURE_DECLARATION)) {
67    nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_SIGNATURE_DECLARATION, TSSignatureDeclaration)
68}
69