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

Can't get string literal completions for .js file if not --allowJs #18817

Closed
ghost opened this issue Sep 28, 2017 · 1 comment
Closed

Can't get string literal completions for .js file if not --allowJs #18817

ghost opened this issue Sep 28, 2017 · 1 comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@ghost
Copy link

ghost commented Sep 28, 2017

TypeScript Version: nightly (2.6.0-dev.20170928)

Code

a.d.ts

declare var x: { p: "a" | "b" };

b.js:

x = { /**/ }; // works, get completion for "p"
x.p = "/**/"; // don't get good completions

No tsconfig.json.

Expected behavior:

Get completions inside string literal in a .js file.

Actual behavior:

Get nothing.
If works if I add a tsconfig.json and set --allowJs.
If I enable // @ts-check, I correctly get an error if I use a wrong string literal, so we are picking up the types.
I'm not sure how to reproduce this error in a fourslash test, because apparently if I don't set // @allowJs: true, it can't find the b.js file. Here was my attempt:

/// <reference path="fourslash.ts" />

// @Filename: /a.d.ts
////declare var x: { p: "a" | "b" };

// @Filename: /b.js
////x = { p: "/**/" }

verify.completionsAt("", []);
@ghost
Copy link
Author

ghost commented Sep 28, 2017

Turns out this isn't about allowJs and I was confused due to the property names being "a" and "b" and thus coming up first in alphabetical order.

@ghost ghost closed this as completed in #18820 Oct 4, 2017
@mhegazy mhegazy added this to the TypeScript 2.6 milestone Oct 4, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Oct 4, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

1 participant