-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support declared ts class members, remove extra export in strip…
…Types mode
- Loading branch information
1 parent
cceab7d
commit 7d5dab4
Showing
14 changed files
with
185 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@marko/compiler": patch | ||
"marko": patch | ||
"@marko/translator-default": patch | ||
--- | ||
|
||
Avoid adding `export {}` (from "@babel/plugin-transform-typescript") when outputing a template with the types stripped. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@marko/compiler": patch | ||
"marko": patch | ||
"@marko/translator-default": patch | ||
--- | ||
|
||
Avoid outputing a `declare`'d type on a `class`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/translator-default/test/fixtures/declared-class-member/snapshots/cjs-expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
|
||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _index = require("marko/src/runtime/html/index.js"); | ||
var _renderer = _interopRequireDefault(require("marko/src/runtime/components/renderer.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
const _marko_componentType = "packages/translator-default/test/fixtures/declared-class-member/template.marko", | ||
_marko_template = (0, _index.t)(_marko_componentType); | ||
var _default = _marko_template; | ||
exports.default = _default; | ||
class MyClass { | ||
constructor() { | ||
_defineProperty(this, "y", 2); | ||
} | ||
} | ||
const _marko_component = { | ||
onCreate() { | ||
this.y = 2 | ||
} | ||
}; | ||
_marko_template._ = (0, _renderer.default)(function (input, out, _componentDef, _component, state, $global) {}, { | ||
t: _marko_componentType, | ||
d: true | ||
}, _marko_component); |
4 changes: 4 additions & 0 deletions
4
...translator-default/test/fixtures/declared-class-member/snapshots/generated-expected.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class { | ||
declare x: string; | ||
y = 2; | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/translator-default/test/fixtures/declared-class-member/snapshots/html-expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
import { t as _t } from "marko/src/runtime/html/index.js"; | ||
const _marko_componentType = "packages/translator-default/test/fixtures/declared-class-member/template.marko", | ||
_marko_template = _t(_marko_componentType); | ||
export default _marko_template; | ||
class MyClass { | ||
constructor() { | ||
_defineProperty(this, "y", 2); | ||
} | ||
} | ||
import _marko_renderer from "marko/src/runtime/components/renderer.js"; | ||
const _marko_component = { | ||
onCreate() { | ||
this.y = 2 | ||
} | ||
}; | ||
_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) {}, { | ||
t: _marko_componentType, | ||
d: true | ||
}, _marko_component); |
21 changes: 21 additions & 0 deletions
21
...anslator-default/test/fixtures/declared-class-member/snapshots/htmlProduction-expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
import { t as _t } from "marko/dist/runtime/html/index.js"; | ||
const _marko_componentType = "xmfoovwT", | ||
_marko_template = _t(_marko_componentType); | ||
export default _marko_template; | ||
class MyClass { | ||
constructor() { | ||
_defineProperty(this, "y", 2); | ||
} | ||
} | ||
import _marko_renderer from "marko/dist/runtime/components/renderer.js"; | ||
const _marko_component = { | ||
onCreate() { | ||
this.y = 2 | ||
} | ||
}; | ||
_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) {}, { | ||
t: _marko_componentType | ||
}, _marko_component); |
3 changes: 3 additions & 0 deletions
3
...ages/translator-default/test/fixtures/declared-class-member/snapshots/hydrate-expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { init } from "marko/src/runtime/components/index.js"; | ||
import "./template.marko"; | ||
init(); |
26 changes: 26 additions & 0 deletions
26
packages/translator-default/test/fixtures/declared-class-member/snapshots/vdom-expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
import { t as _t } from "marko/src/runtime/vdom/index.js"; | ||
const _marko_componentType = "packages/translator-default/test/fixtures/declared-class-member/template.marko", | ||
_marko_template = _t(_marko_componentType); | ||
export default _marko_template; | ||
class MyClass { | ||
constructor() { | ||
_defineProperty(this, "y", 2); | ||
} | ||
} | ||
import _marko_renderer from "marko/src/runtime/components/renderer.js"; | ||
import { r as _marko_registerComponent } from "marko/src/runtime/components/registry"; | ||
_marko_registerComponent(_marko_componentType, () => _marko_template); | ||
const _marko_component = { | ||
onCreate() { | ||
this.y = 2 | ||
} | ||
}; | ||
_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) {}, { | ||
t: _marko_componentType, | ||
d: true | ||
}, _marko_component); | ||
import _marko_defineComponent from "marko/src/runtime/components/defineComponent.js"; | ||
_marko_template.Component = _marko_defineComponent(_marko_component, _marko_template._); |
25 changes: 25 additions & 0 deletions
25
...anslator-default/test/fixtures/declared-class-member/snapshots/vdomProduction-expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
import { t as _t } from "marko/dist/runtime/vdom/index.js"; | ||
const _marko_componentType = "xmfoovwT", | ||
_marko_template = _t(_marko_componentType); | ||
export default _marko_template; | ||
class MyClass { | ||
constructor() { | ||
_defineProperty(this, "y", 2); | ||
} | ||
} | ||
import _marko_renderer from "marko/dist/runtime/components/renderer.js"; | ||
import { r as _marko_registerComponent } from "marko/dist/runtime/components/registry"; | ||
_marko_registerComponent(_marko_componentType, () => _marko_template); | ||
const _marko_component = { | ||
onCreate() { | ||
this.y = 2 | ||
} | ||
}; | ||
_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) {}, { | ||
t: _marko_componentType | ||
}, _marko_component); | ||
import _marko_defineComponent from "marko/dist/runtime/components/defineComponent.js"; | ||
_marko_template.Component = _marko_defineComponent(_marko_component, _marko_template._); |
9 changes: 9 additions & 0 deletions
9
packages/translator-default/test/fixtures/declared-class-member/template.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class { | ||
declare x: string; | ||
y = 2; | ||
} | ||
|
||
static class MyClass { | ||
declare x: string; | ||
y = 2; | ||
} |