From 0352ef877e050f5004085c528492c71328a7c982 Mon Sep 17 00:00:00 2001 From: meixg Date: Wed, 23 Oct 2019 14:41:08 +0800 Subject: [PATCH] fix: inherited variables included class --- src/emitter.ts | 6 ++++++ test/features/inheritedVariables.php | 8 ++++++++ test/features/inheritedVariables.ts | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/emitter.ts b/src/emitter.ts index a13981c..4a24ad4 100644 --- a/src/emitter.ts +++ b/src/emitter.ts @@ -1770,6 +1770,12 @@ export function emitFile( ) { return; } + + let symbol = typeChecker.getSymbolAtLocation(item); + if (symbol && symbol.flags === ts.SymbolFlags.Class) { + return; + } + const currentSourceFile = item.getSourceFile(); const symbolOfIdentifier = typeChecker.getSymbolAtLocation(item); if (!symbolOfIdentifier) { diff --git a/test/features/inheritedVariables.php b/test/features/inheritedVariables.php index e9625f4..67b53e8 100644 --- a/test/features/inheritedVariables.php +++ b/test/features/inheritedVariables.php @@ -34,3 +34,11 @@ "item" => $item )); }, $arr); +class mmm { + static function func($num) { + return $num; + } +} +$arr4 = array_map(function ($item) { + return mmm::func($item); +}, $arr); diff --git a/test/features/inheritedVariables.ts b/test/features/inheritedVariables.ts index e434a5e..7df2d9c 100644 --- a/test/features/inheritedVariables.ts +++ b/test/features/inheritedVariables.ts @@ -44,4 +44,14 @@ let arr3 = arr.map(item => { ...a, item } +}); + +class mmm { + static func(num: string) { + return num; + } +} + +let arr4 = arr.map(item => { + return mmm.func(item); }); \ No newline at end of file