Fixing error: “Cannot find name ‘unescape'” in TypeScript

Using escape or unescape in TypeScript, you can get the following error:

TSError: ⨯ Unable to compile TypeScript
src\lecture_search\LectureSearchApp.tsx (117,11): Cannot find name 'unescape'. (2304)
    at getOutput (D:\projects\image-annotation\node_modules\ts-node\src\ts-node.ts:210:13)
    at Object.loader (D:\projects\image-annotation\node_modules\ts-node\src\ts-node.ts:225:23)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Module.require (module.js:466:17)
    at require (internal/module.js:20:19)
    at Object. (D:\projects\image-annotation\index.js:7:1)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)

To fix this, add:

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

This is because these are considered deprecated.

6 Replies to “Fixing error: “Cannot find name ‘unescape'” in TypeScript”

Leave a Reply

Your email address will not be published. Required fields are marked *