From 50eb5125664d47ac7cb59a2889236f200a4f4c7d Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Thu, 5 Apr 2018 17:30:04 -0700 Subject: [PATCH 1/5] Added deferred ScriptKind and renamed JsFileExtensionInfo to FileExtensionInfo --- src/compiler/commandLineParser.ts | 10 +++---- src/compiler/core.ts | 28 +++++++++++-------- src/compiler/program.ts | 4 +-- src/compiler/types.ts | 9 ++++-- src/server/editorServices.ts | 16 +++++++++-- src/server/project.ts | 2 +- src/server/protocol.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 18 ++++++++---- tests/baselines/reference/api/typescript.d.ts | 13 ++++++--- 9 files changed, 67 insertions(+), 35 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f386c701dd7..9fa0c20c00b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1421,7 +1421,7 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine { + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine { return parseJsonConfigFileContentWorker(json, /*sourceFile*/ undefined, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions); } @@ -1432,7 +1432,7 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonSourceFileConfigFileContent(sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine { + export function parseJsonSourceFileConfigFileContent(sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine { return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions); } @@ -1471,7 +1471,7 @@ namespace ts { existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], - extraFileExtensions: ReadonlyArray = [], + extraFileExtensions: ReadonlyArray = [], ): ParsedCommandLine { Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined)); const errors: Diagnostic[] = []; @@ -2004,7 +2004,7 @@ namespace ts { options: CompilerOptions, host: ParseConfigHost, errors: Push, - extraFileExtensions: ReadonlyArray, + extraFileExtensions: ReadonlyArray, jsonSourceFile: JsonSourceFile ): ExpandResult { basePath = normalizePath(basePath); @@ -2042,7 +2042,7 @@ namespace ts { * @param extraFileExtensions optionaly file extra file extension information from host */ /* @internal */ - export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: ReadonlyArray = []): ExpandResult { + export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: ReadonlyArray = []): ExpandResult { basePath = normalizePath(basePath); const keyMapper = host.useCaseSensitiveFileNames ? identity : toLowerCase; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a75cc8cba0e..78e308761c8 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2322,7 +2322,7 @@ namespace ts { } export function fileExtensionIs(path: string, extension: string): boolean { - return path.length > extension.length && endsWith(path, extension); + return path.length >= extension.length && endsWith(path, extension); } export function fileExtensionIsOneOf(path: string, extensions: ReadonlyArray): boolean { @@ -2666,16 +2666,22 @@ namespace ts { export const supportedJavascriptExtensions: ReadonlyArray = [Extension.Js, Extension.Jsx]; const allSupportedExtensions: ReadonlyArray = [...supportedTypeScriptExtensions, ...supportedJavascriptExtensions]; - export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: ReadonlyArray): ReadonlyArray { - const needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { - return needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions; + export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: ReadonlyArray): ReadonlyArray { + const needJsExtensions = options && options.allowJs; + let extensions: string[] = needJsExtensions ? [...allSupportedExtensions] : [...supportedTypeScriptExtensions]; + + if (extraFileExtensions) { + extensions = [ + ...extensions, + ...extraFileExtensions.filter(x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJavaScriptLike(x.scriptKind)).map(x => x.extension), + ]; } - return deduplicate( - [...allSupportedExtensions, ...extraFileExtensions.map(e => e.extension)], - equateStringsCaseSensitive, - compareStringsCaseSensitive - ); + + return deduplicate(extensions, equateStringsCaseSensitive, compareStringsCaseSensitive); + } + + function isJavaScriptLike(scriptKind: ScriptKind): boolean { + return scriptKind === ScriptKind.JS || scriptKind === ScriptKind.JSX; } export function hasJavaScriptFileExtension(fileName: string) { @@ -2686,7 +2692,7 @@ namespace ts { return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension)); } - export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: ReadonlyArray) { + export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: ReadonlyArray) { if (!fileName) { return false; } for (const extension of getSupportedExtensions(compilerOptions, extraFileExtensions)) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 31220c68d3c..21ae663ba59 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1299,9 +1299,9 @@ namespace ts { Debug.assert(!!sourceFile.bindDiagnostics); const isCheckJs = isCheckJsEnabledForFile(sourceFile, options); - // By default, only type-check .ts, .tsx, and 'External' files (external files are added by plugins) + // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) const includeBindAndCheckDiagnostics = sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX || - sourceFile.scriptKind === ScriptKind.External || isCheckJs; + sourceFile.scriptKind === ScriptKind.External || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred; const bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray; const checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray; const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f820201063c..5f9475e7bb9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4058,7 +4058,7 @@ namespace ts { Prototype, } - export interface JsFileExtensionInfo { + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; @@ -4265,7 +4265,12 @@ namespace ts { TS = 3, TSX = 4, External = 5, - JSON = 6 + JSON = 6, + /** + * Used on extensions that doesn't define the ScriptKind but the content defines it. + * Deferred extensions are going to be included in all project contexts. + */ + Deferred = 7 } export const enum ScriptTarget { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 09c5e784ba8..8907dd284ac 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -202,7 +202,7 @@ namespace ts.server { formatCodeOptions: FormatCodeSettings; preferences: UserPreferences; hostInfo: string; - extraFileExtensions?: JsFileExtensionInfo[]; + extraFileExtensions?: FileExtensionInfo[]; } export interface OpenConfiguredProjectResult { @@ -212,8 +212,8 @@ namespace ts.server { interface FilePropertyReader { getFileName(f: T): string; - getScriptKind(f: T, extraFileExtensions?: JsFileExtensionInfo[]): ScriptKind; - hasMixedContent(f: T, extraFileExtensions: JsFileExtensionInfo[]): boolean; + getScriptKind(f: T, extraFileExtensions?: FileExtensionInfo[]): ScriptKind; + hasMixedContent(f: T, extraFileExtensions: FileExtensionInfo[]): boolean; } const fileNamePropertyReader: FilePropertyReader = { @@ -2405,5 +2405,15 @@ namespace ts.server { this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles); } } + + hasDeferredExtension() { + for (const extension of this.hostConfiguration.extraFileExtensions) { + if (extension.scriptKind === ScriptKind.Deferred) { + return true; + } + } + + return false; + } } } diff --git a/src/server/project.ts b/src/server/project.ts index 442c7e3f5ad..74ac7d32717 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -235,7 +235,7 @@ namespace ts.server { this.compilerOptions.allowNonTsExtensions = true; this.compilerOptions.allowJs = true; } - else if (hasExplicitListOfFiles || this.compilerOptions.allowJs) { + else if (hasExplicitListOfFiles || this.compilerOptions.allowJs || this.projectService.hasDeferredExtension()) { // If files are listed explicitly or allowJs is specified, allow all extensions this.compilerOptions.allowNonTsExtensions = true; } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 74b6865a3c3..3bbb6da05fa 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1274,7 +1274,7 @@ namespace ts.server.protocol { /** * The host's additional supported .js file extensions */ - extraFileExtensions?: JsFileExtensionInfo[]; + extraFileExtensions?: FileExtensionInfo[]; } /** diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 89c1b54eec5..a2e84b8bca0 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2261,7 +2261,7 @@ declare namespace ts { AlwaysStrict = 64, PriorityImpliesCombination = 28 } - interface JsFileExtensionInfo { + interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; @@ -2423,7 +2423,12 @@ declare namespace ts { TS = 3, TSX = 4, External = 5, - JSON = 6 + JSON = 6, + /** + * Used on extensions that doesn't define the ScriptKind but the content defines it. + * Deferred extensions are going to be included in all project contexts. + */ + Deferred = 7 } enum ScriptTarget { ES3 = 0, @@ -3384,7 +3389,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3392,7 +3397,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; @@ -6016,7 +6021,7 @@ declare namespace ts.server.protocol { /** * The host's additional supported .js file extensions */ - extraFileExtensions?: JsFileExtensionInfo[]; + extraFileExtensions?: FileExtensionInfo[]; } /** * Configure request; value of command field is "configure". Specifies @@ -7850,7 +7855,7 @@ declare namespace ts.server { formatCodeOptions: FormatCodeSettings; preferences: UserPreferences; hostInfo: string; - extraFileExtensions?: JsFileExtensionInfo[]; + extraFileExtensions?: FileExtensionInfo[]; } interface OpenConfiguredProjectResult { configFileName?: NormalizedPath; @@ -8099,6 +8104,7 @@ declare namespace ts.server { resetSafeList(): void; applySafeList(proj: protocol.ExternalProject): NormalizedPath[]; openExternalProject(proj: protocol.ExternalProject): void; + hasDeferredExtension(): boolean; } } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index dbb4d6cc7bf..90111f939da 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2261,7 +2261,7 @@ declare namespace ts { AlwaysStrict = 64, PriorityImpliesCombination = 28 } - interface JsFileExtensionInfo { + interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; @@ -2423,7 +2423,12 @@ declare namespace ts { TS = 3, TSX = 4, External = 5, - JSON = 6 + JSON = 6, + /** + * Used on extensions that doesn't define the ScriptKind but the content defines it. + * Deferred extensions are going to be included in all project contexts. + */ + Deferred = 7 } enum ScriptTarget { ES3 = 0, @@ -4201,7 +4206,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -4209,7 +4214,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; From 2f7e0dc5dd777b599d52cd479a750d42910da5ef Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Mon, 16 Apr 2018 13:36:03 -0700 Subject: [PATCH 2/5] Refactored getSupportedExtension to only copy array when necessary --- src/compiler/core.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 78e308761c8..2ca3b89db3b 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2668,15 +2668,16 @@ namespace ts { export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: ReadonlyArray): ReadonlyArray { const needJsExtensions = options && options.allowJs; - let extensions: string[] = needJsExtensions ? [...allSupportedExtensions] : [...supportedTypeScriptExtensions]; - if (extraFileExtensions) { - extensions = [ - ...extensions, - ...extraFileExtensions.filter(x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJavaScriptLike(x.scriptKind)).map(x => x.extension), - ]; + if (!extraFileExtensions || extraFileExtensions.length === 0) { + return needJsExtensions ? allSupportedExtensions : supportedTypeScriptExtensions; } + const extensions = [ + ...needJsExtensions ? allSupportedExtensions : supportedTypeScriptExtensions, + ...extraFileExtensions.filter(x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJavaScriptLike(x.scriptKind)).map(x => x.extension) + ]; + return deduplicate(extensions, equateStringsCaseSensitive, compareStringsCaseSensitive); } From f17603d3187ba45d554ecdb70b8f3dd73cea587b Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Wed, 18 Apr 2018 12:58:40 -0700 Subject: [PATCH 3/5] Addressed PR comments --- src/compiler/core.ts | 2 +- src/compiler/types.ts | 2 ++ tests/baselines/reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 66cabb7655c..0bef14e9dda 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2677,7 +2677,7 @@ namespace ts { const extensions = [ ...needJsExtensions ? allSupportedExtensions : supportedTypeScriptExtensions, - ...extraFileExtensions.filter(x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJavaScriptLike(x.scriptKind)).map(x => x.extension) + ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJavaScriptLike(x.scriptKind) ? x.extension : undefined) ]; return deduplicate(extensions, equateStringsCaseSensitive, compareStringsCaseSensitive); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 27965451a14..5eea26f1c69 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4066,6 +4066,8 @@ namespace ts { Prototype, } + export type JsFileExtensionInfo = FileExtensionInfo; + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 3f999ef66a6..9d63950cc66 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2266,6 +2266,7 @@ declare namespace ts { AlwaysStrict = 64, PriorityImpliesCombination = 28 } + type JsFileExtensionInfo = FileExtensionInfo; interface FileExtensionInfo { extension: string; isMixedContent: boolean; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f868b26b9f0..8f6e3a70291 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2266,6 +2266,7 @@ declare namespace ts { AlwaysStrict = 64, PriorityImpliesCombination = 28 } + type JsFileExtensionInfo = FileExtensionInfo; interface FileExtensionInfo { extension: string; isMixedContent: boolean; From 5434c4146ee51e95078e9d490a73579807fa943a Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Fri, 20 Apr 2018 16:50:57 -0700 Subject: [PATCH 4/5] Added deferred project context test, marked JsFileExtension as deprecated --- src/compiler/types.ts | 1 + .../unittests/tsserverProjectSystem.ts | 42 +++++++++++++++++++ .../reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + 4 files changed, 45 insertions(+) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7fabd5d0265..4372469ac71 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4067,6 +4067,7 @@ namespace ts { Prototype, } + /** @deprecated Use FileExtensionInfo instead. */ export type JsFileExtensionInfo = FileExtensionInfo; export interface FileExtensionInfo { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 10912b4fb87..433f5eff95b 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3135,6 +3135,48 @@ namespace ts.projectSystem { }); }); + + it("includes deferred files in the project context", () => { + const file1 = { + path: "/a.deferred", + content: "const a = 1;" + }; + // Deferred extensions should not affect JS files. + const file2 = { + path: "/b.js", + content: "const b = 1;" + }; + const tsconfig = { + path: "/tsconfig.json", + content: "" + }; + + const host = createServerHost([file1, file2, tsconfig]); + const session = createSession(host); + const projectService = session.getProjectService(); + + // Configure the deferred extension. + const extraFileExtensions = [{ extension: ".deferred", scriptKind: ScriptKind.Deferred, isMixedContent: true }]; + const configureHostRequest = makeSessionRequest(CommandNames.Configure, { extraFileExtensions }); + session.executeCommand(configureHostRequest); + + // Open external project + const projectName = "/proj1"; + projectService.openExternalProject({ + projectFileName: projectName, + rootFiles: toExternalFiles([file1.path, file2.path, tsconfig.path]), + options: {} + }); + + // Assert + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + + const configuredProject = configuredProjectAt(projectService, 0); + checkProjectActualFiles(configuredProject, [file1.path, tsconfig.path]); + + // Allow allowNonTsExtensions will be set to true for deferred extensions. + assert.isTrue(configuredProject.getCompilerOptions().allowNonTsExtensions); + }); }); describe("tsserverProjectSystem Proper errors", () => { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 1ba84a4d08f..6ce8e53e397 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2266,6 +2266,7 @@ declare namespace ts { AlwaysStrict = 64, PriorityImpliesCombination = 28 } + /** @deprecated Use FileExtensionInfo instead. */ type JsFileExtensionInfo = FileExtensionInfo; interface FileExtensionInfo { extension: string; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d93c09f1281..b3d84f0edd9 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2266,6 +2266,7 @@ declare namespace ts { AlwaysStrict = 64, PriorityImpliesCombination = 28 } + /** @deprecated Use FileExtensionInfo instead. */ type JsFileExtensionInfo = FileExtensionInfo; interface FileExtensionInfo { extension: string; From b8ddc0dabb9395d46327c1c2c032f08adc8e6535 Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Wed, 2 May 2018 17:17:55 -0700 Subject: [PATCH 5/5] Rollback fileExtensionIs --- src/compiler/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 27e906b8a5a..d38e9f3d3d5 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2324,7 +2324,7 @@ namespace ts { } export function fileExtensionIs(path: string, extension: string): boolean { - return path.length >= extension.length && endsWith(path, extension); + return path.length > extension.length && endsWith(path, extension); } export function fileExtensionIsOneOf(path: string, extensions: ReadonlyArray): boolean {