Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hegel/core

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hegel/core - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

5

inference/function-type.js

@@ -627,2 +627,7 @@ "use strict";

if (genericArgument.isUserDefined) {
newGenericArguments.add(genericArgument);
continue;
}
const oldRoot = _type.Type.getTypeRoot(genericArgument);

@@ -629,0 +634,0 @@

2

package.json
{
"name": "@hegel/core",
"author": "Artem Kobzar",
"version": "0.0.22",
"version": "0.0.23",
"description": "",

@@ -6,0 +6,0 @@ "main": "./index.js",

@@ -777,3 +777,4 @@ "use strict";

if (!isTypeDefinitions && classScope.type === _variableScope.VariableScope.CLASS_TYPE) {
const fnScope = moduleScope.scopes.get(_variableScope.VariableScope.getName(currentNode)); // $FlowIssue
const fnScope = moduleScope.scopes.get(_variableScope.VariableScope.getName(currentNode));
fnScope.declaration = fn; // $FlowIssue

@@ -791,2 +792,22 @@ fnScope.body.set(_constants.THIS_TYPE, currentNode.static ? classScope.declaration : self);

if (propertyName === _constants.CONSTRUCTABLE) {
const type = fn.type instanceof _genericType.GenericType ? fn.type.subordinateType : fn.type;
const returnType = (type.returnType instanceof _objectType.ObjectType || type.returnType instanceof _collectionType.CollectionType) && _objectType.ObjectType.Object.isPrincipalTypeFor(type.returnType) ? type.returnType : self.type;
const fnName = `${String(self.type.name)} constructor`;
let constructorType = _functionType.FunctionType.term(fnName, {}, type.argumentsTypes, returnType);
const isConstructorGeneric = fn.type instanceof _genericType.GenericType;
if (self.type instanceof _bottomType.$BottomType) {
const genericArguments = [...new Set(self.type.genericArguments.concat(isConstructorGeneric ? fn.type.genericArguments.filter(a => a !== fn.type.subordinateType.returnType) : []))];
const localTypeScope = isConstructorGeneric ? fn.type.localTypeScope : self.type.subordinateMagicType.localTypeScope;
constructorType = _genericType.GenericType.new(fnName, {}, genericArguments, localTypeScope, constructorType);
} else if (isConstructorGeneric) {
constructorType = _genericType.GenericType.new(fnName, {}, fn.type.genericArguments, fn.type.localTypeScope, constructorType);
}
fn.type = constructorType;
}
if (moduleScope instanceof _moduleScope.PositionedModuleScope) {

@@ -793,0 +814,0 @@ moduleScope.addPosition(currentNode, fn);

@@ -326,53 +326,27 @@ "use strict";

if (existedConstructor) {
const fn = classScope.declaration.type.properties.get(_constants.CONSTRUCTABLE);
if (existedConstructor && !isTypeDefinitions) {
const constructorScope = typeGraph.scopes.get(_variableScope.VariableScope.getName(existedConstructor));
if (fn === undefined) {
throw new Error("Never!");
if (!(constructorScope instanceof _variableScope.VariableScope)) {
throw new Error("Never!!!");
}
const type = fn.type instanceof _genericType.GenericType ? fn.type.subordinateType : fn.type;
const returnType = (type.returnType instanceof _objectType.ObjectType || type.returnType instanceof _collectionType.CollectionType) && _objectType.ObjectType.Object.isPrincipalTypeFor(type.returnType) ? type.returnType : self.type;
const fnName = `${String(self.type.name)} constructor`;
let constructorType = _functionType.FunctionType.term(fnName, {}, type.argumentsTypes, returnType);
const isConstructorGeneric = fn.type instanceof _genericType.GenericType;
if (self.type instanceof _bottomType.$BottomType) {
const genericArguments = [...new Set(self.type.genericArguments.concat(isConstructorGeneric ? fn.type.genericArguments.filter(a => a !== fn.type.subordinateType.returnType) : []))];
const localTypeScope = isConstructorGeneric ? fn.type.localTypeScope : self.type.subordinateMagicType.localTypeScope;
constructorType = _genericType.GenericType.new(fnName, {}, genericArguments, localTypeScope, constructorType);
} else if (isConstructorGeneric) {
constructorType = _genericType.GenericType.new(fnName, {}, fn.type.genericArguments, fn.type.localTypeScope, constructorType);
if (constructorScope.calls.find(call => call.targetName === "return") === undefined) {
const callMeta = new _callMeta.CallMeta(new _functionType.FunctionType("", {}, [self.type], self.type), [self], // $FlowIssue
constructorScope.declaration.meta.loc, "return", false, true);
constructorScope.calls.push(callMeta);
}
fn.type = constructorType;
if (superType !== undefined) {
const superCallIndex = constructorScope.calls.findIndex(call => call.targetName === "super");
const thisCallIndex = constructorScope.calls.findIndex(call => call.targetName === "this");
if (!isTypeDefinitions) {
const constructorScope = typeGraph.scopes.get(_variableScope.VariableScope.getName(existedConstructor));
if (!(constructorScope instanceof _variableScope.VariableScope)) {
throw new Error("Never!!!");
if (superCallIndex === -1) {
throw new _errors2.default('Constructor must contain "super" call super inside', // $FlowIssue
constructorScope.declaration.meta.loc);
}
if (constructorScope.calls.find(call => call.targetName === "return") === undefined) {
const callMeta = new _callMeta.CallMeta(new _functionType.FunctionType("", {}, [self.type], self.type), [self], // $FlowIssue
constructorScope.declaration.meta.loc, "return", false, true);
constructorScope.calls.push(callMeta);
if (thisCallIndex !== -1 && superCallIndex > thisCallIndex) {
throw new _errors2.default('"super" must be called before accessing "this"', constructorScope.calls[thisCallIndex].loc);
}
if (superType !== undefined) {
const superCallIndex = constructorScope.calls.findIndex(call => call.targetName === "super");
const thisCallIndex = constructorScope.calls.findIndex(call => call.targetName === "this");
if (superCallIndex === -1) {
throw new _errors2.default('Constructor must contain "super" call super inside', // $FlowIssue
constructorScope.declaration.meta.loc);
}
if (thisCallIndex !== -1 && superCallIndex > thisCallIndex) {
throw new _errors2.default('"super" must be called before accessing "this"', constructorScope.calls[thisCallIndex].loc);
}
}
}

@@ -379,0 +353,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc