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

Allow custom static analysis, esp. for Jquery selectors #2738

Closed
wizofaus opened this issue Apr 13, 2015 · 3 comments
Closed

Allow custom static analysis, esp. for Jquery selectors #2738

wizofaus opened this issue Apr 13, 2015 · 3 comments
Labels
Duplicate An existing issue was already created Suggestion An idea for TypeScript

Comments

@wizofaus
Copy link

I'm using TypeScript quite heavily now, and loving the static/compile-time checking that I've always felt was sorely missing with JS-based development, but I'd love even more, especially for JQuery selectors. E.g. if my .ts file is used by an .aspx or .html page I want to know when I've misspelled an ID or classname or pseudo-class in a jquery selector, or I've got the wrong syntax. I'd be happy to add this sort of thing myself (I understand it's not integral to TypeScript itself) but is there a plugin mechanism for TypeScript's static-analysis module to do this? Ideally I'd even be able to write it so that TypeScript knows the object type from a Jquery selector - e.g. if I use $("select").each((i,e)=>{ e.selectedIndex = -1 }) that should compile because the use of "select" means the element type is HTMLSelectElement.

@CyrusNajmabadi
Copy link
Contributor

if I use $("select").each((i,e)=>{ e.selectedIndex = -1 }) that should compile because the use of "select" means the element type is HTMLSelectElement.

Ideally, there would be some string-overload of $ that indicated that. it should look something like:

declare function $(v: "select"): HTMLSelectElement;

@danquirk
Copy link
Member

In general the VS HTML editor and backing JS/TS could be much more aware of one another's contents (and error/suggest things appropriately).

@danquirk danquirk added the Suggestion An idea for TypeScript label Apr 13, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Dec 10, 2015

Looks like a dupe of #3136

@mhegazy mhegazy closed this as completed Dec 10, 2015
@mhegazy mhegazy added the Duplicate An existing issue was already created label Dec 10, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 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 Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants