Skip to content
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

bug: cannot import typescript file from npm package #16790

Closed
idranme opened this issue Nov 24, 2022 · 4 comments · Fixed by #16813
Closed

bug: cannot import typescript file from npm package #16790

idranme opened this issue Nov 24, 2022 · 4 comments · Fixed by #16813
Labels
invalid what appeared to be an issue with Deno wasn't node compat

Comments

@idranme
Copy link
Contributor

idranme commented Nov 24, 2022

Deno version: 1.28.1

Step:
1.
test.ts:

import { hello } from "npm:test-deno-ts@latest";
console.log(hello)
deno run test.ts
error: 'import', and 'export' cannot be used outside of module code at file:///C:/Users/28648/AppData/Local/deno/npm/registry.npmjs.org/test-deno-ts/0.0.1/mod.ts:1:1

Content of test-deno-ts:
package.json:

{
	"name": "test-deno-ts",
	"version": "0.0.1",
	"type": "module",
	"license": "MIT",
	"exports": {
		"default": "./mod.ts"
	},
	"files": [
		"mod.ts"
	]
}

mod.ts:

export const hello: string = 'world'
@bartlomieju bartlomieju added needs investigation requires further investigation before determining if it is an issue or not node compat labels Nov 24, 2022
@dsherret
Copy link
Member

I'm not sure this is a bug. We don't support TypeScript files in npm packages the same way that Node doesn't support TypeScript files in npm packages. That said, we should have a better error message than the one shown.

@dsherret dsherret added invalid what appeared to be an issue with Deno wasn't and removed needs investigation requires further investigation before determining if it is an issue or not labels Nov 24, 2022
@idranme
Copy link
Contributor Author

idranme commented Nov 25, 2022

I'm not sure this is a bug. We don't support TypeScript files in npm packages the same way that Node doesn't support TypeScript files in npm packages. That said, we should have a better error message than the one shown.

I think Deno can support it, and it doesn't conflict with Node.

@dsherret
Copy link
Member

It would be encouraging people to distribute code to npm that doesn't work in Node. npm is a JavaScript registry so I think we should respect that.

@idranme
Copy link
Contributor Author

idranme commented Nov 25, 2022

It would be encouraging people to distribute code to npm that doesn't work in Node. npm is a JavaScript registry so I think we should respect that.

fair enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid what appeared to be an issue with Deno wasn't node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants