Skip to content

Commit c0b5ded

Browse files
committed
tsconfig: TypeScript version
closes #126 refs microsoft/TypeScript#2133
1 parent 1d2e6d4 commit c0b5ded

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

docs/tsconfig.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ A unified project format for TypeScript ([see merged PR on Microsoft/TypeScript]
44
* [`compilerOptions`](https://github.com/TypeStrong/atom-typescript/blob/e2fa67c4715189b71430f766ed9a92d9fb3255f9/lib/main/tsconfig/tsconfig.ts#L8-L33) similar to what you would pass on the commandline to `tsc`.
55
* [`filesGlob`](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#filesglob): To make it easier for you to just add / remove files in your project we add `filesGlob` which accepts an array of `glob / minimatch / RegExp` patterns (similar to grunt) to specify source files.
66
* [`format`](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#format) : Code formatting options
7+
* [`version`](https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#version): The TypeScript version
78

89

910
## Examples
@@ -57,3 +58,6 @@ We pass these to the TypeScript language service as code formatting options.
5758
}
5859
}
5960
```
61+
62+
### version
63+
This exists simply to make it easier for the future you to know which TypeScript version was used when this project file was created. You can read more here [Microsoft/TypeScript#2113](https://github.com/Microsoft/TypeScript/issues/2133)

lib/main/tsconfig/tsconfig.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var ts = require('typescript');
1818
var formatting = require('./formatting');
1919
var projectFileName = 'tsconfig.json';
2020
var defaultFilesGlob = ["./**/*.ts", "!./node_modules/**/*.ts"];
21+
var typeScriptVersion = '1.4.1';
2122
exports.defaults = {
2223
target: ts.ScriptTarget.ES5,
2324
module: ts.ModuleKind.CommonJS,
@@ -191,6 +192,7 @@ function createProjectRootSync(srcFile, defaultOptions) {
191192
if (fs.existsSync(projectFilePath))
192193
throw new Error(exports.errors.CREATE_PROJECT_ALREADY_EXISTS);
193194
var projectSpec = {};
195+
projectSpec.version = typeScriptVersion;
194196
projectSpec.compilerOptions = tsToRawCompilerOptions(defaultOptions || exports.defaults);
195197
projectSpec.filesGlob = defaultFilesGlob;
196198
fs.writeFileSync(projectFilePath, prettyJSON(projectSpec));

lib/main/tsconfig/tsconfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ interface CompilerOptions {
3535
}
3636

3737
interface TypeScriptProjectRawSpecification {
38+
version?: string;
3839
compilerOptions?: CompilerOptions;
3940
files?: string[]; // optional: paths to files
4041
filesGlob?: string[]; // optional: An array of 'glob / minimatch / RegExp' patterns to specify source files
@@ -82,8 +83,8 @@ import os = require('os');
8283
import formatting = require('./formatting');
8384

8485
var projectFileName = 'tsconfig.json';
85-
8686
var defaultFilesGlob = ["./**/*.ts", "!./node_modules/**/*.ts"];
87+
var typeScriptVersion = '1.4.1';
8788

8889
export var defaults: ts.CompilerOptions = {
8990
target: ts.ScriptTarget.ES5,
@@ -310,6 +311,7 @@ export function createProjectRootSync(srcFile: string, defaultOptions?: ts.Compi
310311

311312
// We need to write the raw spec
312313
var projectSpec: TypeScriptProjectRawSpecification = {};
314+
projectSpec.version = typeScriptVersion;
313315
projectSpec.compilerOptions = tsToRawCompilerOptions(defaultOptions || defaults);
314316
projectSpec.filesGlob = defaultFilesGlob;
315317

0 commit comments

Comments
 (0)