Lines Matching refs:ts
16 import ts from 'typescript';
38 export function getInitConstructor(members: ts.NodeArray<ts.Node>, parentComponentName: ts.Identifi…
39 ): ts.ConstructorDeclaration {
41 return ts.isConstructorDeclaration(item);
49 export function updateConstructor(ctorNode: ts.ConstructorDeclaration, para: ts.ParameterDeclaratio…
50 addStatements: ts.Statement[], isSuper: boolean = false, isAdd: boolean = false,
51 parentComponentName?: ts.Identifier): ts.ConstructorDeclaration {
52 let modifyPara: ts.ParameterDeclaration[];
59 let modifyBody: ts.Statement[];
71 let ctorPara: ts.ParameterDeclaration[] | ts.NodeArray<ts.ParameterDeclaration> =
76 ctorNode = ts.factory.updateConstructorDeclaration(ctorNode, ctorNode.decorators,
78 ts.factory.createBlock(modifyBody || ctorNode.body.statements, true));
83 function initConstructorParams(node: ts.ConstructorDeclaration, parentComponentName: ts.Identifier):
84 ts.ConstructorDeclaration {
85 if (!ts.isIdentifier(parentComponentName)) {
100 const newParameters: ts.ParameterDeclaration[] = Array.from(node.parameters);
106 newParameters.push(ts.factory.createParameterDeclaration(undefined, undefined, undefined,
107 ts.factory.createIdentifier(paramName), undefined, undefined,
109 …ts.factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, ts.factory.createNumericLiteral('…
110 ts.factory.createIdentifier(COMPONENT_IF_UNDEFINED) : undefined));
113 return ts.factory.updateConstructorDeclaration(node, undefined, node.modifiers, newParameters,
117 function addParamsType(ctorNode: ts.ConstructorDeclaration, modifyPara: ts.ParameterDeclaration[],
118 parentComponentName: ts.Identifier): ts.ParameterDeclaration[] {
119 const tsPara: ts.ParameterDeclaration[] | ts.NodeArray<ts.ParameterDeclaration> =
121 const newTSPara: ts.ParameterDeclaration[] = [];
123 let parameter: ts.ParameterDeclaration = item;
126 parameter = ts.factory.updateParameterDeclaration(item, item.decorators, item.modifiers,
128 ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), item.initializer);
131 parameter = ts.factory.createParameterDeclaration(item.decorators, item.modifiers,
133 ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(
138 parameter = ts.factory.updateParameterDeclaration(item, item.decorators, item.modifiers,
140 ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(
144 …parameter = ts.factory.createParameterDeclaration(item.decorators, item.modifiers, item.dotDotDotT…
145 …item.name, ts.factory.createToken(ts.SyntaxKind.QuestionToken), ts.factory.createTypeReferenceNode(
146 …ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_LOCALSTORAGE_TYPE_PU), undefined), item.initiali…
154 export function addConstructor(ctorNode: any, watchMap: Map<string, ts.Node>,
155 parentComponentName: ts.Identifier): ts.ConstructorDeclaration {
156 const watchStatements: ts.ExpressionStatement[] = [];
158 const watchNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(
159 ts.factory.createCallExpression(
160 ts.factory.createPropertyAccessExpression(
161 ts.factory.createThis(),
162 ts.factory.createIdentifier(COMPONENT_WATCH_FUNCTION)
166 ts.factory.createStringLiteral(key),
167 ts.isStringLiteral(value) ?
168 ts.factory.createPropertyAccessExpression(ts.factory.createThis(),
169 ts.factory.createIdentifier(value.text)) : value as ts.PropertyAccessExpression
174 const callSuperStatement: ts.Statement = createCallSuperStatement();
175 const updateWithValueParamsStatement: ts.Statement = createUPdWithValStatement();
180 function createCallSuperStatement(): ts.Statement {
182 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
183 ts.factory.createSuper(), undefined,
184 [ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_ID),
185 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
186 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_LOCALSTORAGE)]));
188 return ts.factory.createExpressionStatement(
189 ts.factory.createCallExpression(ts.factory.createSuper(), undefined,
190 [ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
191 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_LOCALSTORAGE_PU),
192 ts.factory.createIdentifier(ELMTID)]));
196 function createUPdWithValStatement(): ts.Statement {
197 return ts.factory.createExpressionStatement(
198 ts.factory.createCallExpression(
199 ts.factory.createPropertyAccessExpression(
200 ts.factory.createThis(),
201 ts.factory.createIdentifier(
207 [ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARAMS)]