Skip to content

Support lib property in tsconfig.json #918

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

Closed
michaelmesser opened this issue Apr 12, 2016 · 24 comments
Closed

Support lib property in tsconfig.json #918

michaelmesser opened this issue Apr 12, 2016 · 24 comments

Comments

@michaelmesser
Copy link

When I use the new lib property in tsconfig.json I get an error (works fine with tsc).

@basarat
Copy link
Member

basarat commented Apr 12, 2016

Note : this is flag that I believe the user is speaking of : microsoft/TypeScript#6974 🌹

@michaelmesser
Copy link
Author

Working on PR

@michaelmesser
Copy link
Author

How would I add a array of strings property? I see string, boolean, and number. Should I extend the validator to deal with arrays or just write code specific to the lib property?

@basarat
Copy link
Member

basarat commented Apr 13, 2016

Should I extend the validator to deal with arrays or just write code specific to the lib property

Nothing stays simple ¯\_(ツ)_/¯ (simpleValidator.ts) 🌹

Add an any type to Simple Validator and don't do any validation / error reporting < this would be the quickest way. I'd like to move to better JSON validation / autocomplete in the future so don't invest too much of your 😓 and 🔴

@michaelmesser
Copy link
Author

@basarat http://json-schema.org/ looks like a decent JSON validator. I believe there is an atom plugin with autocomplete.

@michaelmesser
Copy link
Author

https://github.com/OmniSharp/atom-json-schema/blob/master/README.md

@michaelmesser
Copy link
Author

I got the lib property to pass validation but it does not work.

@basarat
Copy link
Member

basarat commented Apr 17, 2016

I got the lib property to pass validation but it does not work.

Guess you need to change the lib.d.ts adding logic : https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/lang/core/languageServiceHost2.ts#L226-L228 🌹

@michaelmesser
Copy link
Author

Is there a way to access the compiler host from atom-typescript?

On Apr 17, 2016, at 5:54 AM, Basarat Ali Syed [email protected] wrote:

I got the lib property to pass validation but it does not work.

Guess you need to change the lib.d.ts adding logic : https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/lang/core/languageServiceHost2.ts#L226-L228 https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/lang/core/languageServiceHost2.ts#L226-L228


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub #918 (comment)

@michaelmesser
Copy link
Author

Someone already wrote a json-schema definition for tsconfig.json. http://json.schemastore.org/tsconfig

@michaelmesser
Copy link
Author

https://github.com/bali182/autocomplete-json is another atom plugin

@basarat
Copy link
Member

basarat commented Apr 24, 2016

I did a quick readthrough of the vscode codebase. It seems to have its schema validator a bit custom : https://github.com/Microsoft/vscode/blob/42a2cd566530c5ba1f5dd3ad9bacd454579cbc49/src/vs/languages/json/common/jsonSchemaService.ts

So for alm I'll be extending simpleValidator to support the full tsconfig validation in its current state. Even then it should be simpler than creating a jsonschema validator. I'll think through adding json autocomplete later

@basarat
Copy link
Member

basarat commented Apr 24, 2016

http://json.schemastore.org/tsconfig

FWIW this is missing a lot of options including lib :-/ so definitely not worth using for cutting edge stuff.

That said I wrote a bunch of start from scratch tsconfig.json handling in alm and I got it working. You are welcome to jump over there and see files like tsconfig.ts / typescriptDir.ts / tsconfigValidation.ts / projectDataLoader.ts.

In the end is just a matter of loading the right lib.d.ts into the compilation context (in the language service host I pointed to in atom-typescript code base) so that is still worth a try if someone wants to do a lazy PR.

More details : microsoft/TypeScript#6974 (comment)

@basarat
Copy link
Member

basarat commented Apr 24, 2016

How would I add a array of strings property? I see string, boolean, and number.

Also apparently it is still a string. Nevertheless I've asked for a clarification : microsoft/TypeScript#6974 (comment) 🌹

@michaelmesser
Copy link
Author

@basarat I have some code a think should work but for some reason it does not. console.log and debugger statements don't work for some odd reason so I can't figure out why it is failing.

@michaelmesser
Copy link
Author

@basarat
Copy link
Member

basarat commented Apr 24, 2016

@2426021684 it is an array after parsing for sure. But I am questioning the before parsing state:

From microsoft/TypeScript#6974

image

If you can find something / code that says otherwise it would be awesome. I don't like its not an array microsoft/TypeScript#6974 (comment) 🌹

@michaelmesser
Copy link
Author

"lib": "es5,es6.array" -> error TS5024: Compiler option 'lib' requires a value of type list.
"lib": ["es5", "es6.array"] -> Works fine
Version 1.9.0-dev.20160424

@basarat
Copy link
Member

basarat commented Apr 25, 2016

@2426021684 awesome. Thanks! I'll clean up alm 🌹

@michaelmesser
Copy link
Author

My plan for making lib work won’t work. I tried to port typescript's implementation but even though the methods I need are accessible they don’t work. It errors about __filename being undefined when typescript’s internal code tries to get the lib to load. Maybe I can get the lib path from the path to typescript services.js.

On Apr 24, 2016, at 9:54 PM, Basarat Ali Syed [email protected] wrote:

@2426021684 https://github.com/2426021684 awesome. Thanks! I'll clean up alm


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #918 (comment)

@basarat
Copy link
Member

basarat commented Apr 25, 2016

Maybe I can get the lib path from the path to typescript services.js.

That's what I do in atom-ts languageServiceHost2 as well as in alm's typescriptDir.ts

@alexeagle
Copy link

typescript includes APIs to parse the JSON (they handle comments) and create the CompilerOptions from it.
I think this is referred to with https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/tsconfig/tsconfig.ts#L9

Isn't the answer to delete all the configuration code and just use the API from the TS language service?

@basarat
Copy link
Member

basarat commented Jun 17, 2016

Isn't the answer to delete all the configuration code and just use the API from the TS language service?

Not quite. That api just returns the compilerOptions object (containing the value of lib). How that option is handled is still up to the language tools author. Essentially we need a function like this (from the alm source code) : https://github.com/alm-tools/alm/blob/5fef6d6b0f52ae08b52cea23241ed2d5f56d7236/src/server/workers/lang/core/typeScriptDir.ts#L12-L22

I've mentioned the need for such a public function here as well : microsoft/TypeScript#6974 (comment) 🌹

@github-actions
Copy link

github-actions bot commented Jan 1, 2020

This issue has been marked as stale because it did not have any activity for the last 90 days or more. Remove the stale label or comment or this will be closed in 14 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants