Fix missing ES types regression in 0.15 #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed a few projects failing when Dependabot updated tsd from 0.14 to 0.15. Using
git bisect
I traced this to f5b69ed, specifically:f5b69ed#diff-e717ee248865fa4044ef4561e4692693459eb15f9c1605b12ca42b8f38226fa3R37
Changing
lib.es2017.d.ts
toes2017
results in errors when typings use core ES types likeRegExp
,Array
, andJSON
(Cannot find name ${type}
).bendrucker/creditcards#43
bendrucker/creditcards-types#70
bendrucker/snakecase-keys#49
Presumably if any of these typings used DOM types, that would fail similarly. Digging further, it seemed suspicious that the test for adding DOM by default explicitly enables
dom
as an override:f5b69ed#diff-ec66651dab3235538c4084a1f2f27a2a10d2752f03b28af09fbd18a16b4384baR5
If
dom
is enabled by default, the test fixture should not have to override. Turns out this was needed because otherwisefindConfigFile
traverses upwards until it finds atsconfig.json
file, so tests were inheriting the options used to buildtsd
itself by default.In order to get test coverage more akin to end usage, I renamed the tsconfig file to exclude it from automatic discovery.
The resulting object from
getOptionsFromTsConfig
haslib
mappedlib.${lib}.d.ts
form. So without a tsconfig.json, the DOM test fails. Iflib
is transformed into full filenames, it passes.Those library mappings come from here:
https://github.com/microsoft/TypeScript/blob/fe4a6709da77c7eb7cff1ba2a31963e18037bc86/src/compiler/commandLineParser.ts#L20
When working directly with a
CompilerOptions
, I can't find any public method that would transform the array of lib keys to their filenames. It should be safe to go with a mapping function since the onlylib
entries that don't obey that strict relationship is mutable targets likeesnext
, which don't seem like they would be specified in tsd.I could also convert the compiler options back to their
tsconfig.json
representation and useconvertCompilerOptionsFromJson
instead.Not invested in any particular fix here, just wanted to provide a thorough report. Happy to revise.
Closes #101