You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the two packages are fragmented but since serverless-runtime-types describes implementations that are dependent on which version of runtime-handler you are using we should probably merge the two.
The main problem is that @twilio/runtime-handler is not meant to be required and in fact throws an error when done in production.
TypeScript offers the ability to do type imports only like:
This would technically compile away when converted to JavaScript which would be fine but a customer might actually omit the type from the import statement breaking their code.
One option would be to create another submodule similar to @twilio/runtime-handler/dev and soon @twilio/runtime-handler/test we could have @twilio/runtime-hanlder/types that could be used. Similar to the current @twilio-labs/serverless-runtime-types this would not actually contain any code but instead would only be used for types and to define global types.
The usage for TS would be:
// Imports global types. Since it won't contain any logic this is actually fine.import'@twilio/runtime-handler/types';// Fetches specific typesimporttypes{Context,ServerlessCallback,ServerlessEventObject,ServerlessFunctionSignature,}from'@twilio/runtime-handler/types';exportconsthandler: ServerlessFunctionSignature=function(context: Context,event: ServerlessEventObject,callback: ServerlessCallback){consttwiml=newTwilio.twiml.VoiceResponse();twiml.say('Hello World!');callback(null,twiml);};
Right now the two packages are fragmented but since serverless-runtime-types describes implementations that are dependent on which version of runtime-handler you are using we should probably merge the two.
The main problem is that
@twilio/runtime-handler
is not meant to be required and in fact throws an error when done in production.TypeScript offers the ability to do type imports only like:
This would technically compile away when converted to JavaScript which would be fine but a customer might actually omit the
type
from the import statement breaking their code.One option would be to create another submodule similar to
@twilio/runtime-handler/dev
and soon@twilio/runtime-handler/test
we could have@twilio/runtime-hanlder/types
that could be used. Similar to the current@twilio-labs/serverless-runtime-types
this would not actually contain any code but instead would only be used for types and to define global types.The usage for TS would be:
For JavaScript it would look the following:
Related to #297
The text was updated successfully, but these errors were encountered: