11import * as ts from "typescript" ;
22import * as lua from "../../LuaAST" ;
33import { TransformationContext } from "../context" ;
4- import { UnsupportedProperty } from "../utils/errors " ;
4+ import { unsupportedProperty } from "../utils/diagnostics " ;
55import { createExpressionPlusOne } from "../utils/lua-ast" ;
66import { LuaLibFeature , transformLuaLibFunction } from "../utils/lualib" ;
77import { PropertyCallExpression , transformArguments } from "../visitors/call" ;
@@ -19,7 +19,7 @@ function createStringCall(methodName: string, tsOriginal: ts.Node, ...params: lu
1919export function transformStringPrototypeCall (
2020 context : TransformationContext ,
2121 node : PropertyCallExpression
22- ) : lua . Expression {
22+ ) : lua . Expression | undefined {
2323 const expression = node . expression ;
2424 const signature = context . checker . getResolvedSignature ( node ) ;
2525 const params = transformArguments ( context , node . arguments , signature ) ;
@@ -148,14 +148,14 @@ export function transformStringPrototypeCall(
148148 node
149149 ) ;
150150 default :
151- throw UnsupportedProperty ( "string" , expressionName , node ) ;
151+ context . diagnostics . push ( unsupportedProperty ( node , "string" , expressionName ) ) ;
152152 }
153153}
154154
155155export function transformStringConstructorCall (
156156 context : TransformationContext ,
157157 node : PropertyCallExpression
158- ) : lua . Expression {
158+ ) : lua . Expression | undefined {
159159 const expression = node . expression ;
160160 const signature = context . checker . getResolvedSignature ( node ) ;
161161 const params = transformArguments ( context , node . arguments , signature ) ;
@@ -170,14 +170,14 @@ export function transformStringConstructorCall(
170170 ) ;
171171
172172 default :
173- throw UnsupportedProperty ( "String" , expressionName , node ) ;
173+ context . diagnostics . push ( unsupportedProperty ( node , "String" , expressionName ) ) ;
174174 }
175175}
176176
177177export function transformStringProperty (
178178 context : TransformationContext ,
179179 node : ts . PropertyAccessExpression
180- ) : lua . UnaryExpression {
180+ ) : lua . UnaryExpression | undefined {
181181 switch ( node . name . text ) {
182182 case "length" :
183183 let expression = context . transformExpression ( node . expression ) ;
@@ -186,6 +186,6 @@ export function transformStringProperty(
186186 }
187187 return lua . createUnaryExpression ( expression , lua . SyntaxKind . LengthOperator , node ) ;
188188 default :
189- throw UnsupportedProperty ( "string" , node . name . text , node ) ;
189+ context . diagnostics . push ( unsupportedProperty ( node , "string" , node . name . text ) ) ;
190190 }
191191}
0 commit comments