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

JavaScript: casting with "checkJs": true #16881

Closed
bruce965 opened this issue Jul 1, 2017 · 1 comment
Closed

JavaScript: casting with "checkJs": true #16881

bruce965 opened this issue Jul 1, 2017 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@bruce965
Copy link

bruce965 commented Jul 1, 2017

I opened a question on StackOverflow and got no answers, so I guess this is still a missing feature.

I'm looking for a way to do a cast with JavaScript Language Service code-checker enabled.

TypeScript Version: 2.4.1 / 2.5.0-dev.20170629

// JavaScript

const something = window.something;
// TypeScript equivalent

const something: SomethingConstructor = (window as any).something;
// JavaScript with checkJs

const anyWindow = (/** @type {any} */(window));  // Property 'something' does not exist on type 'Window'.
const something = (/** @type {SomethingConstructor} */(anyWindow.something));
// Workaround for this specific situation

/** @type {any} */
const anyWindow = window;
/** @type {SomethingConstructor} */
const something = anyWindow.something;

References:

#9694

@rbuckton rbuckton added the Duplicate An existing issue was already created label Aug 5, 2017
@rbuckton
Copy link
Member

rbuckton commented Aug 5, 2017

This is a duplicate of #5158.

@rbuckton rbuckton closed this as completed Aug 5, 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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants