GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Have module resolution be independend of --allowJs and --jsx flags · Pull Request #11704 · microsoft/TypeScript Conversation
|
| * - don't use tripleslash references | ||
| */ | ||
| isExternalLibraryImport?: boolean; | ||
| isExternalLibraryImport: boolean; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this should stay optional. otherwise we break other API
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * in which case they will be inferred from the file extension. | ||
| * Prefer to return a full ResolvedModule. | ||
| */ | ||
| export type ResolvedModuleFromHost = { resolvedFileName: string; isExternalLibraryImport: boolean } | ResolvedModule; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
i do not understand why we need this. the two new properties are optional, and we have logic to handle them being missing. so do not see the value here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return undefined; | ||
| } | ||
| // `resolvedTsFileName` and `resolvedJsFileName` should be present as properties even if undefined. | ||
| else if ("resolvedTsFileName" in resolved) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
mm. do you really need that check? can we check when we create them instead?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * Extracts the file name from a ResolvedModule, or returns a DiagnosticMessage if we are not set up to use that kind of file. | ||
| * The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to. | ||
| */ | ||
| export function getResolutionOrDiagnostic(options: CompilerOptions, { resolvedTsFileName: ts, resolvedJsFileName: js }: ResolvedModule): string | { file: string, diag: DiagnosticMessage } { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit. i would rather we just use module.resolvedTsFileName || module.resolvedJsFileName for the module, and have this function just to report errors. this avoids the complexity of checking if the return type is string or not.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Vladimir Matveev (@vladima) can you take a look. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… avoid using resolution.resolvedFileName if the diagnostic is defined.
…e` and `resolvedJsFileName` optional properties (but still automatically infer one of them to supply if the host supplied neither)
| /* @internal */ | ||
| export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; | ||
| export function trace(host: ModuleResolutionHost, message: DiagnosticMessage): void { | ||
| function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
why removing @internal?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| /** LsHost uses a global cache of automatically-installed typings to help it resolve modules. */ | ||
| /* @internal */ | ||
| export function resolveModuleNameForLsHost(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string | undefined, projectName: string): ResolvedModuleWithFailedLookupLocations { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don' think this function should be here given that this file is part of core compiler bits and LSHost is specific to server
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…solvedFileName` and `extension`. Also, change search order to do all TS searching before searching for JS.
| resolveModuleNamesWorker = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile); | ||
| resolveModuleNamesWorker = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile).map(resolved => { | ||
| // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. | ||
| if (!resolved || resolved.extension) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Extenstion.TS is Zero so this will fail. probably want to check for undefined here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /* | ||
| * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be proper external module: | ||
| /** Extension of resolvedFileName. This must match what's at the end of resolvedFileName. */ | ||
| extension: Extension; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
optional?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If this is optional we will need fallback logic on every access. I thought it was easier to just perform the conversion when getting it from an external source. This would mean that older clients won't compile against the new compiler, but will still run.
We might choose to not have this property as it is techincally redundant, but it's neater to have this property and use switch statements than to use if (fileExtensionIs(resolved.resolvedFileName, ".ts")) { ... } else if (fileExtensionIs(resolved.resolvedFileName, ".tsx")) { ... } all over.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
just a couple of API comments
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.