Skip to content

Commit b3fb87f

Browse files
authored
Build VS Code using TS 4.0 (microsoft#100033)
* Build VS Code using TS 4.0 Also updates to an eslint alpha build that supports the new TS version * Fix hygiene
1 parent faac1ff commit b3fb87f

7 files changed

Lines changed: 196 additions & 183 deletions

File tree

build/lib/i18n.js

Lines changed: 135 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -101,161 +101,158 @@ class TextModel {
101101
return this._lines;
102102
}
103103
}
104-
let XLF = /** @class */ (() => {
105-
class XLF {
106-
constructor(project) {
107-
this.project = project;
108-
this.buffer = [];
109-
this.files = Object.create(null);
110-
this.numberOfMessages = 0;
111-
}
112-
toString() {
113-
this.appendHeader();
114-
for (let file in this.files) {
115-
this.appendNewLine(`<file original="${file}" source-language="en" datatype="plaintext"><body>`, 2);
116-
for (let item of this.files[file]) {
117-
this.addStringItem(file, item);
118-
}
119-
this.appendNewLine('</body></file>', 2);
104+
class XLF {
105+
constructor(project) {
106+
this.project = project;
107+
this.buffer = [];
108+
this.files = Object.create(null);
109+
this.numberOfMessages = 0;
110+
}
111+
toString() {
112+
this.appendHeader();
113+
for (let file in this.files) {
114+
this.appendNewLine(`<file original="${file}" source-language="en" datatype="plaintext"><body>`, 2);
115+
for (let item of this.files[file]) {
116+
this.addStringItem(file, item);
120117
}
121-
this.appendFooter();
122-
return this.buffer.join('\r\n');
118+
this.appendNewLine('</body></file>', 2);
123119
}
124-
addFile(original, keys, messages) {
125-
if (keys.length === 0) {
126-
console.log('No keys in ' + original);
127-
return;
128-
}
129-
if (keys.length !== messages.length) {
130-
throw new Error(`Unmatching keys(${keys.length}) and messages(${messages.length}).`);
131-
}
132-
this.numberOfMessages += keys.length;
133-
this.files[original] = [];
134-
let existingKeys = new Set();
135-
for (let i = 0; i < keys.length; i++) {
136-
let key = keys[i];
137-
let realKey;
138-
let comment;
139-
if (Is.string(key)) {
140-
realKey = key;
141-
comment = undefined;
142-
}
143-
else if (LocalizeInfo.is(key)) {
144-
realKey = key.key;
145-
if (key.comment && key.comment.length > 0) {
146-
comment = key.comment.map(comment => encodeEntities(comment)).join('\r\n');
147-
}
148-
}
149-
if (!realKey || existingKeys.has(realKey)) {
150-
continue;
151-
}
152-
existingKeys.add(realKey);
153-
let message = encodeEntities(messages[i]);
154-
this.files[original].push({ id: realKey, message: message, comment: comment });
155-
}
120+
this.appendFooter();
121+
return this.buffer.join('\r\n');
122+
}
123+
addFile(original, keys, messages) {
124+
if (keys.length === 0) {
125+
console.log('No keys in ' + original);
126+
return;
156127
}
157-
addStringItem(file, item) {
158-
if (!item.id || item.message === undefined || item.message === null) {
159-
throw new Error(`No item ID or value specified: ${JSON.stringify(item)}. File: ${file}`);
128+
if (keys.length !== messages.length) {
129+
throw new Error(`Unmatching keys(${keys.length}) and messages(${messages.length}).`);
130+
}
131+
this.numberOfMessages += keys.length;
132+
this.files[original] = [];
133+
let existingKeys = new Set();
134+
for (let i = 0; i < keys.length; i++) {
135+
let key = keys[i];
136+
let realKey;
137+
let comment;
138+
if (Is.string(key)) {
139+
realKey = key;
140+
comment = undefined;
160141
}
161-
if (item.message.length === 0) {
162-
log(`Item with id ${item.id} in file ${file} has an empty message.`);
142+
else if (LocalizeInfo.is(key)) {
143+
realKey = key.key;
144+
if (key.comment && key.comment.length > 0) {
145+
comment = key.comment.map(comment => encodeEntities(comment)).join('\r\n');
146+
}
163147
}
164-
this.appendNewLine(`<trans-unit id="${item.id}">`, 4);
165-
this.appendNewLine(`<source xml:lang="en">${item.message}</source>`, 6);
166-
if (item.comment) {
167-
this.appendNewLine(`<note>${item.comment}</note>`, 6);
148+
if (!realKey || existingKeys.has(realKey)) {
149+
continue;
168150
}
169-
this.appendNewLine('</trans-unit>', 4);
151+
existingKeys.add(realKey);
152+
let message = encodeEntities(messages[i]);
153+
this.files[original].push({ id: realKey, message: message, comment: comment });
170154
}
171-
appendHeader() {
172-
this.appendNewLine('<?xml version="1.0" encoding="utf-8"?>', 0);
173-
this.appendNewLine('<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">', 0);
155+
}
156+
addStringItem(file, item) {
157+
if (!item.id || item.message === undefined || item.message === null) {
158+
throw new Error(`No item ID or value specified: ${JSON.stringify(item)}. File: ${file}`);
174159
}
175-
appendFooter() {
176-
this.appendNewLine('</xliff>', 0);
160+
if (item.message.length === 0) {
161+
log(`Item with id ${item.id} in file ${file} has an empty message.`);
177162
}
178-
appendNewLine(content, indent) {
179-
let line = new Line(indent);
180-
line.append(content);
181-
this.buffer.push(line.toString());
163+
this.appendNewLine(`<trans-unit id="${item.id}">`, 4);
164+
this.appendNewLine(`<source xml:lang="en">${item.message}</source>`, 6);
165+
if (item.comment) {
166+
this.appendNewLine(`<note>${item.comment}</note>`, 6);
182167
}
168+
this.appendNewLine('</trans-unit>', 4);
183169
}
184-
XLF.parsePseudo = function (xlfString) {
185-
return new Promise((resolve) => {
186-
let parser = new xml2js.Parser();
187-
let files = [];
188-
parser.parseString(xlfString, function (_err, result) {
189-
const fileNodes = result['xliff']['file'];
190-
fileNodes.forEach(file => {
191-
const originalFilePath = file.$.original;
192-
const messages = {};
193-
const transUnits = file.body[0]['trans-unit'];
194-
if (transUnits) {
195-
transUnits.forEach((unit) => {
196-
const key = unit.$.id;
197-
const val = pseudify(unit.source[0]['_'].toString());
198-
if (key && val) {
199-
messages[key] = decodeEntities(val);
200-
}
201-
});
202-
files.push({ messages: messages, originalFilePath: originalFilePath, language: 'ps' });
203-
}
204-
});
205-
resolve(files);
170+
appendHeader() {
171+
this.appendNewLine('<?xml version="1.0" encoding="utf-8"?>', 0);
172+
this.appendNewLine('<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">', 0);
173+
}
174+
appendFooter() {
175+
this.appendNewLine('</xliff>', 0);
176+
}
177+
appendNewLine(content, indent) {
178+
let line = new Line(indent);
179+
line.append(content);
180+
this.buffer.push(line.toString());
181+
}
182+
}
183+
exports.XLF = XLF;
184+
XLF.parsePseudo = function (xlfString) {
185+
return new Promise((resolve) => {
186+
let parser = new xml2js.Parser();
187+
let files = [];
188+
parser.parseString(xlfString, function (_err, result) {
189+
const fileNodes = result['xliff']['file'];
190+
fileNodes.forEach(file => {
191+
const originalFilePath = file.$.original;
192+
const messages = {};
193+
const transUnits = file.body[0]['trans-unit'];
194+
if (transUnits) {
195+
transUnits.forEach((unit) => {
196+
const key = unit.$.id;
197+
const val = pseudify(unit.source[0]['_'].toString());
198+
if (key && val) {
199+
messages[key] = decodeEntities(val);
200+
}
201+
});
202+
files.push({ messages: messages, originalFilePath: originalFilePath, language: 'ps' });
203+
}
206204
});
205+
resolve(files);
207206
});
208-
};
209-
XLF.parse = function (xlfString) {
210-
return new Promise((resolve, reject) => {
211-
let parser = new xml2js.Parser();
212-
let files = [];
213-
parser.parseString(xlfString, function (err, result) {
214-
if (err) {
215-
reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`));
207+
});
208+
};
209+
XLF.parse = function (xlfString) {
210+
return new Promise((resolve, reject) => {
211+
let parser = new xml2js.Parser();
212+
let files = [];
213+
parser.parseString(xlfString, function (err, result) {
214+
if (err) {
215+
reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`));
216+
}
217+
const fileNodes = result['xliff']['file'];
218+
if (!fileNodes) {
219+
reject(new Error(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`));
220+
}
221+
fileNodes.forEach((file) => {
222+
const originalFilePath = file.$.original;
223+
if (!originalFilePath) {
224+
reject(new Error(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`));
216225
}
217-
const fileNodes = result['xliff']['file'];
218-
if (!fileNodes) {
219-
reject(new Error(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`));
226+
let language = file.$['target-language'];
227+
if (!language) {
228+
reject(new Error(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`));
229+
}
230+
const messages = {};
231+
const transUnits = file.body[0]['trans-unit'];
232+
if (transUnits) {
233+
transUnits.forEach((unit) => {
234+
const key = unit.$.id;
235+
if (!unit.target) {
236+
return; // No translation available
237+
}
238+
let val = unit.target[0];
239+
if (typeof val !== 'string') {
240+
val = val._;
241+
}
242+
if (key && val) {
243+
messages[key] = decodeEntities(val);
244+
}
245+
else {
246+
reject(new Error(`XLF parsing error: XLIFF file ${originalFilePath} does not contain full localization data. ID or target translation for one of the trans-unit nodes is not present.`));
247+
}
248+
});
249+
files.push({ messages: messages, originalFilePath: originalFilePath, language: language.toLowerCase() });
220250
}
221-
fileNodes.forEach((file) => {
222-
const originalFilePath = file.$.original;
223-
if (!originalFilePath) {
224-
reject(new Error(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`));
225-
}
226-
let language = file.$['target-language'];
227-
if (!language) {
228-
reject(new Error(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`));
229-
}
230-
const messages = {};
231-
const transUnits = file.body[0]['trans-unit'];
232-
if (transUnits) {
233-
transUnits.forEach((unit) => {
234-
const key = unit.$.id;
235-
if (!unit.target) {
236-
return; // No translation available
237-
}
238-
let val = unit.target[0];
239-
if (typeof val !== 'string') {
240-
val = val._;
241-
}
242-
if (key && val) {
243-
messages[key] = decodeEntities(val);
244-
}
245-
else {
246-
reject(new Error(`XLF parsing error: XLIFF file ${originalFilePath} does not contain full localization data. ID or target translation for one of the trans-unit nodes is not present.`));
247-
}
248-
});
249-
files.push({ messages: messages, originalFilePath: originalFilePath, language: language.toLowerCase() });
250-
}
251-
});
252-
resolve(files);
253251
});
252+
resolve(files);
254253
});
255-
};
256-
return XLF;
257-
})();
258-
exports.XLF = XLF;
254+
});
255+
};
259256
class Limiter {
260257
constructor(maxDegreeOfParalellism) {
261258
this.maxDegreeOfParalellism = maxDegreeOfParalellism;

build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"minimist": "^1.2.3",
4545
"request": "^2.85.0",
4646
"terser": "4.3.8",
47-
"typescript": "^3.9.3",
47+
"typescript": "^4.0.0-dev.20200612",
4848
"vsce": "1.48.0",
4949
"vscode-telemetry-extractor": "^1.5.4",
5050
"xml2js": "^0.4.17"

build/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,10 +2519,10 @@ typescript@^3.0.1:
25192519
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
25202520
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
25212521

2522-
typescript@^3.9.3:
2523-
version "3.9.3"
2524-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.3.tgz#d3ac8883a97c26139e42df5e93eeece33d610b8a"
2525-
integrity sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==
2522+
typescript@^4.0.0-dev.20200612:
2523+
version "4.0.0-dev.20200612"
2524+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.0-dev.20200612.tgz#6f1f1a8508eae00ef79b57116886dc05051b398e"
2525+
integrity sha512-o69PZMHrijfGcfvPmTJjLOmYZYccfpDcpFohMmBVLZLOdtRWzjOZSfymGq1J13w6tRlvnLdREpdH40cCnhURow==
25262526

25272527
typical@^4.0.0:
25282528
version "4.0.0"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
"@types/winreg": "^1.2.30",
8989
"@types/yauzl": "^2.9.1",
9090
"@types/yazl": "^2.4.2",
91-
"@typescript-eslint/eslint-plugin": "3.1.0",
92-
"@typescript-eslint/parser": "^3.1.0",
91+
"@typescript-eslint/eslint-plugin": "3.2.0",
92+
"@typescript-eslint/parser": "^3.2.1-alpha.2",
9393
"ansi-colors": "^3.2.3",
9494
"asar": "^0.14.0",
9595
"chromium-pickle-js": "^0.2.0",
@@ -154,7 +154,7 @@
154154
"source-map": "^0.4.4",
155155
"style-loader": "^1.0.0",
156156
"ts-loader": "^4.4.2",
157-
"typescript": "^3.9.3",
157+
"typescript": "^4.0.0-dev.20200612",
158158
"typescript-formatter": "7.1.0",
159159
"underscore": "^1.8.2",
160160
"vinyl": "^2.0.0",

src/vs/base/test/node/path.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ suite('Paths (Node Implementation)', () => {
164164
os = 'posix';
165165
}
166166
const message =
167-
`path.${os}.join(${test[0].map(JSON.stringify).join(',')})\n expect=${
168-
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
167+
`path.${os}.join(${test[0].map(JSON.stringify).join(',')})\n expect=${JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
169168
if (actual !== expected && actualAlt !== expected) {
170169
failures.push(`\n${message}`);
171170
}
@@ -319,17 +318,15 @@ suite('Paths (Node Implementation)', () => {
319318
os = 'posix';
320319
}
321320
const actual = extname(input);
322-
const message = `path.${os}.extname(${JSON.stringify(input)})\n expect=${
323-
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
321+
const message = `path.${os}.extname(${JSON.stringify(input)})\n expect=${JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
324322
if (actual !== expected) {
325323
failures.push(`\n${message}`);
326324
}
327325
});
328326
{
329327
const input = `C:${test[0].replace(slashRE, '\\')}`;
330328
const actual = path.win32.extname(input);
331-
const message = `path.win32.extname(${JSON.stringify(input)})\n expect=${
332-
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
329+
const message = `path.win32.extname(${JSON.stringify(input)})\n expect=${JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
333330
if (actual !== expected) {
334331
failures.push(`\n${message}`);
335332
}
@@ -416,8 +413,7 @@ suite('Paths (Node Implementation)', () => {
416413

417414
const expected = test[1];
418415
const message =
419-
`path.${os}.resolve(${test[0].map(JSON.stringify).join(',')})\n expect=${
420-
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
416+
`path.${os}.resolve(${test[0].map(JSON.stringify).join(',')})\n expect=${JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
421417
if (actual !== expected && actualAlt !== expected) {
422418
failures.push(`\n${message}`);
423419
}
@@ -585,9 +581,7 @@ suite('Paths (Node Implementation)', () => {
585581
const actual = relative(test[0], test[1]);
586582
const expected = test[2];
587583
const os = relative === path.win32.relative ? 'win32' : 'posix';
588-
const message = `path.${os}.relative(${
589-
test.slice(0, 2).map(JSON.stringify).join(',')})\n expect=${
590-
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
584+
const message = `path.${os}.relative(${test.slice(0, 2).map(JSON.stringify).join(',')})\n expect=${JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
591585
if (actual !== expected) {
592586
failures.push(`\n${message}`);
593587
}

0 commit comments

Comments
 (0)