-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Change default of types to [] in tsconfig.json
#63031
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
base: main
Are you sure you want to change the base?
Changes from all commits
4a9fccf
2b70067
3040049
8eeb702
95e2cd0
25b06e8
148074c
83af771
5144841
3b0d338
e641e7e
89de5f6
387b02a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,13 +26,15 @@ import { | |
| emptyArray, | ||
| endsWith, | ||
| ensureTrailingDirectorySeparator, | ||
| equateValues, | ||
| every, | ||
| Extension, | ||
| extensionIsTS, | ||
| fileExtensionIs, | ||
| fileExtensionIsOneOf, | ||
| filter, | ||
| firstDefined, | ||
| flatten, | ||
| forEach, | ||
| forEachAncestorDirectory, | ||
| formatMessage, | ||
|
|
@@ -808,13 +810,17 @@ export function resolvePackageNameToPackageJson( | |
| * this list is only the set of defaults that are implicitly included. | ||
| */ | ||
| export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] { | ||
| // Use explicit type list from tsconfig.json | ||
| if (options.types) { | ||
| // Default to [] if nothing specified | ||
| if (options.types === undefined) { | ||
| return emptyArray; | ||
| } | ||
|
|
||
| if (!options.types.includes("*")) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to update updateTypeRootsWatch to reflect this change |
||
| // No wildcard, no need to iterate anything | ||
| return options.types; | ||
| } | ||
|
|
||
| // Walk the primary type lookup locations | ||
| const result: string[] = []; | ||
| const wildcardMatches: string[] = []; | ||
| if (host.directoryExists && host.getDirectories) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also need to fix |
||
| const typeRoots = getEffectiveTypeRoots(options, host); | ||
| if (typeRoots) { | ||
|
|
@@ -829,19 +835,19 @@ export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: M | |
| const isNotNeededPackage = host.fileExists(packageJsonPath) && (readJson(packageJsonPath, host) as PackageJson).typings === null; | ||
| if (!isNotNeededPackage) { | ||
| const baseFileName = getBaseFileName(normalized); | ||
|
|
||
| // At this stage, skip results with leading dot. | ||
| if (baseFileName.charCodeAt(0) !== CharacterCodes.dot) { | ||
| // Return just the type directive names | ||
| result.push(baseFileName); | ||
| wildcardMatches.push(baseFileName); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return result; | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // Order potentially matters in program construction, so substitute | ||
| // in the wildcard in the position it was specified in the types array | ||
| return deduplicate(flatten(options.types.map(t => t === "*" ? wildcardMatches : t)), equateValues); | ||
| } | ||
|
|
||
| export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, NonRelativeNameResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,3 +29,22 @@ module.exports = { | |
| export const thing: Something; | ||
| import Something_1 = require("fs"); | ||
| import Something = Something_1.Something; | ||
|
|
||
|
|
||
| //// [DtsFileErrors] | ||
|
|
||
|
|
||
| tests/cases/conformance/jsdoc/declarations/out/index.d.ts(2,30): error TS2307: Cannot find module 'fs' or its corresponding type declarations. | ||
|
|
||
|
|
||
| ==== tests/cases/conformance/jsdoc/declarations/out/index.d.ts (1 errors) ==== | ||
| export const thing: Something; | ||
| import Something_1 = require("fs"); | ||
| ~~~~ | ||
| !!! error TS2307: Cannot find module 'fs' or its corresponding type declarations. | ||
| import Something = Something_1.Something; | ||
|
Comment on lines
+34
to
+45
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something isn't right here; probably need to update the test as it explicitly makes a |
||
|
|
||
| ==== node_modules/@types/node/index.d.ts (0 errors) ==== | ||
| declare module "fs" { | ||
| export class Something {} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,26 @@ export namespace A { | |
| } | ||
| import Something_1 = require("fs"); | ||
| import Something = Something_1.Something; | ||
|
|
||
|
|
||
| //// [DtsFileErrors] | ||
|
|
||
|
|
||
| tests/cases/conformance/jsdoc/declarations/out/index.d.ts(6,30): error TS2307: Cannot find module 'fs' or its corresponding type declarations. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here. |
||
|
|
||
|
|
||
| ==== tests/cases/conformance/jsdoc/declarations/out/index.d.ts (1 errors) ==== | ||
| export namespace A { | ||
| namespace B { | ||
| let thing: Something; | ||
| } | ||
| } | ||
| import Something_1 = require("fs"); | ||
| ~~~~ | ||
| !!! error TS2307: Cannot find module 'fs' or its corresponding type declarations. | ||
| import Something = Something_1.Something; | ||
|
|
||
| ==== node_modules/@types/node/index.d.ts (0 errors) ==== | ||
| declare module "fs" { | ||
| export class Something {} | ||
| } | ||
This file was deleted.
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.
There are error messages in
getCannotFindNameDiagnosticForNamein checker.ts that needs to be fixed to always suggest adding type name to types array ?