TypeScript Version: 2.2.0-dev.20170117
Code
(new Date()).toGMTString();
Expected behavior:
No errors.
Actual behavior:
Error: Property 'toGMTString' does not exist on type 'Date'.
MDN link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString
This method is deprecated, but still available in browsers and Node.js.
Note: toGMTString() is deprecated and should no longer be used. It remains implemented only for backward compatibility; please use toUTCString() instead.
Why not use the non-deprecated method instead?
Why not just use the non-deprecated method instead?
I use. But, anyway I think, that this method should be declared, because it's available from JavaScript.
You聽can聽manually do:
interface Date {
toGMTString(): string;
}
@SaschaNaz Issue about missing declaration in lib.es5.d.ts. I known how it may be fixed locally, thanks.
The method is intentionally redacted from the declaration file as it has since been removed from the standard. The lib files are commutative, i.e. lib.es2015.d.ts includes lib.es5.d.t.s.
From a correctness point of view, the API should be included, but marked as deprecated. We can revisit this after https://github.com/Microsoft/TypeScript/issues/390 is supported.
Declining due to lack of other feedback
Most helpful comment
Why not use the non-deprecated method instead?