-
Notifications
You must be signed in to change notification settings - Fork 8
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
Why add both tsconfig.json and jsconfig.json? #73
Comments
@ericdrobinson In said plugins, the following {
"compilerOptions": {
"module": "commonjs",
"strict": true,
"target": "es2016",
"baseUrl": "./",
"allowJs": true,
"checkJs": true,
"resolveJsonModule": true,
"lib": [
"es2015",
"dom"
]
},
"include": [
"src/**/*",
"types/**/*"
]
} This appears to give me full plug-and-play autocompletion goodness in both WebStorm and VSCode (and probably a lot of other editors, Since this would basically simplify using it in projects for usage with Typescript and many (more?) editors, at first glance, it sounds like the preferable solution to me. For usage with {
"@types/adobe-xd": "git://github.com/AdobeXD/typings.git"
} is the preferred solution (although, for some reason I haven't found in two hours of debugging, this doesn't grant me access to global interfaces like Any thoughts?
Unfortunately (or maybe, fortunately, since allowing multiple ways also seems strange), UXP (for now) only supports CommonJS (and I haven't heard anything about that getting changed any time soon), so at least for now, |
@pklaschka You raise some excellent points here! I'll start by outlining my recommendation. Recommendation
Yes. Specifically:
Remember, the goal of a core repository like this isn't to provide users with a fully optimized solution out of the box, but to provide them with a basic feature set and notes about requirements that they can configure in their own project to match their needs and setup. The more options you configure, the more confusing it is to untangle the assumptions that the setup is making. For instance, the suggestion I outlined above already assumes the user uses How simple? The setup I outlined above allowed me to When I did add both a
{
"compilerOptions": {
"strict": true,
"target": "es2015",
"module": "CommonJS",
"lib": [
"es2015",
"dom"
]
}
}
{
"compilerOptions": {
"strict": true,
"target": "es2015",
"module": "CommonJS",
"checkJs": true,
"lib": [
"es2015",
"dom"
]
},
} Super simple. The only change on the JavaScript side that I noticed was that VSCode's autocomplete stopped suggesting keywords from the surrounding context (as the context was now made explicit). Here is a screenshot of the project I tossed together to showcase this: TypeScript to the left; JavaScript to the right. You will notice that there is no root-level config file: both I then installed TypeScript (the language service was using the version of TypeScript installed with VSCode itself) and ran that TypeScript compiler on my It's hard to think of a simpler way to handle this. As a side benefit, when a strategy for publishing the types is determined, updating the ReadMe file will be as simple as fixing the one Opinionated SetupsNone of this stops you from creating (and even linking to) a separate opinionated repository that does include such a fully optimized solution, of course. Systems like your Remember: each line you add to a config file (in this case What About the
|
And now, Regarding your suggestions: Sounds good, I'll work on updating the docs in the next few days, so expect to see a PR relatively soon 🙂. |
As a quick test, I made the organizational adjustments I suggested in the What About the [t/j]sconfig.json Files in This Repository? section of this comment. I found that a I added as few settings as possible to each in order to keep everything simple. What follows is what I came up with:
|
@pklaschka While testing something out, I added a I'll post their contents here in the event that it's something you're interested in adding to the project:
|
Just FYI: After further testing, I can conclude that JetBrains IDEs don't support |
Which IDE are you using? A quick Google search shows that there are lots of people using [EDIT] I'm not certain the gist I linked outlines how to use the |
The WebStorm 2019.2 release announcement even mentions |
My understanding is that any IDE that relies upon the TypeScript language service to handle JavaScript type checking will support the The JetBrains folks do their own magic for type checking JavaScript, using the At the end of the day, I don't really care if you use For clarity, which JetBrains IDE (including version number) are you using? |
@ericdrobinson The thing is that (to my knowledge, I don't have the time to find sources for this statement right now) Webstorm, unlike VSCode?, doesn't use TypeScript as a language server by default. When I add the I'm using WebStorm (latest version) as an IDE. |
It is actually the
|
Does the |
@ericdrobinson Yes: (it's basically my working |
Well it's really up to you. Perhaps you add a Perhaps it makes sense to file a bug with WebStorm to have it pick up on JavaScript type checking when a |
Sounds good.
When I find the time to properly confirm this behavior and write a bug report, I'll probably do that. As the exams at my university currently (once again) are getting closer and closer at an alarming rate, that'll still have to wait a bit, though... 😉 |
Declaring both
tsconfig.json
andjsconfig.json
is unnecessary (and actually a bit confusing). The presence of either will instruct the TypeScript Language Service that the containing folder is the root of a "Project" (for which the config file is the ruleset by which to process the project). If you specify both, then things become ambiguous...I would recommend removing the
tsconfig.json
file. This is due to the following reasons:tsconfig.json
and may have it set up for themselves.tsconfig.json
file makes certain assumptions that will not hold true for all projects:allowJS
andcheckJS
settings).node_modules
installed (see:types
andtypeRoots
properties).types
andtypeRoots
properties at all.To test a "minimal TypeScript project", I created a project that contained a
src
folder with a singletest.ts
file, thetypes
folder with all declarations in this project, and atsconfig.json
file with the following contents:All type declarations worked as expected and the compilation process proceeded without issue.
Rather than including a
tsconfig.json
file, it may be worthwhile to include a "Using these types with TypeScript" section in the ReadMe that calls out the settings above and explains why they're there. Specifically:Such a section might go on to suggest that:
Does this make sense?
SIDE NOTE: I added the
module
property to the JSON (as compared with the currenttsconfig.json
file, as TypeScript will output ES6-style moduleimport
statements rather thanrequire
, which I'm not sure if XD/UXP supports yet or not (doesn't appear to be listed in the documentation in any way). SpecifyingCommonJS
for themodule
property instructs the TypeScript compiler to output JavaScript code that usesrequire
.If ES6-style modules are actually supported, then removing this property would be spiffy.
The text was updated successfully, but these errors were encountered: