Added deferred ScriptKind and renamed JsFileExtensionInfo to FileExte…#23191
Conversation
| return needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions; | ||
| export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: ReadonlyArray<FileExtensionInfo>): ReadonlyArray<string> { | ||
| const needJsExtensions = options && options.allowJs; | ||
| let extensions: string[] = needJsExtensions ? [...allSupportedExtensions] : [...supportedTypeScriptExtensions]; |
There was a problem hiding this comment.
Can you please not create copy of array when its not needed.
There was a problem hiding this comment.
Changed. Although the needJsExtension comparison now repeats once.
|
|
||
| const extensions = [ | ||
| ...needJsExtensions ? allSupportedExtensions : supportedTypeScriptExtensions, | ||
| ...extraFileExtensions.filter(x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJavaScriptLike(x.scriptKind)).map(x => x.extension) |
There was a problem hiding this comment.
May be use
...mapDefined(extraFileExtentions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJavaScriptLike(x.scriptKind) ? x.scriptKind : undefined)
| PriorityImpliesCombination = 28 | ||
| } | ||
| interface JsFileExtensionInfo { | ||
| interface FileExtensionInfo { |
There was a problem hiding this comment.
this is a breaking change really. consider not changing the name, or adding a type alias type JsFileExtensionInfo = FileExtensionInfo
|
Please add some test cases using the new Deffered as the script kind. |
| } | ||
|
|
||
| export interface JsFileExtensionInfo { | ||
| export type JsFileExtensionInfo = FileExtensionInfo; |
There was a problem hiding this comment.
add a /** @deprecated use FileExtensionInfo instead./ comment
|
Added unit test for checking that the deferred extension is included on the project context. |
| checkNumberOfProjects(projectService, { configuredProjects: 1 }); | ||
|
|
||
| const configuredProject = configuredProjectAt(projectService, 0); | ||
| checkProjectActualFiles(configuredProject, [file1.path, tsconfig.path]); |
There was a problem hiding this comment.
Interesting.. Why is file2 not part of the project, I thought it would be expected to included in the project?
There was a problem hiding this comment.
File2 is a JS file and the tsconfig.json doesn't enable AllowJS. This test checks that by adding a deferred extension it gets the right context but also doesn't affect the JS setting. Hope it makes sense.
|
|
||
| export function fileExtensionIs(path: string, extension: string): boolean { | ||
| return path.length > extension.length && endsWith(path, extension); | ||
| return path.length >= extension.length && endsWith(path, extension); |
There was a problem hiding this comment.
You sure you want >= here? For example a file named .ts shouldn't count.
There was a problem hiding this comment.
Rollback. Its no longer needed for Deferred kind.
…nsionInfo
This change will help identifying files that the extension doesn't identify the script kind but the content does.