Skip to content

Commit 1074231

Browse files
authored
fix(concatjs): resolve error with TypeScript 4.7 (#3420)
In TypeScript 4.7 the first argument of `resolveTypeReferenceDirectives` can be a `FileReference[]`, in addition to a `string[]`. These changes resolve a runtime error that was happening as result.
1 parent 5d1c2ad commit 1074231

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎packages/concatjs/internal/tsc_wrapped/compiler_host.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,32 +401,33 @@ export class CompilerHost implements ts.CompilerHost, tsickle.TsickleHost {
401401
* typescript secondary search behavior needs to be overridden to support
402402
* looking under `bazelOpts.nodeModulesPrefix`
403403
*/
404-
resolveTypeReferenceDirectives(names: string[],containingFile: string): ts.ResolvedTypeReferenceDirective[]{
404+
resolveTypeReferenceDirectives(names: string[]|ts.FileReference[],containingFile: string): ts.ResolvedTypeReferenceDirective[]{
405405
if(!this.allowActionInputReads)return[];
406406
constresult: ts.ResolvedTypeReferenceDirective[]=[];
407407
names.forEach(name=>{
408+
constfileName=typeofname==='string' ? name : name.fileName;
408409
letresolved: ts.ResolvedTypeReferenceDirective|undefined;
409410

410411
// primary search
411412
if(this.options.typeRoots){
412413
this.options.typeRoots.forEach(typeRoot=>{
413414
if(!resolved){
414-
resolved=this.resolveTypingFromDirectory(path.posix.join(typeRoot,name),true);
415+
resolved=this.resolveTypingFromDirectory(path.posix.join(typeRoot,fileName),true);
415416
}
416417
});
417418
}
418419

419420
// secondary search
420421
if(!resolved){
421-
resolved=this.resolveTypingFromDirectory(path.posix.join(this.bazelOpts.nodeModulesPrefix,name),false);
422+
resolved=this.resolveTypingFromDirectory(path.posix.join(this.bazelOpts.nodeModulesPrefix,fileName),false);
422423
}
423424

424425
// Types not resolved should be silently ignored. Leave it to Typescript
425426
// to either error out with "TS2688: Cannot find type definition file for
426427
// 'foo'" or for the build to fail due to a missing type that is used.
427428
if(!resolved){
428429
if(DEBUG){
429-
debug(`Failed to resolve type reference directive '${name}'`);
430+
debug(`Failed to resolve type reference directive '${fileName}'`);
430431
}
431432
return;
432433
}

0 commit comments

Comments
 (0)