{"id":17445992,"url":"https://github.com/jamen/typling-core","last_synced_at":"2025-10-25T08:37:25.654Z","repository":{"id":57383150,"uuid":"75323740","full_name":"jamen/typling-core","owner":"jamen","description":"Check typlings on Esprima-style AST","archived":false,"fork":false,"pushed_at":"2017-01-06T14:18:11.000Z","size":65,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T20:53:34.217Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamen.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-01T19:08:07.000Z","updated_at":"2023-02-19T08:59:19.000Z","dependencies_parsed_at":"2022-09-26T19:52:34.561Z","dependency_job_id":null,"html_url":"https://github.com/jamen/typling-core","commit_stats":null,"previous_names":["jamen/type-analyze"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftypling-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftypling-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftypling-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftypling-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamen","download_url":"https://codeload.github.com/jamen/typling-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246802594,"owners_count":20836365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-17T18:19:51.425Z","updated_at":"2025-10-25T08:37:20.621Z","avatar_url":"https://github.com/jamen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typling-core\n\n\u003e Check typlings on Esprima-style AST\n\nThis is for using typling as a module.  See [`typling`](https://github.com/jamen/typling) for using as a tool.\n\n```js\nvar esprima = require('esprima')\nvar typling = require('typling-core')\n\nvar source = esprima.parse(\n  `//@ Number, Number -\u003e Number\n   function foo (x, y) {\n     return x + y\n   }\n\n   foo(123, 'hello world')`,\n   { attachComment: true, loc: true }\n )\n\nvar result = typling.check(source)\n\nconsole.log(result.report)\nconsole.log(result.source)\n// ...\n```\n\nThere are 3 functions you can use with `typling`:\n\n - `check(source, options?)`: Create context and generate reports. (`create` and `verify` combined)\n - `create(source, options?)`: Create context with typlings, definitions, source, and no reports.\n - `verify(context)`: Generate reports on the context.\n\n**Notice:** Nodes must have comments attached, and optionally locations for line/column in reports.  Use `{ attachComment: true, loc: true }` with `esprima`, or similar in others.\n\n## Installation\n\n```sh\n$ npm install --save typling-core\n```\n\n## Usage\n\n### `typling.check(source, options?)`\n\nType check the node, and return a context object with all the results.\n\n- `source` ([estree `Node`](https://github.com/estree/estree/blob/master/es5.md#node-objects)): A Node (preferably [`Program`](https://github.com/estree/estree/blob/master/es5.md#programs)) created from any ESTree-compatible parser.\n- `options` (`Object`): Options object for creating context.  Optional.\n- `options.definitions` (`Object`): An object mapping type names (e.g. `String`, `Number`) to a type definition. Has [built-in definitions](lib/defs/)\n- `options.typlings` (`Array`): Preloading typlings.  Typlings from the node are added in.\n\n```js\n// Create context and generate reports:\nvar result = typling.check(node)\n\n// Result is context object:\nconsole.log(result.report)\nconsole.log(result.source)\n```\n\nThis is `typling.create` and `typling.verify` turned into one step if you want simple type checker.\n\n### `typling.create(source, options?)`\n\nCreate a context object.  Contains `definitions`, `typlings`, `source`, `report`.  Same options as `typling.check`\n\n```js\n// Create context (generates typlings):\nvar context = typling.create(node)\n\n// Has necessary props, with no report\nconsole.log(context.typlings)\nconsole.log(context.definitions)\n// ...\n```\n\n**Note:** `report` will be empty until you use `typling.verify` or use `typling.check` instead.\n\n### `typling.verify(context)`\n\nVerify a context from `typling.create`. Creates objects on `report`, otherwise empty.\n\n```js\n// Create context, and cache typligns\nvar context = typling.create(node)\nvar typlings = context.typlings\n\n// Verify context\ntypling.verify(context)\n\n// Log any reports:\nconsole.log(context.reports)\n```\n\n### `typling.signature(signature, [associate])`\n\nParse a strip into a signature.  `null` is turned into `*`.  The optional `associate` parameter is a node or string.\n\n```js\ntypling.signature('Number, Number -\u003e String')\n// =\u003e [['Number', 'Number'], 'Number']\n\ntypling.signature('Number, *, String -\u003e *')\n// =\u003e [['Number', null, 'String'], null]\n\ntypling.signature('String -\u003e String', { foo: 123 })\n// =\u003e [['String'], 'String', { foo: 123 }]\n```\n\n## License\n\nMIT © [Jamen Marz](https://git.io/jamen)\n\n---\n\n[![version](https://img.shields.io/npm/v/typling-core.svg?style=flat-square)][package] [![travis](https://img.shields.io/travis/jamen/typling-core.svg?style=flat-square)](https://travis-ci.org/jamen/typling-core) [![downloads](https://img.shields.io/npm/dt/typling-core.svg?style=flat-square)][package] [![license](https://img.shields.io/npm/l/express.svg?style=flat-square)][package] [![follow](https://img.shields.io/github/followers/jamen.svg?style=social\u0026label=Follow)](https://github.com/jamen)\n\n[package]: https://npmjs.org/package/typling-core\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Ftypling-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamen%2Ftypling-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Ftypling-core/lists"}