Configure typescript

This commit is contained in:
Paulo Gustavo Veiga 2021-12-29 09:51:04 -08:00
parent ef3984cfd0
commit 29f3e41fa3
4 changed files with 17 additions and 21 deletions

View File

@ -1,5 +1,5 @@
import Exporter from "src/components/export/Exporter";
import Mindmap from "src/components/model/Mindmap";
import Exporter from "./Exporter";
import Mindmap from "../model/Mindmap";
class TextExporter implements Exporter {

View File

@ -2,41 +2,36 @@ import { $assert } from '@wisemapping/core-js';
import IconModel from './IconModel';
import LinkModel from './LinkModel';
import NoteModel from './NoteModel';
import FeatureModel from './FeatureModel';
const FeatureModelFactory = {
Icon: {
class FeatureModelFactory {
private static modelById = [{
id: IconModel.FEATURE_TYPE,
model: IconModel,
},
Link: {
}, {
id: LinkModel.FEATURE_TYPE,
model: LinkModel,
},
/** the note object */
Note: {
}, {
id: NoteModel.FEATURE_TYPE,
model: NoteModel,
},
}] as const;
createModel(type, attributes) {
static createModel(type: string, attributes): FeatureModel {
$assert(type, 'type can not be null');
$assert(attributes, 'attributes can not be null');
const { model: Model } = FeatureModelFactory._featuresMetadataById
const { model: Model } = FeatureModelFactory.modelById
.filter((elem) => elem.id === type)[0];
return new Model(attributes);
},
}
/**
* @param id the feature metadata id
* @return {Boolean} returns true if the given id is contained in the metadata array
*/
isSupported(id) {
return FeatureModelFactory._featuresMetadataById.some((elem) => elem.id === id);
},
static isSupported(type: string): boolean {
return FeatureModelFactory.modelById.some((elem) => elem.id === type);
}
};
FeatureModelFactory._featuresMetadataById = [FeatureModelFactory.Icon, FeatureModelFactory.Link, FeatureModelFactory.Note];
export default FeatureModelFactory;

View File

@ -2,7 +2,7 @@ import TxtExporter from '../../src/components/export/TxtExporter';
import Mindmap from '../../src/components/model/Mindmap';
test('adds 1 + 2 to equal 3', () => {
const m = new Mindmap();
const m = new Mindmap(1);
const exporter = new TxtExporter();
console.log(exporter.export(m));

View File

@ -4,6 +4,7 @@
"sourceMap": true,
"noImplicitAny": false,
"module": "es6",
"moduleResolution": "Node",
"target": "es6",
"allowJs": true,
"esModuleInterop": true