Skip to content

NullRef on processing 'export *' in several cases #2629

@zhuravlikjb

Description

@zhuravlikjb

Code:

class Bbb {
}

class Aaa extends Bbb { }

module Aaa {
    export class SomeType {}
}

module Bbb {
    export class SomeType { }

    export * from Aaa;      // this line causes the nullref
}

var a: Bbb.SomeType;

VS TypeScript add-on exception caught by ReSharper:

Object reference not set to an instance of an object.

--- EXCEPTION #1/2 [NullReferenceException]
Message = “Object reference not set to an instance of an object.”
ExceptionPath = Root.InnerException
ClassName = System.NullReferenceException
HResult = COR_E_NULLREFERENCE=E_POINTER=80004003
Source = Microsoft.CodeAnalysis.TypeScript.EditorFeatures
StackTraceString = “
  at Microsoft.CodeAnalysis.Editor.TypeScript.Features.CompileOnSave.CompileOnSaveHandler.<EmitAndSaveResultsAsync>d__1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.CodeAnalysis.Editor.TypeScript.Features.CompileOnSave.CompileOnSaveHandler.<HandleFileSave>d__1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__3(Object state)
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
     at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
”

This is what the compiler outputs:

C:\Users\Anton.Lobov\Desktop\ts-latest-github\TypeScript\built\local\tsc.js:1130
4
                if (symbol.flags & 1952 /* HasExports */ && !ts.contains(visit
                          ^
TypeError: Cannot read property 'flags' of undefined
    at visit (C:\Users\Anton.Lobov\Desktop\ts-latest-github\TypeScript\built\loc
al\tsc.js:11304:27)
    at visit (C:\Users\Anton.Lobov\Desktop\ts-latest-github\TypeScript\built\loc
al\tsc.js:11317:29)
    at getExportsForModule (C:\Users\Anton.Lobov\Desktop\ts-latest-github\TypeSc
ript\built\local\tsc.js:11299:13)
    at getExportsOfModule (C:\Users\Anton.Lobov\Desktop\ts-latest-github\TypeScr
ipt\built\local\tsc.js:11287:70)
    at getExportsOfSymbol (C:\Users\Anton.Lobov\Desktop\ts-latest-github\TypeScr
ipt\built\local\tsc.js:11283:55)
    at resolveAnonymousTypeMembers (C:\Users\Anton.Lobov\Desktop\ts-latest-githu
b\TypeScript\built\local\tsc.js:13022:31)
    at resolveObjectOrUnionTypeMembers (C:\Users\Anton.Lobov\Desktop\ts-latest-g
ithub\TypeScript\built\local\tsc.js:13049:21)
    at getTypeWithoutConstructors (C:\Users\Anton.Lobov\Desktop\ts-latest-github
\TypeScript\built\local\tsc.js:13988:32)
    at checkClassDeclaration (C:\Users\Anton.Lobov\Desktop\ts-latest-github\Type
Script\built\local\tsc.js:19364:55)
    at checkSourceElement (C:\Users\Anton.Lobov\Desktop\ts-latest-github\TypeScr
ipt\built\local\tsc.js:20108:28)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions