diff --git a/src/emitter.ts b/src/emitter.ts index c09cb16..4080309 100644 --- a/src/emitter.ts +++ b/src/emitter.ts @@ -757,7 +757,13 @@ export function emitFile( function emitPropertyDeclaration(node: ts.PropertyDeclaration) { // emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + if (node.modifiers) { + emitModifiers(node, node.modifiers); + } + else { + writeKeyword('public'); + writeSpace(); + } emit(node.name); // emit(node.questionToken); // emit(node.exclamationToken); @@ -784,6 +790,8 @@ export function emitFile( emitModifiers(node, node.modifiers); // emit(node.asteriskToken); if (ts.isClassDeclaration(node.parent)) { + writeKeyword("function"); + writeSpace(); emit(node.name); } else { @@ -802,6 +810,8 @@ export function emitFile( function emitConstructor(node: ts.ConstructorDeclaration) { // emitModifiers(node, node.modifiers); + writeKeyword("function"); + writeSpace(); writeKeyword("__construct"); emitSignatureAndBody(node, emitSignatureHead); } diff --git a/test/features/Alias.php b/test/features/Alias.php index c19fd3e..edf1177 100644 --- a/test/features/Alias.php +++ b/test/features/Alias.php @@ -1,5 +1,5 @@ title = $options["title"]; $this->publish(1); } - private publish($id) { + private function publish($id) { array_push(Article::$published, $id); parent::dispose(); } diff --git a/test/features/ComputedPropertyName.php b/test/features/ComputedPropertyName.php index cd06e2a..d67fb91 100644 --- a/test/features/ComputedPropertyName.php +++ b/test/features/ComputedPropertyName.php @@ -1,5 +1,5 @@ 1 ); $difftime = isset($tplData["difftime"]) ? $tplData["difftime"] : 8; $a = $tplData["a"]; diff --git a/test/features/EnumDeclaration.php b/test/features/EnumDeclaration.php index eb84552..049e7c0 100644 --- a/test/features/EnumDeclaration.php +++ b/test/features/EnumDeclaration.php @@ -1,5 +1,5 @@ 1, "b" => 2, "c" => 3 ); $bbb = array( "a" => 0, "b" => 1, "c" => 2 ); $ccc = array( "a" => "a", "b" => "b", "c" => "c" ); diff --git a/test/features/ForStatement.php b/test/features/ForStatement.php index 3d2faac..f9d93ab 100644 --- a/test/features/ForStatement.php +++ b/test/features/ForStatement.php @@ -1,5 +1,5 @@ 1 )); $b = array_keys($a); $c = $a; diff --git a/test/features/ObjectLiteralExpression.php b/test/features/ObjectLiteralExpression.php index dfb88ed..4296641 100644 --- a/test/features/ObjectLiteralExpression.php +++ b/test/features/ObjectLiteralExpression.php @@ -1,5 +1,5 @@ 123, "b" => "456" diff --git a/test/features/ShorthandPropertyAssignment.php b/test/features/ShorthandPropertyAssignment.php index 58ecee3..e5fcafe 100644 --- a/test/features/ShorthandPropertyAssignment.php +++ b/test/features/ShorthandPropertyAssignment.php @@ -1,5 +1,5 @@ "aaa" ); diff --git a/test/features/template.php b/test/features/template.php index 57b389e..132b7dc 100644 --- a/test/features/template.php +++ b/test/features/template.php @@ -1,5 +1,5 @@ array( "b" => $String, diff --git a/test/index.js b/test/index.js index 9e4dc40..88a11aa 100644 --- a/test/index.js +++ b/test/index.js @@ -12,7 +12,7 @@ const {compile} = require('../src/index.ts'); const files = fs.readdirSync(path.resolve(__dirname, './features')); const featureNames = files.reduce((res, file) => { - const m = file.match(/(.+)\.ts/); + const m = file.match(/(.+)\.ts$/); if (m) { res.push(m[1]); } @@ -39,7 +39,7 @@ describe('features', () => { const phpContent = await readFile(path.resolve(__dirname, `./features/${featureName}.php`)); const tsPath = path.resolve(__dirname, `./features/${featureName}.ts`); const res = compile(tsPath, { - namespace: `test\\${featureName}`, + namespace: `test\\case_${featureName}`, modules: { 'vue': { required: true