mirror of
https://github.com/swc-project/swc.git
synced 2024-11-28 02:29:04 +03:00
43 lines
858 B
TypeScript
43 lines
858 B
TypeScript
// @allowJs: true
|
|
// @checkJs: true
|
|
// @moduleResolution: node
|
|
// @declaration: true
|
|
// @emitDeclarationOnly: true
|
|
// @filename: rectangle.js
|
|
class Rectangle {
|
|
constructor() {
|
|
console.log("I'm a rectangle!");
|
|
}
|
|
}
|
|
|
|
module.exports = { Rectangle };
|
|
// @filename: index.js
|
|
const {Rectangle} = require('./rectangle');
|
|
|
|
class Render {
|
|
constructor() {
|
|
/**
|
|
* Object list
|
|
* @type {Rectangle[]}
|
|
*/
|
|
this.objects = [];
|
|
}
|
|
/**
|
|
* Adds a rectangle
|
|
*
|
|
* @returns {Rectangle} the rect
|
|
*/
|
|
addRectangle() {
|
|
const obj = new Rectangle();
|
|
this.objects.push(obj);
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
module.exports = { Render };
|
|
// @filename: test.js
|
|
const {Render} = require("./index");
|
|
let render = new Render();
|
|
|
|
render.addRectangle();
|
|
console.log("Objects", render.objects); |