Typescript: lib.es5.d.ts: Date#toGMTString declaration is missing

Created on 22 Jan 2017  路  6Comments  路  Source: microsoft/TypeScript



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.

lib.d.ts Revisit Suggestion

Most helpful comment

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?

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanzer picture seanzer  路  3Comments

Roam-Cooper picture Roam-Cooper  路  3Comments

manekinekko picture manekinekko  路  3Comments

dlaberge picture dlaberge  路  3Comments

siddjain picture siddjain  路  3Comments