Skip to content
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

Definition Files are interpreted as relative "paths" #12524

Closed
georgeedwards opened this issue Nov 27, 2016 · 1 comment
Closed

Definition Files are interpreted as relative "paths" #12524

georgeedwards opened this issue Nov 27, 2016 · 1 comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@georgeedwards
Copy link

TypeScript Version: 2.0.10
Code

declare module com {
    export module google {
        export module android {
            export module gms {
                export module auth {
                    export class GoogleAuthUtil {
                        public static getToken(param0: android.content.Context, param1: string, param2: string): string;
                    }
                }
            }
        }
    }
}
declare module android {
    declare module content {
        export class Context {
        }
    }
}

Expected behavior:
For tsc to interpret android.content.Context as an absolute path and as such look to the declare module android and find the exported class Context.

Actual behavior:
tsc interprets android.content.Context as a relative path, looks in the namespace com.google.android rather than android., can't find content.Context and throws an error.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 1, 2016

Please see relevant discussion in #983

There is no way to fully qualify a namespace from the global scope. The recommendation is to use aliasing to capture shadowed namespaces, i.e:

declare module com {
    import globalAndroid = android;
    export module google {
        export module android {
            export module gms {
                export module auth {
                    export class GoogleAuthUtil {
                        public static getToken(param0: globalAndroid.content.Context, param1: string, param2: string): string;
                    }
                }
            }
        }
    }
}
declare module android {
    module content {
        export class Context {
        }
    }
}

@mhegazy mhegazy added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Dec 1, 2016
@mhegazy mhegazy closed this as completed Apr 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

2 participants