npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

greybel-type-analyzer

v1.1.3

Published

[![greybel-type-analyzer](https://circleci.com/gh/ayecue/greybel-type-analyzer.svg?style=svg)](https://circleci.com/gh/ayecue/greybel-type-analyzer)

Readme

greybel-type-analyzer

greybel-type-analyzer

A static type analyzer for Greybel/MiniScript that provides comprehensive type inference, symbol resolution, and code intelligence features. This package performs static code analysis to determine variable types, function signatures, and object properties, enabling advanced IDE features like autocompletion, type checking, and refactoring.

Features

  • Type Inference: Automatically infers types for variables, functions, and complex expressions
  • Symbol Resolution: Resolves identifiers across scopes and namespaces
  • JSDoc Support: Parses JSDoc-style comments for enhanced type information
  • Document Merging: Combines multiple code documents for cross-file analysis
  • Completion Support: Provides autocompletion data for IDE integration
  • Union Types: Handles variables with multiple possible types
  • Custom Types: Supports user-defined types and inheritance via __isa

Installation

npm install greybel-type-analyzer

Basic Usage

import { TypeManager } from 'greybel-type-analyzer';
import { miniscriptMeta } from 'miniscript-meta';
import { Parser } from 'greybel-core';

const typeManager = new TypeManager({
  container: miniscriptMeta
});

const code = `
  myVar = "hello"
  myNumber = 123
  myMap = { "key": "value" }
`;

const parser = new Parser(code, { unsafe: true });
const chunk = parser.parseChunk();
const document = typeManager.analyze('main.gs', chunk);

// Get all global properties
const globals = document.globals.getAllProperties();
console.log(`Found ${globals.length} global identifiers`);

// Get type of specific variable
const myVarType = document.globals.getProperty('myVar').type;
console.log(`myVar type: ${myVarType.id}`); // "string"

Advanced Features

Type Annotations with JSDoc

const code = `
  // @param {string} name - User name
  // @param {number} age - User age  
  // @return {map} User object
  createUser = function(name, age)
    return { "name": name, "age": age }
  end function
`;

const document = typeManager.analyze('users.gs', code);
const func = document.globals.getProperty('createUser').type;
const signature = func.signature;

console.log(signature.getArguments()); // Gets parameter info
console.log(signature.getReturns());   // Gets return type info

Document Merging

// Analyze multiple files and merge for cross-file type resolution
const doc1 = typeManager.analyze('utils.gs', utilsCode);
const doc2 = typeManager.analyze('main.gs', mainCode);

const mergedDoc = doc2.merge({ document: doc1 });
// Now main.gs can see types from utils.gs

Symbol Resolution

// Resolve symbol at specific code position
const line = document.chunk.lines[5][0]; // Get AST node
const result = document.resolveNamespace(line, false);
console.log(result.item.id); // Type of symbol at that position

API Reference

Core Classes

  • TypeManager: Main entry point for type analysis
  • IDocument: Represents analyzed document with type information
  • IScope: Represents variable scope (global, function, etc.)
  • IType: Base interface for all type information

Type System

The analyzer supports these type kinds:

  • string, number, list, map - Basic types
  • function - Function types with signatures
  • union - Variables that can be multiple types
  • unknown - For unresolved or dynamic types
  • Custom types defined via JSDoc @type annotations

Compatible ASTs

This package works with AST output from: