Socket
Socket
Sign inDemoInstall

flow2ts

Package Overview
Dependencies
88
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.3.0

20

dist/index.es.js

@@ -1,2 +0,2 @@

import { tsTypeParameter, tsAnyKeyword, tsArrayType, tsBooleanKeyword, tsLiteralType, tsNullKeyword, tsFunctionType, tsTypeOperator, tsIndexedAccessType, tsTypeReference, tsTypeParameterInstantiation, tsIntersectionType, tsTypeLiteral, tsNeverKeyword, tsUnionType, tsNumberKeyword, tsStringKeyword, tsThisType, tsTupleType, tsVoidKeyword, tsTypeParameterDeclaration, identifier, tsTypeAnnotation, restElement, isIdentifier, stringLiteral, isFunctionTypeAnnotation, tsMethodSignature, tsPropertySignature, isObjectTypeProperty, tsCallSignatureDeclaration, isNumberTypeAnnotation, tsIndexSignature, tsQualifiedName, isAnyTypeAnnotation, isArrayTypeAnnotation, isBooleanTypeAnnotation, isBooleanLiteralTypeAnnotation, booleanLiteral, isNullLiteralTypeAnnotation, isExistsTypeAnnotation, isGenericTypeAnnotation, isTSUnionType, isTSIntersectionType, isTSTypeLiteral, isTSTupleType, isQualifiedTypeIdentifier, isInterfaceTypeAnnotation, isIntersectionTypeAnnotation, isMixedTypeAnnotation, isEmptyTypeAnnotation, isNullableTypeAnnotation, isNumberLiteralTypeAnnotation, numericLiteral, isObjectTypeAnnotation, isObjectTypeSpreadProperty, isStringLiteralTypeAnnotation, isStringTypeAnnotation, isThisTypeAnnotation, isTupleTypeAnnotation, isTypeofTypeAnnotation, isUnionTypeAnnotation, isVoidTypeAnnotation, tsExpressionWithTypeArguments, tsInterfaceBody, tsInterfaceDeclaration, isImportDefaultSpecifier, importSpecifier, importDeclaration, tsTypeAliasDeclaration, tsAsExpression, classProperty, classMethod, isClassDeclaration, exportNamedDeclaration } from '@babel/types';
import { tsTypeParameter, tsAnyKeyword, tsArrayType, tsBooleanKeyword, tsLiteralType, tsUndefinedKeyword, tsParenthesizedType, tsTypeOperator, tsIndexedAccessType, tsTypeReference, tsTypeParameterInstantiation, tsIntersectionType, tsTypeLiteral, tsNeverKeyword, tsUnionType, tsNumberKeyword, tsStringKeyword, tsThisType, tsTupleType, tsVoidKeyword, tsTypeParameterDeclaration, identifier, tsTypeAnnotation, restElement, isIdentifier, stringLiteral, isFunctionTypeAnnotation, tsMethodSignature, tsPropertySignature, isObjectTypeProperty, tsCallSignatureDeclaration, isNumberTypeAnnotation, tsIndexSignature, tsQualifiedName, isAnyTypeAnnotation, isArrayTypeAnnotation, isBooleanTypeAnnotation, isBooleanLiteralTypeAnnotation, booleanLiteral, isNullLiteralTypeAnnotation, isExistsTypeAnnotation, tsFunctionType, isGenericTypeAnnotation, isTSUnionType, isTSIntersectionType, isTSTypeLiteral, isTSTupleType, isQualifiedTypeIdentifier, isInterfaceTypeAnnotation, isIntersectionTypeAnnotation, isMixedTypeAnnotation, isEmptyTypeAnnotation, isNullableTypeAnnotation, isNumberLiteralTypeAnnotation, numericLiteral, isObjectTypeAnnotation, isObjectTypeSpreadProperty, isStringLiteralTypeAnnotation, isStringTypeAnnotation, isThisTypeAnnotation, isTupleTypeAnnotation, isTypeofTypeAnnotation, isUnionTypeAnnotation, isVoidTypeAnnotation, tsExpressionWithTypeArguments, tsInterfaceBody, tsInterfaceDeclaration, isImportDefaultSpecifier, importSpecifier, importDeclaration, tsTypeAliasDeclaration, tsAsExpression, parenthesizedExpression, classProperty, classMethod, isClassDeclaration, exportNamedDeclaration } from '@babel/types';
import generate from '@babel/generator';

@@ -86,3 +86,4 @@ import { parse } from '@babel/parser';

const convertIndexer = (indexer) => {
const id = identifier(indexer.node.id.name);
const indexerID = indexer.node.id;
const id = identifier(indexerID == undefined ? 'key' : indexerID.name);
const type = isNumberTypeAnnotation(indexer.node.key) ? tsNumberKeyword() : tsStringKeyword();

@@ -114,3 +115,3 @@ id.typeAnnotation = tsTypeAnnotation(type);

if (isNodePath(isNullLiteralTypeAnnotation)(path)) {
return tsNullKeyword();
return tsUndefinedKeyword();
}

@@ -123,3 +124,3 @@ if (isNodePath(isExistsTypeAnnotation)(path)) {

func.parameters = convertParameters(path);
return func;
return tsParenthesizedType(func);
}

@@ -171,2 +172,5 @@ if (isNodePath(isGenericTypeAnnotation)(path)) {

}
else if (id.name === 'Object') {
return tsAnyKeyword();
}
return tsTypeReference(identifier(id.name), tsTypeParameters);

@@ -188,3 +192,3 @@ }

if (isNodePath(isNullableTypeAnnotation)(path)) {
return tsUnionType([convertFlowType(path.get('typeAnnotation')), tsNullKeyword()]);
return tsUnionType([convertFlowType(path.get('typeAnnotation')), tsUndefinedKeyword()]);
}

@@ -232,3 +236,3 @@ if (isNodePath(isNumberLiteralTypeAnnotation)(path)) {

if (isNodePath(isUnionTypeAnnotation)(path)) {
return tsUnionType(path.node.types.map((_, idx) => convertFlowType(path.get(`types.${idx}`))));
return tsParenthesizedType(tsUnionType(path.node.types.map((_, idx) => convertFlowType(path.get(`types.${idx}`)))));
}

@@ -318,3 +322,3 @@ if (isNodePath(isVoidTypeAnnotation)(path)) {

TypeCastExpression(path) {
path.replaceWith(tsAsExpression(path.node.expression, convertFlowType(path.get('typeAnnotation').get('typeAnnotation'))));
path.replaceWith(tsAsExpression(parenthesizedExpression(path.node.expression), convertFlowType(path.get('typeAnnotation').get('typeAnnotation'))));
},

@@ -418,3 +422,3 @@ TypeParameterDeclaration(path) {

}
}
},
};

@@ -421,0 +425,0 @@

18

dist/index.js

@@ -92,3 +92,4 @@ 'use strict';

const convertIndexer = (indexer) => {
const id = t.identifier(indexer.node.id.name);
const indexerID = indexer.node.id;
const id = t.identifier(indexerID == undefined ? 'key' : indexerID.name);
const type = t.isNumberTypeAnnotation(indexer.node.key) ? t.tsNumberKeyword() : t.tsStringKeyword();

@@ -120,3 +121,3 @@ id.typeAnnotation = t.tsTypeAnnotation(type);

if (isNodePath(t.isNullLiteralTypeAnnotation)(path$$1)) {
return t.tsNullKeyword();
return t.tsUndefinedKeyword();
}

@@ -129,3 +130,3 @@ if (isNodePath(t.isExistsTypeAnnotation)(path$$1)) {

func.parameters = convertParameters(path$$1);
return func;
return t.tsParenthesizedType(func);
}

@@ -177,2 +178,5 @@ if (isNodePath(t.isGenericTypeAnnotation)(path$$1)) {

}
else if (id.name === 'Object') {
return t.tsAnyKeyword();
}
return t.tsTypeReference(t.identifier(id.name), tsTypeParameters);

@@ -194,3 +198,3 @@ }

if (isNodePath(t.isNullableTypeAnnotation)(path$$1)) {
return t.tsUnionType([convertFlowType(path$$1.get('typeAnnotation')), t.tsNullKeyword()]);
return t.tsUnionType([convertFlowType(path$$1.get('typeAnnotation')), t.tsUndefinedKeyword()]);
}

@@ -238,3 +242,3 @@ if (isNodePath(t.isNumberLiteralTypeAnnotation)(path$$1)) {

if (isNodePath(t.isUnionTypeAnnotation)(path$$1)) {
return t.tsUnionType(path$$1.node.types.map((_, idx) => convertFlowType(path$$1.get(`types.${idx}`))));
return t.tsParenthesizedType(t.tsUnionType(path$$1.node.types.map((_, idx) => convertFlowType(path$$1.get(`types.${idx}`)))));
}

@@ -324,3 +328,3 @@ if (isNodePath(t.isVoidTypeAnnotation)(path$$1)) {

TypeCastExpression(path$$1) {
path$$1.replaceWith(t.tsAsExpression(path$$1.node.expression, convertFlowType(path$$1.get('typeAnnotation').get('typeAnnotation'))));
path$$1.replaceWith(t.tsAsExpression(t.parenthesizedExpression(path$$1.node.expression), convertFlowType(path$$1.get('typeAnnotation').get('typeAnnotation'))));
},

@@ -424,3 +428,3 @@ TypeParameterDeclaration(path$$1) {

}
}
},
};

@@ -427,0 +431,0 @@

{
"name": "flow2ts",
"version": "1.2.1",
"version": "1.3.0",
"keywords": [

@@ -5,0 +5,0 @@ "flow",

@@ -147,3 +147,4 @@ import { NodePath } from '@babel/traverse';

const convertIndexer = (indexer: NodePath<t.ObjectTypeIndexer>) => {
const id = t.identifier(indexer.node.id!.name);
const indexerID = indexer.node.id;
const id = t.identifier(indexerID == undefined ? 'key' : indexerID.name);
const type = t.isNumberTypeAnnotation(indexer.node.key) ? t.tsNumberKeyword() : t.tsStringKeyword();

@@ -199,3 +200,3 @@ id.typeAnnotation = t.tsTypeAnnotation(type);

if (isNodePath(t.isNullLiteralTypeAnnotation)(path)) {
return t.tsNullKeyword();
return t.tsUndefinedKeyword();
}

@@ -213,3 +214,3 @@

func.parameters = convertParameters(path);
return func;
return t.tsParenthesizedType(func);
}

@@ -260,2 +261,4 @@

);
} else if (id.name === 'Object') {
return t.tsAnyKeyword();
}

@@ -284,3 +287,3 @@

if (isNodePath(t.isNullableTypeAnnotation)(path)) {
return t.tsUnionType([convertFlowType(path.get('typeAnnotation')), t.tsNullKeyword()]);
return t.tsUnionType([convertFlowType(path.get('typeAnnotation')), t.tsUndefinedKeyword()]);
}

@@ -340,3 +343,3 @@

if (isNodePath(t.isUnionTypeAnnotation)(path)) {
return t.tsUnionType(path.node.types.map((_, idx) => convertFlowType(path.get(`types.${idx}`))));
return t.tsParenthesizedType(t.tsUnionType(path.node.types.map((_, idx) => convertFlowType(path.get(`types.${idx}`)))));
}

@@ -468,3 +471,3 @@

t.tsAsExpression(
path.node.expression,
t.parenthesizedExpression(path.node.expression),
convertFlowType(path.get('typeAnnotation').get('typeAnnotation')),

@@ -471,0 +474,0 @@ ),

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc