We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It`s not possible to import typescrpit code as a string dynamically
Add the following code to any of the examples:
async function importjs(js: string, filename = "importedjs") { const dataUri = "data:text/typescript;charset=utf-8," + encodeURIComponent(js) + `//# sourceURL=${filename}.ts;`; const r = await import(/* @vite-ignore */ dataUri); return r; } const r = await importjs(`export default (arg1:any) => {return 'hello world '+arg1}`) console.log(r.default("test")) // EXPECTED: hello world test
The worker will error complaining about typescript sintax
{ "error": "Unexpected token ':' at data:text/typescript;charset=utf-8,export%20default%20(arg1%3Aany)%20%3D%3E%20%7Breturn%20'hello%20world%20'%2Barg1%7D//#%20sourceURL=importedjs.ts;:1:21" }
Typescript code should work
The text was updated successfully, but these errors were encountered:
Note:
I was able to reproduce it locally. This issue was caused by passing the original content as it is to deno_core without lowering it to Javascript.
Sorry, something went wrong.
No branches or pull requests
Bug report
Describe the bug
It`s not possible to import typescrpit code as a string dynamically
To Reproduce
Add the following code to any of the examples:
The worker will error complaining about typescript sintax
Expected behavior
Typescript code should work
System information
The text was updated successfully, but these errors were encountered: