-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Fix importing generic types #312
base: master
Are you sure you want to change the base?
Conversation
…ixing 'fileExists'
I was following https://stackoverflow.com/questions/50526710/typescript-compiler-api-get-type-of-imported-names for how to get the type of the imported object. (tl;dr: let symbol = checker.getSymbolAtLocation(imp.name)
let type = checker.getDeclaredTypeOfSymbol(symbol); The change in CompilerHost was neccessary because without it it would always return undefined. With this change it returns a valid type. |
Note: i had to switch to synchronous IO otherwise the test would read back an empty file
This actually fixes two things:
If I did |
There is one pending issue with importing generics - classes and interfaces work, aliases don't. example: file 1 declare interface IGenericInterface<T> { value: T }
declare class GenericClass<T> { value: T }
declare type GenericAlias<T> = { value : T }
export { IGenericInterface, GenericClass, GenericAlias } file 2: import { IGenericInterface, GenericClass, GenericAlias } from './core/other'; will generate type IGenericInterface<'T> = __core_other.IGenericInterface<'T>
type GenericClass<'T> = __core_other.GenericClass<'T>
type GenericAlias = __core_other.GenericAlias when the last line should be type GenericAlias<'T> = __core_other.GenericAlias<'T> But I can't get them the same way, Would you pull this anyway? Even though it is incomplete, it's still better than before :D |
I've merged master - I had wanted to do a few smaller PRs instead of one big one, but that kinda backfired. Also I found another issue: default exports are not correctly exported, so it isn't 100% finished. I'll try to complete that and add a unit test. |
If I have two files where I export and import a generic type
and
then it currently generates invalid F# code.