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

Allow ".ts" in include/require statements. #49926

Closed
5 tasks done
tracker1 opened this issue Jul 15, 2022 · 5 comments
Closed
5 tasks done

Allow ".ts" in include/require statements. #49926

tracker1 opened this issue Jul 15, 2022 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@tracker1
Copy link

Suggestion

In order to align with Deno usage, as well as potentially future support for a browser loader, it would be beneficial to be able to include files with the .ts extension included.

The option should be able to be configured. When enabled output of ".ts" extension should be omitted on the output.

If a module reference begins with http:, https: or // then the default behavior should be left in place. Possibly use separate option to download/process such modules placed in (outdir)/_cache/https__www.foo.com/path/to/mod.js. where the protocol followed by two underscors is presented... preference for https, fallback to http in case of // at the front.

There's a pretty deep rabbit hole this could go down... that said, it would be really nice if it were easier to support Deno along with node and browser, and this would go a long way toward doing that. Since Deno can reference project code directly in typescript, it would allow projects to be Deno first, but still allow for build targets for node and browser usage.

🔍 Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

  • deno
  • ".ts"
  • extension

✅ Viability 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. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

💻 Use Cases

@MartinJohns
Copy link
Contributor

#38149?

@tracker1 tracker1 reopened this Jul 15, 2022
@tracker1
Copy link
Author

tracker1 commented Jul 15, 2022

While there are other references.. the #38149 was closed along with other mentioned issues.

#38149 (comment)

To me, given that part of the purpose of TS should be to support browser usage, that explicitly requires an extension... it makes far MORE sense to include the output extension for files that TSC processes, not less. Just because it's easier to ignore the issue, does emphatically NOT mean it's not an issue. In fact, TSC should ADD the .js extension where none was specified when it will be transpiling the referenced location via magic extension detection.

@MartinJohns
Copy link
Contributor

the #38149 was closed along with other mentioned issues.

No idea what you're talking about. It's still open.

TSC should ADD the .js extension where none was specified when it will be transpiling the referenced location via magic extension detection.

Rewriting paths has come up again and again, and the TypeScript team called this a huge no-go. Just check this issue: #49083 This is also something different from your initial issue.

@tracker1
Copy link
Author

@MartinJohns it's pretty much the same issue... Being able to use the .ts file extension and outputting .js for reference where the reference was outputted with a different extension.

Those is for better compatibility with the browser and deno, while it also would not break node.

@DanielRosenwasser
Copy link
Member

We're not likely to transform paths, but the closest thing we may be considering is #37582.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Jul 15, 2022
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