javascript - Browser API: URL class is not recognized in Typescript -
i'm using url utility: https://developer.mozilla.org/en-us/docs/web/api/url , have problem using in typescript code.
whereas can open console in browser , type:
new url("http://stackoverflow.com/question/ask")
and code successful, whenever write in typescript file , transpile it, following error:
error ts2351: cannot use 'new' expression type lacks call or construct signature.
does mean class doesn't exist in typescript? there way use in typescript code?
that should supported typescript, that's included on lib.dom.d.ts included default if target es5.
you can configure on tsconfig.json (that default config when using es5, can try add explicitly):
"lib": [ "dom", "es5", "scripthost" ],
Comments
Post a Comment