StubCompilerHost should contain all files in the TS program
Closed this issue · 0 comments
Spent quite a long time digging into why the this.context
in many commands was failing... turns out TypeScript was trying to find the resolved modules relative to each command file, but they didn't exist because StubCompilerHost
only had the individual file being transformed in its this.sourceFiles
.
Rough notes...
Converting C:/Code/GLS/src/Rendering/Commands/VariableCommand.ts... Trying this.context.convertParsed(newParameters).commandResults[0].text Getting node 4 this.context.convertParsed(newParameters) Error at getNodeLinks (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:30080:63) at getResolvedSignature (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:47327:25) at checkCallExpression (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:47423:29) at checkExpressionWorker (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:49178:28) at checkExpression (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:49115:42) at checkNonNullExpression (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:45513:37) at checkPropertyAccessExpressionOrQualifiedName (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:45539:28) at checkPropertyAccessExpression (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:45532:20) at checkExpressionWorker (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:49169:28) at checkExpression (C:\Code\TS-GLS\node_modules\typescript\lib\typescript.js:49115:42) > 1 undefinednode.getText()
"this"
6 error
instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
TypeObject {checker: Object, flags: 65536, id: 44, isThisType: true, symbol: SymbolObject, …}
checker: Object {getNodeCount: , getIdentifierCount: , getSymbolCount: , …}
constraint: TypeObject {checker: Object, flags: 131072, id: 43, …}
flags: 65536
id: 44
isThisType: true
symbol: SymbolObject {flags: 32, escapedName: "VariableCommand", declarations: Array(1), …}
proto: Object {getFlags: , getSymbol: , getProperties: , …}
node.getText()
"this.context"
left.getText()
"this"
right.getText()
"context"
leftType
TypeObject {checker: Object, flags: 65536, id: 44, isThisType: true, symbol: SymbolObject, …}
checker: Object {getNodeCount: , getIdentifierCount: , getSymbolCount: , …}
constraint: TypeObject {checker: Object, flags: 131072, id: 43, …}
flags: 65536
id: 44
isThisType: true
symbol: SymbolObject {flags: 32, escapedName: "VariableCommand", declarations: Array(1), …}
proto: Object {getFlags: , getSymbol: , getProperties: , …}
...
var prop = getPropertyOfType(apparentType, right.escapedText);
node.getText()
"this.context"
left.getText()
"this"
right.escapedText
"context"
this does not seem to have "context"...?
Debugged into type resolution. Found getBaseConstructorTypeOfClass
when I come here first, type.resolvedBaseConstructorType is {errorType} :(
checking: set to undefined?
ts.getEffectiveBaseTypeNode(decl).getText() is "Command" yes (it's after the extends)
also getBaseTypeNodeOfClass(type).getText()
checkExpression(baseTypeNode.expression); is {errorType}
recursing into checks to get the Command
getResolvedSymbol(node); is Command; checkIdentifier knows it's not errorType
Going into getTypeOfSymbol(symbol) where symbol still has "Command"
getTypeOfAlias
symbolLinks[4] is the {errorType}... :(
...
put a breakpoint for symbolId === 4 in there.
first hit by resolveAlias(symbol)
...which gives an unknown symbol from getTargetOfAliasDeclaration(node)?
getTargetOfImportSpecifier
Both give undefined:
var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217
var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias);
Within resolveExternalModule:
ts.getResolvedModule(currentSourceFile, moduleReference); gives undefined
sourceFile.resolvedModules
Map(5) {}
[[Entries]]:Array(5)
length:5
0:{"../LineResults" => undefined} {key: "../LineResults", value: undefined}
1:{"./Command" => undefined} {key: "./Command", value: undefined}
2:{"./CommandNames" => undefined} {key: "./CommandNames", value: undefined}
3:{"./Metadata/CommandMetadata" => undefined} {key: "./Metadata/CommandMetadata", value: undefined}
4:{"./Metadata/Parameters/SingleParameter" => undefined} {key: "./Metadata/Parameters/SingleParameter", value: undefined}
size:5
proto:Map {constructor: , get: , set: , …}
sourceFile.resolvedModules.get(moduleNameText)
undefined
moduleNameText
"./Command"
Skipping to where this is set in processImportedModules:
var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState);
[undefined, undefined, undefined, undefined, undefined]
Is this the issue? That it can't resolve to the external files? WHy?
Oh geez. This is me.
Under resolveModuleNames, in my own StubCompilerHost
this.sourceFiles contains only the ones being compiled... but it should have everything under the project