@@ -18,6 +18,7 @@ import {
1818 IApiDefinitionReferenceParts
1919} from '../ApiDefinitionReference' ;
2020import { AstItemContainer } from './AstItemContainer' ;
21+ import { IPackageJson } from '@microsoft/node-core-library' ;
2122
2223/**
2324 * Indicates the type of definition represented by a AstItem object.
@@ -602,18 +603,17 @@ export abstract class AstItem {
602603 // Walk upwards from that directory until you find a directory containing package.json,
603604 // this is where the referenced type is located.
604605 // Example: "c:\users\<username>\sp-client\spfx-core\sp-core-library"
605- const typeReferencePackagePath : string | undefined = this . context . packageJsonLookup
606- . tryGetPackageFolder ( sourceFile . fileName ) ;
606+ const typeReferencePackageJson : IPackageJson | undefined = this . context . packageJsonLookup
607+ . tryLoadPackageJsonFor ( sourceFile . fileName ) ;
607608 // Example: "@microsoft/sp-core-library"
608609 let typeReferencePackageName : string = '' ;
609610
610611 // If we can not find a package path, we consider the type to be part of the current project's package.
611612 // One case where this happens is when looking for a type that is a symlink
612- if ( ! typeReferencePackagePath ) {
613+ if ( ! typeReferencePackageJson ) {
613614 typeReferencePackageName = this . context . package . name ;
614615 } else {
615- typeReferencePackageName = this . context . packageJsonLookup
616- . getPackageName ( typeReferencePackagePath ) ;
616+ typeReferencePackageName = typeReferencePackageJson . name ;
617617
618618 typingsScopeNames . every ( typingScopeName => {
619619 if ( typeReferencePackageName . indexOf ( typingScopeName ) > - 1 ) {
@@ -630,7 +630,7 @@ export abstract class AstItem {
630630 const currentPackageName : string = this . context . package . name ;
631631
632632 const typeName : string = typeReferenceNode . typeName . getText ( ) ;
633- if ( ! typeReferencePackagePath || typeReferencePackageName === currentPackageName ) {
633+ if ( ! typeReferencePackageJson || typeReferencePackageName === currentPackageName ) {
634634 // The type is defined in this project. Did the person remember to export it?
635635 const exportedLocalName : string | undefined = this . context . package . tryGetExportedSymbolName ( currentSymbol ) ;
636636 if ( exportedLocalName ) {
0 commit comments