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

Angular CLI compiler requires older Typescript #7625

Closed
jtsom opened this issue Sep 8, 2017 · 22 comments
Closed

Angular CLI compiler requires older Typescript #7625

jtsom opened this issue Sep 8, 2017 · 22 comments

Comments

@jtsom
Copy link
Contributor

jtsom commented Sep 8, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.0
node: 8.4.0
os: darwin x64
@angular/animations: 4.3.6
@angular/cdk: 2.0.0-beta.10
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/material: 2.0.0-beta.10
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.4.0
@angular/compiler-cli: 4.3.6
@angular/language-service: 4.3.6
typescript: 2.5.2

Repro steps.

Start up app with ng serve and this message is displayed:

@angular/compiler-cli@4.3.6 requires typescript@'>=2.1.0 <2.4.0' but 2.5.2 was found instead.
Using this version can result in undefined behaviour and difficult to debug problems.

Please run the following command to install a compatible version of TypeScript.

    npm install typescript@'>=2.1.0 <2.4.0'

To disable this warning run "ng set --global warnings.typescriptMismatch=false".
@kuncevic
Copy link

kuncevic commented Sep 8, 2017

Based on that commit it should allow 2.5+ but I have same issue even with 2.4.2 and angular 4.3.6

UPDATE: Based on that sounds like typescript: '>=2.4.0 <2.6.0' required angular compiler '>=5.0.0 <6.0.0'

@karser
Copy link

karser commented Sep 8, 2017

Newly created project with angular-cli@1.4.0 requires typescript@~2.3.3

@kondi
Copy link

kondi commented Sep 8, 2017

Is this requirement valid? My project looks fine with typescript@2.4.2 and I was planning to go for 2.5.x but now I am not sure if it is a good idea.

@kondi
Copy link

kondi commented Sep 8, 2017

Anyway it would be good if @angular/compiler-cli would define the correct peer dependency here: https://github.com/angular/angular/blob/4.4.x/packages/compiler-cli/package.json#L17. Not everybody is using angular-cli. I can understand the safety check, but I am not sure the matrix linked by kuncevic should be the correct place to specify the requirements.

@jtsom
Copy link
Contributor Author

jtsom commented Sep 8, 2017

There were no indications that this restriction would be implemented. The only thing I updated in my project was the CLI. The @angular/compiler-cli@4.3.6 has no problems previously.

@filipesilva
Copy link
Contributor

These versions shown in the warning are the ones recommended by the Angular team.

A lot of bugs that are reported are actually the result of using incompatible versions, and it is not clear at all what these versions are. This is not a new restriction: incompatible versions have caused problems for a while now.

It is true that other typescript versions may work in your particular project - but we cannot guarantee they will work. That is why we show a warning now (but not an error).

It became more important to alert users to what the recommended versions are because Angular version 5 is coming out and it has its own recommend set of typescript versions.

There are two factors preventing simply adding a strict dependency:

  • the CLI must support Angular versions 2, 4, and 5
  • Angular itself does not have a dependency/peer dependency on typescript

So it was better to show a warning than to prevent usage of other typescript versions. If you feel confident that your project should work with other versions of typescript, you can disable the warning. This is useful when using versions of libraries that specifically need typescript of a certain version for compilation to be successful.

@fmorriso
Copy link

fmorriso commented Sep 8, 2017

@filipesilva : Thanks for the high-level explanation.

For those of us who wish to "scout ahead" using TypeScript versions beyond what is recommended, is there a place where any known issues (with or without a fix/work-around) have been documented?

@xnnkmd
Copy link

xnnkmd commented Sep 13, 2017

@filipesilva See also #7678 which would help a lot related to the warning.

@TitaneBoy
Copy link

TitaneBoy commented Sep 20, 2017

Hi guys...
Having the same issue with @angular/compiler-cli@4.4.3

Node: 8.4.0
Typescript: 2.5.2

But as we can see in the package.json of angular/compiler-cli, it saids, in its peerDependencies, that it needs typescript ^2.0.2, and typescript@2.5.2 should meet this requirement

@Brocco Brocco added P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity1: confusing labels Sep 22, 2017
@dherges
Copy link

dherges commented Sep 27, 2017

Maybe the dependencies on typescript should be a peerDependencies?

A CLI project may now cause more confusion:

- node_modules
  |- @angular
     |- cli
        |- node_modules
           |- typescript # <- 2.5.x (from cli package.json >=2.0.0 < 2.6.0)
  |- typescript # <- 2.4.x (from package.json)
package.json

@filipesilva filipesilva added type: discussion and removed P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity1: confusing labels Sep 27, 2017
@calvellido
Copy link

In my case I am quite used to work with the spread operator, also using it to pass parameters to functions, and I need to use Typescript@>=2.4.0 to compile a project created with Angular CLI 4.3.6, as this issue was resolved in TypeScript 2.4 microsoft/TypeScript#5296.

But the reasoning given is quite valid, and you can upgrade TypeScript per project to see if it fits for you or not.

Thanks, and keep the good work team ❤️

calvellido added a commit to frees-io/freestyle-opscenter-webclient that referenced this issue Sep 29, 2017
* This is due to a bug about spread operator usage fixed on TypeScript 2.4.0 (microsoft/TypeScript#5296)
* With this change now a warning will be given about the TS version used. This is expected, you see the discussion about it  on angular/angular-cli#7625
@filipesilva
Copy link
Contributor

@dherges that's actually a limitation of the CLI architecture currently... the CLI (specifically ngtools/webpack) really wants to use the local project typescript, but the global CLI doesn't have a local project and thus it would have missing peerdeps.

The answer is, of course, to have two CLI packages: one for global and one for local, installing different dependencies. This is a goal for CLI 2.0, but would be disruptive now so we don't do it.

@dherges
Copy link

dherges commented Oct 2, 2017 via email

@filipesilva
Copy link
Contributor

It would, but asking people to install both the cli and typescript globally isn't a good solution either imho.

@dherges
Copy link

dherges commented Oct 27, 2017

Is it right, that anguilar cli now uses the typescript version installed ion the user's project workspace?

fix(@angular/cli): remove typescript dependency
a28a967
#8185

@filipesilva
Copy link
Contributor

@dherges it almost always did, except when the dependency wasn't hoisted. That PR is meant to address that case.

@CreepyGnome
Copy link

CreepyGnome commented May 14, 2019

It seems this is still the case today that the latest Angular Compiler requires an older version of TypeScript, but just the compiler. I mean we are talking minor version limitations not major versions this seems odd. It should require just a min or greater version and block the next major version.

Currently today you get this error:

The Angular Compiler requires TypeScript >=3.1.1 and <3.3.0 but 3.4.5 was found instead.

Seem like it should just require TypeScript >=3.1.1 and <4.0.0 until there is a broken minor release which would hopefully be rare.

Should we just always assume that if we want to use the latest stable release of Angular we always have to run versions behind the latest stable version of Typescript?

@alan-agius4
Copy link
Collaborator

@CreepyGnome, Typescript minor version can be breaking and that's why we only support versions that have been released.

@CreepyGnome
Copy link

Currently, it doesn't support anything newer than 3.2.4 and there have been other released versions since then. The current released version is Typescript 3.4.5.

So based on your statement shouldn't Typescript 3.4.5 be supported then?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented May 14, 2019

It is supported in version 8 release candidate.

@alan-agius4
Copy link
Collaborator

Closing the initial reported issue should be solved by now.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
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