Currently, the method must be of the ResponseMethods TypeScript enum, which is really an integer. So to create a request in TypeScript, one would use the enum to describe the method instead of passing in the method string:
var options = new RequestOptions({
url: '/foo.json',
method: RequestMethods.POST
});
var request = new Request(options);
This adds some convenience for TypeScript and Dart users to get some IDE/compiler help to make sure the method is a valid value. But plain old ES5 users probably don't want to pass 0 as the method value. Instead, RequestOptions should have the method property be a union type of RequestMethods | string, and should validate the provided string & throw if not a recognized method.
I'm not sure Request class needs to accept method as a string though. Ideally, we could reduce instances of type ambiguity to public APIs.
Currently, the method must be of the
ResponseMethodsTypeScript enum, which is really an integer. So to create a request in TypeScript, one would use the enum to describe the method instead of passing in the method string:This adds some convenience for TypeScript and Dart users to get some IDE/compiler help to make sure the method is a valid value. But plain old ES5 users probably don't want to pass
0as the method value. Instead,RequestOptionsshould have themethodproperty be a union type ofRequestMethods | string, and should validate the provided string & throw if not a recognized method.I'm not sure
Requestclass needs to accept method as a string though. Ideally, we could reduce instances of type ambiguity to public APIs.