Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Upgrade to Typescript 2.1 #39

Closed
kipz opened this issue Dec 8, 2016 · 8 comments
Closed

Upgrade to Typescript 2.1 #39

kipz opened this issue Dec 8, 2016 · 8 comments
Assignees
Milestone

Comments

@kipz
Copy link
Contributor

kipz commented Dec 8, 2016

08:53]
cd we have one failing test with TypeScript 2.1.4

[08:53]

 com.atomist.rug.compiler.typescript.TypeScriptCompilationException: .atomist/ConstructedEditor.ts(41,11): error TS2365: Operator '!=' cannot be applied to types '1' and '0'.
.atomist/ConstructedEditor.ts(124,35): error TS2365: Operator '!=' cannot be applied to types '1' and '2'.
 at com.atomist.rug.compiler.typescript.TypeScriptCompiler.handleException(TypeScriptCompiler.java:86)
 at com.atomist.rug.compiler.typescript.TypeScriptCompiler.lambda$compile$0(TypeScriptCompiler.java:52)
 at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
 at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
 at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
 at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
 at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
 at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
 at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
 at com.atomist.rug.compiler.typescript.TypeScriptCompiler.compile(TypeScriptCompiler.java:55)```
(edited)

[08:53]  
^ @kipz

[08:54]  
https://github.com/atomist/rug-typescript-compiler/commit/3356ea7ba5a9c56781afae43dfc010a6e1dec5aa
@kipz kipz self-assigned this Dec 8, 2016
@kipz
Copy link
Contributor Author

kipz commented Dec 8, 2016

The following fails to compile.

function  edit() {
  let lyst: string[] = ["foo", "bar"]
  if(lyst.length !== 111){
      return "foo"
  }
  if(lyst.length !== 222){
      return "bar"
   }
}

This looks like a compiler bug to me at first glance - or we've been doing it wrong.

@kipz
Copy link
Contributor Author

kipz commented Dec 8, 2016

This succeeds:

function  edit() {
  let lyst: Array<string> = ["foo", "bar"]
  if(lyst.length !== new Number(111)){
      return "foo"
  }
  if(lyst.length !== new Number(222)){
      return "bar"
   }
}

@kipz
Copy link
Contributor Author

kipz commented Dec 8, 2016

It looks as if the compiler is assigning lyst.length the type '111' and therefore the comparison fails.

@kipz kipz closed this as completed Dec 8, 2016
@kipz kipz reopened this Dec 8, 2016
@kipz kipz removed their assignment Dec 8, 2016
@kipz
Copy link
Contributor Author

kipz commented Jan 3, 2017

This is probably a manifestation of:

https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#literal-types-are-inferred-by-default-for-const-variables-and-readonly-properties

because the following is fine:

function  edit()  {
  let lyst: string[] = ["foo", "bar"]
  if(lyst.length !== <number>111){
     return "foo"
  }
  if(lyst.length !== <number>222){
      return "bar"
   }
}

@cdupuis
Copy link
Contributor

cdupuis commented Jan 3, 2017

What should we do about this now? So we try again with 2.1?

@kipz kipz self-assigned this Jan 5, 2017
@kipz
Copy link
Contributor Author

kipz commented Jan 26, 2017

So some of these issues are related to the TypeScript type system being super (too) smart, but there are some genuine show-stoppers, unless I'm missing something:

microsoft/TypeScript#13697

@kipz
Copy link
Contributor Author

kipz commented Jan 27, 2017

So @cdupuis - I think we should go ahead and upgrade to 2.1.5. The TS guys do not consider these to be bugs - it's for developers to work around. So if we're sticking with TS, we should keep moving forward IMO.

@cdupuis
Copy link
Contributor

cdupuis commented Feb 7, 2017

I've now updated the compiler and released a new version 0.11.0.

@cdupuis cdupuis assigned kipz and unassigned cdupuis Feb 7, 2017
kipz added a commit that referenced this issue Feb 7, 2017
kipz added a commit that referenced this issue Feb 7, 2017
Upgrade TS compiler to 2.1.5 #39
@kipz kipz added this to the 0.11.0 milestone Feb 7, 2017
@kipz kipz closed this as completed Feb 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants