Skip to content

No escape and unescape methods in lib.d.ts #18813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
k8w opened this issue Sep 28, 2017 · 8 comments
Closed

No escape and unescape methods in lib.d.ts #18813

k8w opened this issue Sep 28, 2017 · 8 comments
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@k8w
Copy link

k8w commented Sep 28, 2017

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
2.6.0-dev.20170926

Code

let a = escape('aaa');
unescape(a);

Expected behavior:
Compile succ

Actual behavior:
Compile error

@wrager
Copy link

wrager commented Sep 28, 2017

The escape() function (or unescape) was deprecated in JavaScript version 1.5. Use encodeURI() or encodeURIComponent() instead.

https://www.w3schools.com/jsref/jsref_escape.asp
https://www.w3schools.com/jsref/jsref_unescape.asp

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Oct 3, 2017
@wbhob
Copy link
Contributor

wbhob commented Oct 8, 2017

MDN actually lists escape and unescape as valid ESNext functions, FYI. Working on a PR

wbhob added a commit to wbhob/TypeScript that referenced this issue Oct 8, 2017
although the issue is marked working as expected, it is important to mention that most major browsers maintain support for escape and unescape, and some javascript codebases moving to typescript may have escape and unescape in them. They are valid JavaScript, and thus they should be included in the global definition.
@mhegazy
Copy link
Contributor

mhegazy commented Oct 9, 2017

This behavior is intentional. Please see #8639 (comment).

You can always define:

declare function escape(s:string): string;
declare function unescape(s:string): string;

@k8w k8w closed this as completed Oct 18, 2017
@k8w k8w reopened this Oct 18, 2017
@k8w
Copy link
Author

k8w commented Oct 18, 2017

Have seen #8639 and find nothing about deprecated here.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape

@kitsonk
Copy link
Contributor

kitsonk commented Oct 18, 2017

Copying comment from other thread

@k8w those pages used to refer to it being deprecated, and it was. It does not appear to be deprecated in the current standard though, and I can't find a specific reference to why the change was made. I suspect they were retained in the specification to not break code, but you shouldn't be using them for new code as they don't handle Unicode URIs properly, and so IMO they are best to leave out and people can add them back in if they are supporting old code.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 18, 2017

Please see comment in #8639 (comment)

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Working as Intended The behavior described is the intended behavior; this is not a bug labels Oct 18, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Nov 1, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Nov 1, 2017
@mhegazy mhegazy added Fixed A PR has been merged for this issue Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript and removed Duplicate An existing issue was already created labels Nov 13, 2017
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Nov 13, 2017
mhegazy pushed a commit that referenced this issue Nov 13, 2017
* add types for escape and unescape methods #18813
although the issue is marked working as expected, it is important to mention that most major browsers maintain support for escape and unescape, and some javascript codebases moving to typescript may have escape and unescape in them. They are valid JavaScript, and thus they should be included in the global definition.

* add escape and unescape types to lib in tests

* update tests to turn CI green
@mhegazy mhegazy added the Suggestion An idea for TypeScript label Nov 13, 2017
@wbhob
Copy link
Contributor

wbhob commented Nov 13, 2017

My PR got merged! This issue has been fixed.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants