Change jquery.js to jquery.ts suppose to compile?

Topics: General
Mar 14, 2013 at 8:21 AM
Which I suppose it should work, But it actually gives plenty of compiled errors.
FelixMBPR:markdown sunfmin$ tsc main.ts --out a.js
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,2711): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,5887): Incompatible return type
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,5963): Incompatible return type
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,6590): Operator '?' cannot be applied to types 'number' and 'bool'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,6409): The property 'elem' does not exist on value of type '() => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,7706): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,8097): Operator '?' cannot be applied to types 'string' and 'number'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,8964): The property 'opacity' does not exist on value of type '{ height: any; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,8974): The property 'width' does not exist on value of type '{ height: any; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,10099): Operator '?' cannot be applied to types 'any[]' and 'RegExpExecArray'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,15796): Cannot convert 'number' to 'string'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,16496): The property 'doScroll' does not exist on value of type 'bool'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,16540): The property 'doScroll' does not exist on value of type 'bool'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,18090): The property 'done' does not exist on value of type '{}'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,44650): The property 'guid' does not exist on value of type '(c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,47804): Supplied parameters do not match any signature of call target:
    Type 'Number' is missing property 'exec' from type 'RegExp':
    Type 'Number' is missing property 'exec' from type 'RegExp'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,51393): Operator '*' cannot be applied to types 'number' and 'bool'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,56710): Cannot convert 'number' to 'bool'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,59340): Cannot convert 'RegExp' to 'any[]'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,59416): The property 'test' does not exist on value of type 'any[]'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,59940): Cannot convert 'RegExp' to 'string[]'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,60034): The property 'test' does not exist on value of type 'string[]'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,60051): The property 'test' does not exist on value of type 'any[]'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,45229): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,63985): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64039): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64076): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64104): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64147): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64200): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64266): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64296): Incompatible types in array literal expression
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64361): The property 'optgroup' does not exist on value of type '{ option: any[]; legend: any[]; thead: any[]; tr: any[]; td: any[]; col: any[]; area: any[]; _default: any[]; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64383): The property 'tbody' does not exist on value of type '{ option: any[]; legend: any[]; thead: any[]; tr: any[]; td: any[]; col: any[]; area: any[]; _default: any[]; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64392): The property 'tfoot' does not exist on value of type '{ option: any[]; legend: any[]; thead: any[]; tr: any[]; td: any[]; col: any[]; area: any[]; _default: any[]; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64401): The property 'colgroup' does not exist on value of type '{ option: any[]; legend: any[]; thead: any[]; tr: any[]; td: any[]; col: any[]; area: any[]; _default: any[]; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64413): The property 'caption' does not exist on value of type '{ option: any[]; legend: any[]; thead: any[]; tr: any[]; td: any[]; col: any[]; area: any[]; _default: any[]; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,64433): The property 'th' does not exist on value of type '{ option: any[]; legend: any[]; thead: any[]; tr: any[]; td: any[]; col: any[]; area: any[]; _default: any[]; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72082): The property 'fn' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72117): The property 'superclass' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72135): The property 'fn' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72159): The property 'fn' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72178): The property 'sub' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72193): The property 'fn' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72265): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72330): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72301): The property 'fn' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72321): The property 'fn' does not exist on value of type '(b: any, c: any) => any'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,72950): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,73098): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,77941): Operator '+' cannot be applied to types 'string[]' and 'string[]'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,80877): Supplied parameters do not match any signature of call target
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,79971): The property 'status' does not exist on value of type '{ readyState: number; setRequestHeader: (a: any, b: any) => any; getAllResponseHeaders: () => any; getResponseHeader: (a: any) => any; overrideMimeType: (a: any) => any; abort: (a: any) => any; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,79982): The property 'statusText' does not exist on value of type '{ readyState: number; setRequestHeader: (a: any, b: any) => any; getAllResponseHeaders: () => any; getResponseHeader: (a: any) => any; overrideMimeType: (a: any) => any; abort: (a: any) => any; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,80056): The property 'statusCode' does not exist on value of type '{ readyState: number; setRequestHeader: (a: any, b: any) => any; getAllResponseHeaders: () => any; getResponseHeader: (a: any) => any; overrideMimeType: (a: any) => any; abort: (a: any) => any; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,80906): The property 'success' does not exist on value of type '{ readyState: number; setRequestHeader: (a: any, b: any) => any; getAllResponseHeaders: () => any; getResponseHeader: (a: any) => any; overrideMimeType: (a: any) => any; abort: (a: any) => any; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,80916): The property 'done' does not exist on value of type '{ readyState: number; setRequestHeader: (a: any, b: any) => any; getAllResponseHeaders: () => any; getResponseHeader: (a: any) => any; overrideMimeType: (a: any) => any; abort: (a: any) => any; }'
/Users/sunfmin/WebstormProjects/typescriptest/markdown/jquery.ts(2,80923): The property 'error' does not exist on value of type '{ readyState: number; setRequestHeader: (a: any, b: any) => any; getAllResponseHeaders: () => any; getResponseHeader: (a: any) => any; overrideMimeType: (a: any) => any; abort: (a: any) => any; }'
Coordinator
Mar 14, 2013 at 3:52 PM
Type errors in TypeScript should probably be called "type warnings". Taking a quick look through that list, it looks like the issues are type-related. If so, the compiler will warn about the things it can't reason about but will still output a .js file.

If the compiler doesn't output a working .js file from a valid ES5 .js file that's been renamed to .ts, then that's a bug.
Mar 15, 2013 at 6:13 AM
Edited Mar 15, 2013 at 6:15 AM
Can I suppress these warnings? Think about this situation, I have a bunch of javascript files, But I want to change some of them, I think that's what TypeScript (different or better from dart lang for example) provides, let you adding types to your JavaScript little by little, And If It gives me errors on those .js files that I starting changing to .ts, Then I couldn't depend on the errors report any more. which lose the meaning of compiling.

I think warnings which the compiler still output .js file and errors which stops the compiler output .js file should be separated, So that I know when errors happened, I needs to fix my .ts file, But when warning happend, I can ignore.
Coordinator
Mar 18, 2013 at 3:18 PM
The warnings are in some sense one of the major features of TypeScript, they're the "lint" or "static analysis". When converting source from .js to .ts, it's normal to get warnings, just as when you first begin to lint a file you expect to see warnings (unless you've planned ahead for it). I've generally seen teams convert a file at a time (or directory at a time), going after small files first. That gives them a way of convert code gradually and addressing these warnings as the come up. If you tackle a large file at once, I'd expect what you're seeing, a lot of warnings that you'll need to massage by adding type annotations.

Yes, I agree that warnings and errors need to have cleaner distinction. We could definitely improve there (and we are working on it).
Mar 18, 2013 at 4:06 PM
Thanks a lot for replying me, looking forward to this improvement!
Mar 19, 2013 at 11:35 AM
Maybe the messages should indicate an information whether it is a warning or an error. :-)