Skip to content

npm versionPreview: help shape 1.0

Terminal window
npm install @typemf/core

Model-first

Define your model once and generate your TypeScript code from it.

Real model semantics

Opposites and containment stay consistent automatically. Cross-document references resolve through the resource set.

EMF-compatible

Reads and writes Ecore models and XMI documents in EMF’s formats.

Runs everywhere

Node, the browser and VS Code.

Define a model, generate TypeScript code from it, and load and save instances as XMI.

library.ecoreyour model, edited in VS Codetypemf-generate@typemf/generatorGenerated TypeScripttypes, impls, factoryYour application@typemf/core@typemf/xmiload and savelibrary.xmiyour instances

Generated from an Ecore model, with EMF semantics built in:

const factory = LibraryPackageImpl.eINSTANCE.getEFactoryInstance() as LibraryFactory;
const writer = factory.createWriter();
const book = factory.createBook();
book.setAuthor(writer);
writer.getBooks().size(); // 1, the opposite was updated
const city = factory.createLibrary();
const campus = factory.createLibrary();
city.getBooks().add(book);
campus.getBooks().add(book); // moves the book
city.getBooks().size(); // 0
(book.eContainer() as Library) === campus; // true

See Getting started for the full path from .ecore file to a saved XMI document.

Edit your .ecore models and model instances in VS Code, with a tree on the left and a property editor on the right.

The TypeMF Instance Editor showing the Library model: a tree of the library package and the properties of the writers reference.

TypeMF builds on ideas from TMF, a lightweight TypeScript take on EMF by Tripsnek that is built for JSON-based full-stack apps. TypeMF goes the other way: it aims to be EMF-compatible, as far as TypeScript allows, with the Ecore metamodel at runtime, dynamic objects without generated code, resources with URIs and cross-document references, change notifications, and XMI that follows EMF’s conventions. If you need a small, JSON-first library, look at TMF. If you need EMF’s reflective layer in TypeScript, use TypeMF.

TypeMF is a preview on the way to 1.0. Known limitations today:

  • EMap is not supported.
  • An XMI document must have exactly one root object. The <xmi:XMI> wrapper for several roots is not supported.

Missing something else? Open an issue and help shape 1.0.

TypeMF is created by Bernhard J. Berger, Hamburg University of Technology. It is one result of a Short-Term Scientific Mission (STSM) within the COST Action ROAR-NET (CA22137).

TypeMF is open source under the Apache-2.0 license. Find the code, report issues and contribute on GitHub.