@@ -4,7 +4,14 @@ import { assume } from "../../utils";
44import { TransformationContext } from "../context" ;
55import { importLuaLibFeature , LuaLibFeature } from "../utils/lualib" ;
66import { getIdentifierSymbolId } from "../utils/symbols" ;
7- import { isArrayType , isFunctionType , isNumberType , isStandardLibraryType , isStringType } from "../utils/typescript" ;
7+ import {
8+ hasStandardLibrarySignature ,
9+ isArrayType ,
10+ isFunctionType ,
11+ isNumberType ,
12+ isStandardLibraryType ,
13+ isStringType ,
14+ } from "../utils/typescript" ;
815import { PropertyCallExpression } from "../visitors/call" ;
916import { checkForLuaLibType } from "../visitors/class/new" ;
1017import { transformArrayProperty , transformArrayPrototypeCall } from "./array" ;
@@ -85,22 +92,19 @@ export function transformBuiltinCallExpression(
8592 }
8693 }
8794
88- if ( isStringType ( context , ownerType ) ) {
95+ if ( isStringType ( context , ownerType ) && hasStandardLibrarySignature ( context , node ) ) {
8996 return transformStringPrototypeCall ( context , node ) ;
9097 }
9198
92- if ( isNumberType ( context , ownerType ) ) {
99+ if ( isNumberType ( context , ownerType ) && hasStandardLibrarySignature ( context , node ) ) {
93100 return transformNumberPrototypeCall ( context , node ) ;
94101 }
95102
96- if ( isArrayType ( context , ownerType ) ) {
97- const result = transformArrayPrototypeCall ( context , node ) ;
98- if ( result ) {
99- return result ;
100- }
103+ if ( isArrayType ( context , ownerType ) && hasStandardLibrarySignature ( context , node ) ) {
104+ return transformArrayPrototypeCall ( context , node ) ;
101105 }
102106
103- if ( isFunctionType ( context , ownerType ) ) {
107+ if ( isFunctionType ( context , ownerType ) && hasStandardLibrarySignature ( context , node ) ) {
104108 return transformFunctionPrototypeCall ( context , node ) ;
105109 }
106110
0 commit comments