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

ES6 module filename improvement #27299

Closed
4 tasks done
danielsedlacek opened this issue Sep 24, 2018 · 2 comments
Closed
4 tasks done

ES6 module filename improvement #27299

danielsedlacek opened this issue Sep 24, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@danielsedlacek
Copy link

Search Terms

import, module

Suggestion

When using the import declaration from the documentation

import { ZipCodeValidator } from "./ZipCodeValidator";

the latest Chrome will not find the 'ZipCodeValidator' file. The console will show an error "Failed to load resource: the server responded with a status of 404 (Not Found)".

This can be easily fixed by adding the ".js" suffix to the imported module.

import { ZipCodeValidator } from "./ZipCodeValidator.js";

On one hand, this is a documentation issue (the documentation does not follow implementation), on the other hand, it would be nice if the compiler generated the ".js" automatically.

Please see #27287

Use Cases

TS script:
import { ZipCodeValidator } from "./ZipCodeValidator";

Generated ES6:
import { ZipCodeValidator } from "./ZipCodeValidator";

This is invalid and will not work.

Examples

TS script:
import { ZipCodeValidator } from "./ZipCodeValidator";

Generated ES6:
import { ZipCodeValidator } from "./ZipCodeValidator.js";

The compiler will add the ".js" to the module filename.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Sep 24, 2018
@RyanCavanaugh
Copy link
Member

Duplicate of #16577

@RyanCavanaugh RyanCavanaugh marked this as a duplicate of #16577 Sep 24, 2018
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants