Skip to content

Commit 9c25f2f

Browse files
authored
fix(typings): getDocument return type. (#5132)
1 parent d4ff928 commit 9c25f2f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/core/documents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default class Documents implements Disposable {
186186
return docs
187187
}
188188

189-
public getDocument(uri: number | string, caseInsensitive = platform.isWindows || platform.isMacintosh): Document | null {
189+
public getDocument(uri: number | string, caseInsensitive = platform.isWindows || platform.isMacintosh): Document | null | undefined {
190190
if (typeof uri === 'number') {
191191
return this.buffers.get(uri)
192192
}

src/workspace.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,13 @@ export class Workspace {
357357
/**
358358
* Get created document by uri or bufnr.
359359
*/
360-
public getDocument(uri: number | string): Document | null {
360+
public getDocument(uri: number | string): Document | null | undefined {
361361
return this.documentsManager.getDocument(uri)
362362
}
363363

364364
public hasDocument(uri: string, version?: number): boolean {
365365
let doc = this.documentsManager.getDocument(uri)
366-
return doc != null && (version != null ? doc.version == version : true)
366+
return doc && (version != null ? doc.version == version : true)
367367
}
368368

369369
public getUri(bufnr: number, defaultValue = ''): string {

typings/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8934,7 +8934,7 @@ declare module 'coc.nvim' {
89348934
/**
89358935
* Get created document by uri or bufnr.
89368936
*/
8937-
export function getDocument(uri: number | string): Document
8937+
export function getDocument(uri: number | string): Document | null | undefined
89388938

89398939
/**
89408940
* Apply WorkspaceEdit.

0 commit comments

Comments
 (0)