Closed brad-jones closed 7 years ago
Further to this I modded the TsMain class and provided my own compiler host as per the example here: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#customizing-module-resolution
I then setup the resolveModuleNames function to resolve my project root'ed modules correctly. This seemed to work however I now have the following output:
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]:
-----------------------------------------
Failed getting info from "BaseError".
Detail: Cannot read property 'getSymbol' of undefined
Stack: TypeError: Cannot read property 'getSymbol' of undefined
at TypeCacheContainer.getFileName (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/utils/TsCache.js:41:28)
at TypeCacheContainer.getCache (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/utils/TsCache.js:33:29)
at TsCache.getType (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/utils/TsCache.js:20:45)
at TsTypeNode.getTsTypeFromNode (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/TsTypeNode.js:107:29)
at TsTypeNode.getTypeAtLocationByNode (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/TsTypeNode.js:101:25)
at TsTypeNode.getType (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/TsTypeNode.js:75:21)
at TsFactory.getTypeFromTypeNode (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/factories/TsFactory.js:96:79)
at /home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/binders/ts/class/TsClassBinder.js:24:61
at Array.map (native)
at TsClassBinder.getExtendsTypes (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/binders/ts/class/TsClassBinder.js:24:14)
-----------------------------------------
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
[ts-type-info]: Unknown class child kind: AbstractKeyword
/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/utils/TsCache.js:41
var symbol = tsType.getSymbol();
^
TypeError: Cannot read property 'getSymbol' of undefined
at TypeCacheContainer.getFileName (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/utils/TsCache.js:41:28)
at TypeCacheContainer.getCache (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/utils/TsCache.js:33:29)
at TsCache.getType (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/utils/TsCache.js:20:45)
at TsTypeNode.getTsTypeFromNode (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/TsTypeNode.js:107:29)
at TsTypeNode.getTypeAtLocationByNode (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/TsTypeNode.js:101:25)
at TsTypeNode.getType (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/compiler/TsTypeNode.js:75:21)
at TsFactory.getTypeFromTypeNode (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/factories/TsFactory.js:96:79)
at /home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/binders/ts/class/TsClassBinder.js:24:61
at Array.map (native)
at TsClassBinder.getExtendsTypes (/home/brad/Projects/typescript-playground/node_modules/ts-type-info/dist/binders/ts/class/TsClassBinder.js:24:14)
Sorry for the long reply, Brad. I was away, but now I'm back. Thanks for your feedback and for opening this issue. I opened up a couple of issues because of it.
I'll reduce some of the noise in the log messages and investigate the error you're having. The part of the code that's throwing that error actually won't exist in the next minor revision, but I'll take a look to try to figure out why it was occurring to see if I'll need to fix the new code.
Cheers @dsherret looking forward to the updates.
If I can be of any further assistance let me know.
This should be fixed in 6.2. Let me know if my fix didn't work.
Note: The compiler api had some breaking changes that led me to implement #204 so hopefully it doesn't blow up. It's hard to account for every scenario.
By the way, I added #210 that allows you to pass in a custom compiler host.
@dsherret your a legend, works beautifully.
Now I just need to easily serialize the results of getInfoFromFiles so I can have fast reflection at runtime. Any progress on #123
@brad-jones I'm working on #208, which will allow me to more easily do that. I'm separating the definitions, writing and code generation, from the typescript compiler part of this library. Not sure how long it will take because I'm doing a major internal code refactoring to clean up some of the mess and simplify a few things.
Using this package out of the box, without any custom compiler options I get the following error:
On inspection of the stack trace, it is failing where it hits the class that "Foo" extends because it has not been able to resolve the imported parent class.
The TsNode contains:
I then attempted to provide my compiler options from my tsconfig.json file.
They look like this:
NOTE: I cast the CompilerOptions to to get them passed through.
After I did this I then got the following exception:
As you might have already worked out I have setup my environment to be able to require from the project root. This tsconfig.json works just fine in atom-typescript. ie: Atom resolves
app/Contracts/IFoo
without compliant. It would seem though that the baseUrl & paths properties are not being taken into to consideration when calling your reflection lib.