Skip to content

Commit

Permalink
fix(typings): getDocument return type. (#5132)
Browse files Browse the repository at this point in the history
  • Loading branch information
weirongxu committed Aug 31, 2024
1 parent d4ff928 commit 9c25f2f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default class Documents implements Disposable {
return docs
}

public getDocument(uri: number | string, caseInsensitive = platform.isWindows || platform.isMacintosh): Document | null {
public getDocument(uri: number | string, caseInsensitive = platform.isWindows || platform.isMacintosh): Document | null | undefined {
if (typeof uri === 'number') {
return this.buffers.get(uri)
}
Expand Down
4 changes: 2 additions & 2 deletions src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ export class Workspace {
/**
* Get created document by uri or bufnr.
*/
public getDocument(uri: number | string): Document | null {
public getDocument(uri: number | string): Document | null | undefined {
return this.documentsManager.getDocument(uri)
}

public hasDocument(uri: string, version?: number): boolean {
let doc = this.documentsManager.getDocument(uri)
return doc != null && (version != null ? doc.version == version : true)
return doc && (version != null ? doc.version == version : true)
}

public getUri(bufnr: number, defaultValue = ''): string {
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8934,7 +8934,7 @@ declare module 'coc.nvim' {
/**
* Get created document by uri or bufnr.
*/
export function getDocument(uri: number | string): Document
export function getDocument(uri: number | string): Document | null | undefined

/**
* Apply WorkspaceEdit.
Expand Down

0 comments on commit 9c25f2f

Please sign in to comment.