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

Suggest enabling allowJs for an import from a .js(x) file #47189

Open
5 tasks done
JoshuaKGoldberg opened this issue Dec 18, 2021 · 0 comments
Open
5 tasks done

Suggest enabling allowJs for an import from a .js(x) file #47189

JoshuaKGoldberg opened this issue Dec 18, 2021 · 0 comments
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Milestone

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Dec 18, 2021

Suggestion

πŸ” Search Terms

suggest allowJs js jsx extension import 7016

βœ… 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

The error message for importing from a relative module that's not found is the same as a file that has a .js extension.

πŸ“ƒ Motivating Example

// index.ts
import { value } from "./values";
// By default: implicitly any
// With noImplicitAny: \
//   Could not find a declaration file for module './values'.
//   '/path/to/repo/values.js' implicitly has an 'any' type. ts(7016)
// values.js
export const value = "";

πŸ’» Use Cases

Folks coming in fresh to TypeScript might not know allowJs is off by default.

Perhaps this suggestion text would be helpful?

A .js file exists at that location, but the 'allowJs' compiler option is not enabled.
@RyanCavanaugh RyanCavanaugh added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Jan 4, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants