You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should tsc file.jsbuild a file with the "compilerOptions" in TypeScript's config. Or should it compile a file and ignore the config? #29241
node_modules/rxjs/internal/Observable.d.ts:82:59 - error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
82 toPromise<T>(this: Observable<T>, PromiseCtor: typeof Promise): Promise<T>;
~~~~~~~
Found 1 error.
The error message says you should be targeting lib: "es2015”. Are you? Note that lib and target are distinct because of polyfills (you can polyfill builtins but not syntax)
Just a hunch, have you tried using lowercase for es2018? I know the docs show uppercase but I think that might be a mistake as I’ve always seen it lowercase in practice. Otherwise I have no clue what’s wrong here, it seems bizarre.
So I tried to reproduce this using the exact tsconfig, dependencies, and sample code as in the SO question... and it seems to work fine on my end. Node.js version is 11.6.0.
No idea, all I know is it's erroring with me and I'm not using any special layer so I'm trying to keep it simple and figure out why it's not erroring for you, and I'm thinking your npx is doing something.
Nope, here's the exact issue - you're telling tsc to transpile a single file. In that case it ignores the tsconfig.json and just transpiles the file in a vacuum, using all defaults for the tsconfig fields. Since there is no ///<reference> tag in the source for the es2015 lib you get the Promise error.
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.
Allowing to override tsconfig.json by passing a file path with tsc --noEmit -p tsconfig.json would be really useful and would avoid having multiple config files. Please reopen. Thank you!
Allowing to override tsconfig.json by passing a file path with tsc --noEmit -p tsconfig.json would be really useful and would avoid having multiple config files. Please reopen. Thank you!
This is already supported!
Please reopen; nonhumans closing issues is exceedingly user-hostile.
This is the intended behavior because we don't want to break thousands of msbuild-based compilations where people are using .csproj settings for one compilation and tsconfig.json for something else. Even issuing a warning when a tsconfig.json is present has the potential to break these builds because people might have warnings-as-errors turned on.
people are using .csproj settings for one compilation and tsconfig.json for something else
You can add --no-project flag for them (it's joke, don't bear on me 🙂).
Even issuing a warning when a tsconfig.json is present has the potential to break these builds because people might have warnings-as-errors turned on.
What about allowing to pass a list of files along with --project to override files to compile? It seems that it shouldn't break case you've described above.
Also, what's about compiler options which cannot be passed via CLI such paths (see #29241 (comment))?
What about allowing to pass a list of files along with --project to override files to compile?
See also #27379. I think there's also another issue where people expect to be able to augment the file list in this manner.
Also, what's about compiler options which cannot be passed via CLI
I think allowing some way of specifying additional tsconfig files (probably in a "config only" mode) would be a very reasonable suggestion. I know some teams are effectively doing this by auto-generating tsconfig files in their build scripts; it'd be nice to make that kind of automation unnecessary.
What about allowing to pass a list of files along with --project to override files to compile? It seems that it shouldn't break case you've described above.
Also, what's about compiler options which cannot be passed via CLI such paths (see #29241 (comment))?
This is exactly what I was trying to do and it doesn't work for me. I will look at versions for a new update if you're saying this is supported already.
Activity
fatcerberus commentedon Jan 3, 2019
The error message says you should be targeting
lib: "es2015”. Are you? Note thatlibandtargetare distinct because of polyfills (you can polyfill builtins but not syntax)EvanCarroll commentedon Jan 3, 2019
Bruce Pascoe (@fatcerberus) I have a sample repo with it, in that repo i'm doing es2018 for lib, but you can try es2015 same thing.
https://github.com/EvanCarroll/rxjsissue4448
fatcerberus commentedon Jan 3, 2019
Just a hunch, have you tried using lowercase for
es2018? I know the docs show uppercase but I think that might be a mistake as I’ve always seen it lowercase in practice. Otherwise I have no clue what’s wrong here, it seems bizarre.EvanCarroll commentedon Jan 3, 2019
It is lower case, no joy. It's also confirmed by the rxjs guys and the stackoverflow commenter. Nothing that uses promises works on node 11
fatcerberus commentedon Jan 3, 2019
What I don’t understand is what the node version has to do with this - typescript and node are completely separate tools.oh okay - I see, the issue is when the typescript compiler is run on node 11, not when targeting node 11. My bad.
fatcerberus commentedon Jan 3, 2019
So I tried to reproduce this using the exact tsconfig, dependencies, and sample code as in the SO question... and it seems to work fine on my end. Node.js version is 11.6.0.
EvanCarroll commentedon Jan 3, 2019
Did you pull down my repository run npm install and then try to tsc the file? I'm confused, you say this
Which is true, and then you say " it seems to work fine on my end. Node.js version is 11.6.0."
fatcerberus commentedon Jan 3, 2019
Yeah, that was before I tested it - that was just stating I understood why you mentioned the node version.
EvanCarroll commentedon Jan 3, 2019
I don't know what else to say, I got the prob. Guy on SO and on RXJS question got the prob. Repo is simple works (to show the problem) with the latest version of all tools. It's giving that error on running tsc on my box (running Linux).
EvanCarroll commentedon Jan 3, 2019
This is the line that's problematic for you, this is working?
fatcerberus commentedon Jan 3, 2019
Yeah, that works, as does:
v11.5 because I switched machines--still Node 11 though. Tested on both Windows and Linux (Ubuntu 16.04, Node.js installed from snap).
Only thing I can think of is you're somehow picking up a stale tsconfig.json from elsewhere.
EvanCarroll commentedon Jan 3, 2019
no idea what npx does, or what it's doing differently can you just run
tsc runme.tsc?fatcerberus commentedon Jan 3, 2019
It's the same thing -
tscby itself requires typescript installed globally,npxis when it's installed locally (in node_modules). Works either way.EvanCarroll commentedon Jan 3, 2019
No idea, all I know is it's erroring with me and I'm not using any special layer so I'm trying to keep it simple and figure out why it's not erroring for you, and I'm thinking your npx is doing something.
fatcerberus commentedon Jan 3, 2019
Nope, here's the exact issue - you're telling tsc to transpile a single file. In that case it ignores the tsconfig.json and just transpiles the file in a vacuum, using all defaults for the tsconfig fields. Since there is no
///<reference>tag in the source for the es2015 lib you get the Promise error.22 remaining items
kinowarrior commentedon May 4, 2019
Thanks for your help all. Problem solved here.
typescript-bot commentedon Jul 13, 2019
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.
chrisblossom commentedon Jul 13, 2019
Daniel Rosenwasser (@DanielRosenwasser) Ryan Cavanaugh (@RyanCavanaugh) It is very disappointing this hasn't been taken further into consideration. This is how 98% of javascript developers expect
tscto behave and would maketscconsistent with every other node tool out there.ljharb commentedon Jul 13, 2019
Please reopen; nonhumans closing issues is exceedingly user-hostile.
0vidiu commentedon Aug 6, 2019
Allowing to override
tsconfig.jsonby passing a file path withtsc --noEmit -p tsconfig.jsonwould be really useful and would avoid having multiple config files. Please reopen. Thank you!RyanCavanaugh commentedon Aug 6, 2019
This is already supported!
I will close this myself to help 😉
RyanCavanaugh commentedon Aug 6, 2019
This is the intended behavior because we don't want to break thousands of
msbuild-based compilations where people are using.csprojsettings for one compilation andtsconfig.jsonfor something else. Even issuing a warning when atsconfig.jsonis present has the potential to break these builds because people might have warnings-as-errors turned on.timocov commentedon Aug 6, 2019
You can add
--no-projectflag for them (it's joke, don't bear on me 🙂).What about allowing to pass a list of files along with
--projectto override files to compile? It seems that it shouldn't break case you've described above.Also, what's about compiler options which cannot be passed via CLI such
paths(see #29241 (comment))?Ryan Cavanaugh (@RyanCavanaugh)
RyanCavanaugh commentedon Aug 6, 2019
See also #27379. I think there's also another issue where people expect to be able to augment the file list in this manner.
I think allowing some way of specifying additional tsconfig files (probably in a "config only" mode) would be a very reasonable suggestion. I know some teams are effectively doing this by auto-generating tsconfig files in their build scripts; it'd be nice to make that kind of automation unnecessary.
0vidiu commentedon Aug 8, 2019
This is exactly what I was trying to do and it doesn't work for me. I will look at versions for a new update if you're saying this is supported already.