fix: strip types from inline component class

This commit is contained in:
Dylan Piercey 2023-04-20 08:45:27 -07:00 committed by Dylan Piercey
parent 3ad4ebc86b
commit 04d6fad6d5
2 changed files with 16 additions and 2 deletions

View File

@ -0,0 +1,7 @@
---
"@marko/compiler": patch
"marko": patch
"@marko/translator-default": patch
---
Fix issue where types were not being stripped from the inline Marko component class.

View File

@ -118,6 +118,12 @@ export default (api, markoOpts) => {
visitor:
markoOpts.stripTypes && isMarkoOutput(markoOpts.output)
? {
MarkoClass(path) {
// We replace the MarkoClass with a regular class declaration so babel can strip it's types.
path.replaceWith(
t.classDeclaration(t.identifier(""), null, path.node.body)
);
},
ExportNamedDeclaration: {
exit(path) {
// The babel typescript plugin will add an empty export declaration
@ -159,8 +165,9 @@ export function getMarkoFile(code, fileOpts, markoOpts) {
let mtime = Infinity;
try {
mtime = markoOpts.fileSystem.statSync(watchFile).mtime;
// eslint-disable-next-line no-empty
} catch {}
} catch {
// ignore
}
if (mtime > cached.time) {
// Some dependency changed, invalidate the cache.