Skip to content

Commit df5c53c

Browse files
ayame113aminya
authored andcommitted
fix: modify the type to pass the test
1 parent 19614ce commit df5c53c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/adapters/definition-adapter.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ export default class DefinitionAdapter {
6868
* @param locationResult Either a single {Location} object or an {Array} of {Locations}.
6969
* @returns An {Array} of {Location}s or {null} if the locationResult was null.
7070
*/
71-
public static normalizeLocations(locationResult: Location | Location[] | LocationLink[]): Location[] | LocationLink[] | null {
71+
public static normalizeLocations(locationResult: Location | (Location | LocationLink)[]): (Location | LocationLink)[] | null {
7272
if (locationResult == null) {
7373
return null
7474
}
75-
return (Array.isArray(locationResult) ? locationResult : [locationResult]).filter((d) => (d.range||d.targetRange).start != null)
75+
return (Array.isArray(locationResult) ? locationResult : [locationResult]).filter((d) => ('range' in d?d.range:d.targetRange).start != null)
7676
}
7777

7878
/**
@@ -82,11 +82,11 @@ export default class DefinitionAdapter {
8282
* @param languageName The name of the language these objects are written in.
8383
* @returns An {Array} of {Definition}s that represented the converted {Location}s.
8484
*/
85-
public static convertLocationsToDefinitions(locations: Location[] | LocationLink[], languageName: string): atomIde.Definition[] {
85+
public static convertLocationsToDefinitions(locations: (Location | LocationLink)[], languageName: string): atomIde.Definition[] {
8686
return locations.map((d) => ({
87-
path: Convert.uriToPath(d.uri||d.targetUri),
88-
position: Convert.positionToPoint((d.range||d.targetRange).start),
89-
range: Range.fromObject(Convert.lsRangeToAtomRange(d.range||d.targetRange)),
87+
path: Convert.uriToPath('uri' in d?d.uri:d.targetUri),
88+
position: Convert.positionToPoint(('range' in d?d.range:d.targetRange).start),
89+
range: Range.fromObject(Convert.lsRangeToAtomRange('range' in d?d.range:d.targetRange)),
9090
language: languageName,
9191
}))
9292
}

0 commit comments

Comments
 (0)