-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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 untyped imports #11446
Allow untyped imports #11446
Conversation
db1cbaa
to
1807147
Compare
Can you please add these test cases so we have baselines later if behavior modifies
|
|
I find it suspicious that in |
I don't think we should just be reporting
|
…error when checking it
I went with:
We could mention that option, but this error message will be seen very often by people who simply forget to install types. Maybe we could even recommend |
@andy-ms Nice - that one seems reasonable. |
Nice work @andy-ms ! I wrote a blogpost about this a couple of weeks ago about The one thing that keeps me from using TypeScript. This is exactly what I wanted! Also with the error message that @DanielRosenwasser suggested. The only difference is that I suggested an extra flag called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing the filtering in resolveModuleName, why not just return an additional piece of information on ResolvedModule
call it candidateFile
for instance, and that would be the location of the .js file(s) that were found during the search for the .d.ts /.ts file. In program.ts, if we found this set but no resolvedFileName is set on the ResolvedModule, but a candidateFile, then we know it is untyped.
resolvedModule.resolvedFileName); | ||
} | ||
|
||
const newSymbol = createSymbol(SymbolFlags.ValueModule, quotedName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happenes if you just return undefined? why do you need to create a symbol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you must, i would create a singleton UnkownModuleSymbol
and check for that in isUntypedModuleSymbol
"category": "Message", | ||
"code": 6141 | ||
}, | ||
"A package for '{0}' was found at '{1}', but is untyped. Since '--noImplicitAny' is enabled, this package must have a declaration.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since -> Because
directory = normalizeSlashes(directory); | ||
/** | ||
* Remembers the path to a package.json for the package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The path to a package.json in case we find a typed version of the package further up the spine."
Closing in favor of #11889 |
Fixes #11106
If we find a
package.json
while searching throughnode_modules
, we will allow imports of that module to work in an untyped fashion.This change will not affect users with
--noImplicitAny
turned on.It also has no effect without
--moduleResolution node
. So we might not want to completely close the issue until we have solutions for other module systems.We can't do find-all-references for untyped imports because that function uses
symbol.declarations
, which in this case is empty.