-
Notifications
You must be signed in to change notification settings - Fork 14
Configure TypeScript validator with sensible defaults #40
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
Comments
I would like to avoid hard coding this rules (exclude node_modules, etc). My idea is to use tsconfig.json files and exclude like explained at http://www.typescriptlang.org/docs/handbook/tsconfig.json.html
It doesn't exists TypeScript nature today see #12 (comment)
I know, I think it's more an issue with WTP. If I have a simple idea, I will implement it, but I don't want to take time about that. |
+1 to honor tsconfig.json for includes and excludes. Although there is no “TypeScript nature“ currently, I think if it is available is more newbies friendly than activate the validator. Continue your awesome work. I’m waiting for the first release to migrate from atom to eclipse. |
@micaelgallego I have implemented my idea with tsconfig.json. I will update the wiki with this new features. The basic idea is when validate is done for a folder, or build, it check that it exists a tsconfig.json in the folder of the file to validate (and parent folder of tsconfig.json is not found). When a tsconfig.json is found, valudation must be done if:
Tell me if it works for you. Thanks!
I would like to finish my implementation with compile feature (with compileOnSave). Just one question, why do you wish to migrat efrom atom to eclipse? atom is more powerfull today than typescript.java, no? |
I've been testing the current SNAPSHOT (from update site) and I've the same issue as before. The angular-cli project generates a project structure like this: config dist e2e node_modules src app app.component.html app.component.ts app.ts index.html tsconfig.json typings.d.ts tmp typings package.json typings.json And the tsconfig.json has the following contents: { "compilerOptions": { "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "mapRoot": "", "module": "system", "moduleResolution": "node", "noEmitOnError": true, "noImplicitAny": false, "outDir": "../dist/", "rootDir": ".", "sourceMap": true, "sourceRoot": "/", "target": "es5" }, "compileOnSave": false } Then... your strategy of using tsconfig.json contents doesn't work in this case. I think several projects has folder structures like this. It is a bit complex to configure validator por the project, exclude several folders, etc... Maybe you have to think again about "TypeScript Nature" to tackle these kind of things. First, because configuring validations it is to complex. And second, becase I think that 'node_modules' it is a common name to disable it from validation as default. I you don't automatically active validation as default and configure it right, nobody will use it (or at least, less people than you expect). What do you think? |
What is the problem? I use files or exlude info coming from the tsconfig.json (in the same folder of the ts to validate or parent folder)
I agree it's a little complex. But I liked the idea not to configure something to import project from vscode for instance inside Eclipse.
Le me think about this problem.
You mean that you would like to avoud adding "node_modules" in the exclude of tsconfig.json? If yoy add node_modules in the exclude, does it work for validation? |
I've configured validation for the whole project. Then, node_modules folder have been started to be validated (I've stopped it after a while). In the tsconfig.json (generated with angular-cli) there is nothing about "node_modules" because it is in the parent folder and then tsc compiler executed in the src folder doesn't try to compile it at all. I've tried again and if I try to validate the whole project, node_modules is validated although tsconfig.json contains "exclude": [ "node_modules" ] Also, I have a lot of errors like this in the "Error log" view: eclipse.buildId=4.5.1.M20150904-0015 java.version=1.8.0_77 java.vendor=Oracle Corporation BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=es_ES Framework arguments: -product org.eclipse.epp.package.jee.product Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product This is a continuation of log file /home/mica/Data/Docencia/Asignaturas/DAW/2015-2016/TypeScript/wsTest/.metadata/.bak_1.log Created Time: 2016-04-09 17:34:10.026 org.eclipse.wst.validation Error Sat Apr 09 17:34:17 CEST 2016 Path must include project and resource name: /tsconfig.json java.lang.IllegalArgumentException: Path must include project and resource name: /tsconfig.json at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63) at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2075) at org.eclipse.core.internal.resources.Container.getFile(Container.java:192) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:41) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:45) at ts.eclipse.ide.core.utils.WorkbenchResourceUtil.findFileRecursively(WorkbenchResourceUtil.java:27) at ts.eclipse.ide.internal.core.resources.jsonconfig.JsonConfigResourcesManager.findTsconfig(JsonConfigResourcesManager.java:66) at ts.eclipse.ide.internal.core.resources.IDETypeScriptProject.canValidate(IDETypeScriptProject.java:195) at ts.eclipse.ide.validator.internal.core.validation.TypeScriptValidator.validate(TypeScriptValidator.java:62) at org.eclipse.wst.validation.Validator$V2.validate(Validator.java:1159) at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:704) at org.eclipse.wst.validation.internal.ValManager$1.visit(ValManager.java:665) at org.eclipse.wst.validation.internal.ValManager.accept(ValManager.java:810) at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:669) at org.eclipse.wst.validation.internal.ValidationRunner.execute(ValidationRunner.java:134) at org.eclipse.wst.validation.internal.ValidationRunner.validate(ValidationRunner.java:68) at org.eclipse.wst.validation.ui.internal.ManualValidationRunner.runInWorkspace(ManualValidationRunner.java:83) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) And eclipse.buildId=4.5.1.M20150904-0015 java.version=1.8.0_77 java.vendor=Oracle Corporation BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=es_ES Framework arguments: -product org.eclipse.epp.package.jee.product Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product This is a continuation of log file /home/mica/Data/Docencia/Asignaturas/DAW/2015-2016/TypeScript/wsTest/.metadata/.bak_1.log Created Time: 2016-04-09 17:34:10.026 org.eclipse.wst.validation Error Sat Apr 09 17:37:16 CEST 2016 TypeScript Validator finished validating: file:/home/mica/Data/Docencia/Asignaturas/DAW/2015-2016/TypeScript/code/ejem11/node_modules/angular-cli/node_modules/ember-cli/node_modules/markdown-it-terminal/node_modules/ansi-styles/node_modules/color-convert/index.js |
Could you share your project please. Thanks |
Sure... Here is: ejem11.zip After decompressing it, you have to download dependencies to node_modules folder executing "npm install" command (of course, you need to have installed node and npm) |
Thanks @micaelgallego ! it will be easy for me and you to discuss about future problem if we have a commons project. But perhaps a better idea is that you could create a github project? I have though about your 2 problems, and here my idea:
At first I thought, thate there were 2 cases:
In other words validation must be done only if we find a tsconfig.json and this tsconfig.json doesn't exclude a folder. But....a a tsconfig.json can exist inside a node_modlules folder. In other words my idea with tsconfig.json is not enough. I will add this exclude folder for node_modules. It will hard coded and there were none UI to customize it.
My idea is when user save the first time a ts file in a project, it displays a popup with a message ike "Do you want display errors in the Problem View when you save ts files?" What do you think? |
project and resource name: /tsconfig.json". See #40 (comment)
validate ts file which tsconfig.json cannot be found. See #40 (comment)
I have several projects generated with angular-cli and with ionic cli tool https://github.com/codeurjc/learn-ng2-ionic2 Ionic projects have tsconfig.json in the root and node_modules is excluded I think is a good set of projects to make testing... Your proposed behavior it is ok for me. tsconfig.json guides the compiler
|
Hi Angelo, first of all: great job with the typescript.java project. I don't know if this is the same problem as documented by Michael above. I have set up an Angular2 project in Eclipse. It was originally created as an Eclipse static web project, so the content is in a folder called WebContent. In that folder I have a tsconfig.json, a node_modules folder containing Angular, and a single sample xyz.ts that I want to compile. My tsconfig.json file references the node_modules folder in "excludes". If I run the tsc compiler myself at the command line, I get no errors. However, when I let it build in Eclipse I have many errors in Angular declarations. These are mostly (TS2304): 'Cannot find name xxx' ... with the names Map, Set, and Promise. Any thoughts as to what is going on. Why isn't the compiler behaving the same in Eclipse as on the command line? |
Thanks! Could you share your project please and tell me which files causes problem. It will be more easy for me to understand, thanks
I use tsc too, but it seems that I don't call it with the same parameter than you. It will will help me if you share your project and tell me where you do tsc (which folder) and which parameters command. |
TS1.zip
Maybe a different version? I don't know how to tell what version is the one in node_modules, because I don't seem to be able to run it from the command line. EDIT: I get the same errors when I configure the Eclipse project to use the built-in typescript. |
Thanks for the project. At first I suggest you that you remove JSDT nature because JavaScript Validator will be executed and you need not that. I have tested your project and I have too errors by using Eclipse but with simple command too (with tsc 1.8.10). I don't know why tsc try to compile ts files from node_modules although node_modules is excluded inside tsconfig.json? Is it a bug of tsc? |
None anwser, I close this issue. @peterswords please create a new issue if you need. |
I was testing TypeScript validation feature and I think it will be good to have more sensible defaults in it, for example:
Also, I was wondering it "Validation builder" can be added to project automatically when adding TypeScript nature to project. The steps in https://github.com/angelozerr/typescript.java/wiki/Editor-Features#validation are a bit messy to newbies.
The text was updated successfully, but these errors were encountered: