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

Cannot define a module for a specific file extension in 2.4.1 #16769

Closed
vekexasia opened this issue Jun 27, 2017 · 3 comments
Closed

Cannot define a module for a specific file extension in 2.4.1 #16769

vekexasia opened this issue Jun 27, 2017 · 3 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@vekexasia
Copy link

TypeScript Version: 2.4.1
Code

// A *self-contained* demonstration of the problem follows...
declare module "*.vue" {
  import Vue from 'vue'
  export default typeof Vue
}

Expected behavior:
A file with the above content used to work when importing .vue files.
In 2.4.1 It looks like the file is not taken into account as every .vue file gets imported as "string"?
Actual behavior:
Everything seems to be imported as string?

@vekexasia
Copy link
Author

That file is perfectly working in 2.3.4

@mhegazy
Copy link
Contributor

mhegazy commented Aug 23, 2017

The right hand side of an export default is an expression not a type. typeof Vue is just calling the regular JS typeof operator on the reference Vue; and that happens to be a string all the time..

This should have been an error to have an expression in an ambient context. the only possible value should be an identifier name. files #17991 to track it.

so for this definition, you need to change your declaration to be:

declare module "*.vue" {
    import Vue from 'vue'
    const _: typeof Vue;
    export default _;
}

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Aug 23, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 7, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants