Skip to content

Commit e2a0a56

Browse files
Giovanni Lovatobasarat
authored andcommitted
feat(tsconfig): add lib option support (#1012)
* TypeScript 2.0 lib option support * upstream merge * upstream merge * fix(tsconfig): restore noLib support * fix(tsconfig): restore noLib support * include grammars and dist folders * include dist folder
1 parent 917d218 commit e2a0a56

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

dist/main/lang/core/languageServiceHost2.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,16 @@ var LanguageServiceHost = (function () {
259259
return _this.config.projectFileDirectory;
260260
};
261261
this.getDefaultLibFileName = ts.getDefaultLibFileName;
262-
if (!config.project.compilerOptions.noLib) {
262+
if (!config.project.compilerOptions.noLib && !config.project.compilerOptions.lib) {
263263
this.addScript(exports.getDefaultLibFilePath(config.project.compilerOptions));
264264
}
265+
else if (Array.isArray(config.project.compilerOptions.lib)) {
266+
for (var _i = 0, _a = config.project.compilerOptions.lib; _i < _a.length; _i++) {
267+
var lib = _a[_i];
268+
var filename = "lib." + lib + ".d.ts";
269+
this.addScript((path.join(getTypescriptLocation(), filename)).split('\\').join('/'));
270+
}
271+
}
265272
}
266273
return LanguageServiceHost;
267274
}());

dist/main/tsconfig/simpleValidator.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ exports.types = {
33
string: 'string',
44
boolean: 'boolean',
55
number: 'number',
6-
object: 'object'
6+
object: 'object',
7+
array: 'array'
78
};
89
var SimpleValidator = (function () {
910
function SimpleValidator(validationInfo) {
@@ -28,14 +29,21 @@ var SimpleValidator = (function () {
2829
else {
2930
var validationInfo = _this.validationInfo[k];
3031
var value = config[k];
31-
if (validationInfo.validValues && validationInfo.validValues.length) {
32-
var validValues = validationInfo.validValues;
33-
if (!validValues.some(function (valid) { return valid.toLowerCase() === value.toLowerCase(); })) {
34-
errors.invalidValues.push("Key: '" + k + "' has an invalid value: " + value);
32+
if (validationInfo.type && validationInfo.type === 'array') {
33+
if (!Array.isArray(value)) {
34+
errors.invalidValues.push("Key: '" + k + "' has an invalid type: " + typeof value);
3535
}
3636
}
37-
if (validationInfo.type && typeof value !== validationInfo.type) {
38-
errors.invalidValues.push("Key: '" + k + "' has an invalid type: " + typeof value);
37+
else {
38+
if (validationInfo.validValues && validationInfo.validValues.length) {
39+
var validValues = validationInfo.validValues;
40+
if (!validValues.some(function (valid) { return valid.toLowerCase() === value.toLowerCase(); })) {
41+
errors.invalidValues.push("Key: '" + k + "' has an invalid value: " + value);
42+
}
43+
}
44+
if (validationInfo.type && typeof value !== validationInfo.type) {
45+
errors.invalidValues.push("Key: '" + k + "' has an invalid type: " + typeof value);
46+
}
3947
}
4048
}
4149
});

dist/main/tsconfig/tsconfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ var compilerOptionsValidation = {
6363
target: { type: types.string, validValues: ['es3', 'es5', 'es6', 'es2015'] },
6464
version: { type: types.boolean },
6565
watch: { type: types.boolean },
66+
lib: { type: types.array }
6667
};
6768
var validator = new simpleValidator.SimpleValidator(compilerOptionsValidation);
6869
exports.errors = {

0 commit comments

Comments
 (0)