Using Atom editor with the typescript plug I'm getting the following error:
Error The file "D:/foo/app/classes/event.class.ts" is not included in the TypeScript compilation context. If this is not intended, please check the "files" or "filesGlob" section of your tsconfig.json file.at line 1 col 1
The contents of my tsconfig.json file is:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
I have looked at a few others that have had this problem. This: https://github.com/lathonez/clicker/issues/4 got me to try building a "files" array in the tsconfig.json array. That, much like with the person in the other thread, did not help. Note, that thread talked a lot of about testing... which doesn't apply for me.
I also tried parsing through this thread: https://github.com/TypeStrong/atom-typescript/issues/558 however that basically ended up being an argument about purity vs pragmatism. I did pick up that if the files and filesGlob arrays are missing, an implicit "everything" glob is used. If this were the case, why am I getting the error given I don't have a file and filesGlob entry.
As an aside, command-line TSC is generating the compiled js and map files just fine. ... but I still have to see the big red error in Atom.
For what it's worth, the event.class.ts file looks like this (I don't expect this is the source of the problem, but figured I'd include it for completeness):
import {Utilities} from '../utilities';
export class Event {
eventData:JSON;
eventID:string;
constructor(_eventData:JSON, _eventID?:string) {
if(_eventID==null) {
_eventID=Utilities.newGuidPlus();
}
this.eventID = _eventID;
this.eventData = _eventData;
}
getEventData():JSON { // returns the full event
return this.eventData;
}
getEventID():string {
return this.eventID;
}
}
The compilation context is a term for a grouping of the TypeScript files that will parse and analyze to determine what is valid and what is not valid. The compilation context contains the information about which compiler options are in use. We can define this logical grouping of TypeScript files by using a tsconfig.
json file is a file of JSON format which allows us to point the root level files and different compiler options to setup that require to compile a TypeScript based projects. The existence of this file in a project specifies that the given directory is the TypeScript project folder root.
The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.
For the exact issue in my case, I included "**/*.ts"
in “filesGlob” property in tsconfig.json to resolve. The whole tsconfig.json looks like this.
{
"compileOnSave": false,
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "/",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"outDir": "../dist/",
"rootDir": ".",
"sourceMap": true,
"target": "es5",
"inlineSources": true
},
"filesGlob": [
"**/*.ts"
],
"atom": {
"rewriteTsconfig": false
}
}
For my case, the solution was different:
I will update if something else occurs with this bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With