Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (outputs.length === 0){
return []
} else if (outputs.length === 1) {
// original return value.
return [getTsTypeFromSolidityType(outputs[0], true)]
} else {
// multiple return values: return an object.
const propSigs: PropertySignature[] = [];
for (let index = 0; index < outputs.length; index++){
const output = outputs[index];
const type = getTsTypeFromSolidityType(output as AbiInput, true);
if (output.name) {
// name exists for the output: create a key for that
const nameSig = ts.createPropertySignature(
undefined,
ts.createStringLiteral(output.name),
undefined,
type,
undefined
);
propSigs.push(nameSig);
}
// always create a key for the index.
const indexSig = ts.createPropertySignature(
undefined,
ts.createNumericLiteral(index.toString()),
undefined,
type,
undefined
);
propSigs.push(indexSig);
}
function addFileNameConst(
sourceFile: ts.SourceFile,
jsxFileNameIdentifier: ts.Identifier,
fileName: string
): ts.SourceFile {
const variableDecls = [
ts.createVariableDeclaration(jsxFileNameIdentifier, undefined /* type */, ts.createStringLiteral(fileName))
];
return insertStatementAfterImports(
sourceFile,
ts.createVariableStatement(
undefined /* modifiers */,
ts.createVariableDeclarationList(variableDecls, ts.NodeFlags.Const)
)
);
}
const createStyleLiteral = (cmp: d.ComponentCompilerMeta, style: d.StyleCompiler) => {
if (cmp.encapsulation === 'scoped') {
// scope the css first
const scopeId = getScopeId(cmp.tagName, style.modeName);
return ts.createStringLiteral(
scopeCss(style.styleStr, scopeId, false)
);
}
return ts.createStringLiteral(style.styleStr);
};
const visit: ts.Visitor = node => {
if (webWorkers && ts.isNewExpression(node)) {
const newText = node.expression.getText();
if (newText === 'Worker' || newText === 'SharedWorker') {
if (node.arguments.length === 1) {
const firstArg = node.arguments[0];
const statement = firstArg['text'];
// map item
const item = webWorkers.find(item => {
return item.path === statement && item.type === newText;
});
if (item) {
return ts.createNew(ts.createIdentifier(newText), undefined, [ts.createStringLiteral(item.bundlePath)]);
}
}
}
}
if (isRequireCall(node)) {
const text = node['arguments'][0].text;
const target = pm.findDependantModule(text);
if (!target) {
if (config.target !== 'electron' && config.target !== 'server') {
if (!props.flow.ctx.config.shoudIgnorePackage(text)) {
// if (log.props.ignoreStatementErrors && log.props.ignoreStatementErrors.includes(text)) {
// return;
// }
log.error('Problem when resolving require "$text" in $file', {
text: text,
([headerName, header]) =>
ts.createPropertyAssignment(
ts.createStringLiteral(header.headerFieldName),
ts.createIdentifier(headerName)
)
)
function booleanValidator(parameter: ts.Expression): ts.Expression {
return ts.createStrictEquality(
ts.createTypeOf(parameter),
ts.createStringLiteral("boolean")
);
}
function visitBooleanKeyword(node: ts.TypeNode, accessor: ts.Expression, visitorContext: VisitorContext) {
return ts.createStrictEquality(ts.createTypeOf(accessor), ts.createStringLiteral('boolean'));
}
const decorators = node.decorators.map(decorator => {
if (decoratorNamed(decorator, Decorators.RootComponent)) {
const metadatum = metadata.components.find(component => component.classname === node.name.text)
const shadowExp = getExpressionFromDecorator(decorator, 'shadow')
const styleUrl = getExpressionFromDecorator(decorator, 'styleUrl')
const options = [
ts.createPropertyAssignment('tag', ts.createStringLiteral(metadatum.finalTagName)),
ts.createPropertyAssignment('shadow', shadowExp || ts.createTrue())
]
if (styleUrl) {
options.push(ts.createPropertyAssignment('styleUrl', ts.createStringLiteral(styleUrl.text)))
}
return ts.updateDecorator(
decorator,
ts.createCall(ts.createIdentifier(Decorators.Component), undefined, [
ts.createObjectLiteral(options, true)
])
)
}
return decorator
})
function visitString(type: ts.Type, accessor: ts.Expression, visitorContext: VisitorContext) {
if (visitorContext.mode.type === 'type-check') {
return ts.createStrictEquality(ts.createTypeOf(accessor), ts.createStringLiteral('string'));
} else {
throw new Error('visitString should only be called during type-check mode.');
}
}
function visitStringKeyword(node: ts.TypeNode, accessor: ts.Expression, visitorContext: VisitorContext) {
return ts.createStrictEquality(ts.createTypeOf(accessor), ts.createStringLiteral('string'));
}