Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion _submodules/TypeScript
Submodule TypeScript updated 17565 files
2 changes: 2 additions & 0 deletions internal/tsoptions/tsconfigparsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ func TestParseSrcCompiler(t *testing.T) {
"transformers/classThis.ts",
"transformers/declarations.ts",
"transformers/destructuring.ts",
"transformers/es2015.ts",
"transformers/es2016.ts",
"transformers/es2017.ts",
"transformers/es2018.ts",
Expand All @@ -1157,6 +1158,7 @@ func TestParseSrcCompiler(t *testing.T) {
"transformers/es2021.ts",
"transformers/esDecorators.ts",
"transformers/esnext.ts",
"transformers/generators.ts",
"transformers/jsx.ts",
"transformers/legacyDecorators.ts",
"transformers/namedEvaluation.ts",
Expand Down
35 changes: 28 additions & 7 deletions testdata/baselines/reference/submodule/compiler/2dArrays.js.diff
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
--- old.2dArrays.js
+++ new.2dArrays.js
@@= skipped -20, +20 lines =@@
class Cell {
@@= skipped -17, +17 lines =@@
}
class Ship {

//// [2dArrays.js]
-var Cell = /** @class */ (function () {
- function Cell() {
- }
- return Cell;
-}());
-var Ship = /** @class */ (function () {
- function Ship() {
- }
- return Ship;
-}());
-var Board = /** @class */ (function () {
- function Board() {
- }
- Board.prototype.allShipsSunk = function () {
+class Cell {
+}
+class Ship {
+ isSunk;
}
class Board {
+}
+class Board {
+ ships;
+ cells;
allShipsSunk() {
+ allShipsSunk() {
return this.ships.every(function (val) { return val.isSunk; });
}
- };
- return Board;
-}());
+ }
+}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,40 @@
- */
Object.defineProperty(exports, "__esModule", { value: true });
-var ts = require("typescript");
-var formatHost = {
- getCanonicalFileName: function (path) { return path; },
+const ts = require("typescript");
const formatHost = {
getCanonicalFileName: path => path,
getCurrentDirectory: ts.sys.getCurrentDirectory,
+const formatHost = {
+ getCanonicalFileName: path => path,
getCurrentDirectory: ts.sys.getCurrentDirectory,
- getNewLine: function () { return ts.sys.newLine; },
+ getNewLine: () => ts.sys.newLine,
};
function watchMain() {
- var configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json");
+ const configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json");
if (!configPath) {
throw new Error("Could not find a valid 'tsconfig.json'.");
}
@@= skipped -27, +22 lines =@@
// Between `createEmitAndSemanticDiagnosticsBuilderProgram` and `createSemanticDiagnosticsBuilderProgram`, the only difference is emit.
// For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable.
// Note that there is another overload for `createWatchCompilerHost` that takes a set of root files.
- var host = ts.createWatchCompilerHost(configPath, {}, ts.sys, ts.createSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportWatchStatusChanged);
+ const host = ts.createWatchCompilerHost(configPath, {}, ts.sys, ts.createSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportWatchStatusChanged);
// You can technically override any given hook on the host, though you probably don't need to.
// Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all.
- var origCreateProgram = host.createProgram;
- host.createProgram = function (rootNames, options, host, oldProgram) {
+ const origCreateProgram = host.createProgram;
+ host.createProgram = (rootNames, options, host, oldProgram) => {
console.log("** We're about to create the program! **");
return origCreateProgram(rootNames, options, host, oldProgram);
};
- var origPostProgramCreate = host.afterProgramCreate;
- host.afterProgramCreate = function (program) {
+ const origPostProgramCreate = host.afterProgramCreate;
+ host.afterProgramCreate = program => {
console.log("** We finished making the program! **");
origPostProgramCreate(program);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,30 @@
-var ts = require("typescript");
+const ts = require("typescript");
function watchMain() {
const configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json");
if (!configPath) {
- var configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json");
+ const configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json");
if (!configPath) {
throw new Error("Could not find a valid 'tsconfig.json'.");
}
@@= skipped -21, +17 lines =@@
// Between `createEmitAndSemanticDiagnosticsBuilderProgram` and `createSemanticDiagnosticsBuilderProgram`, the only difference is emit.
// For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable.
// Note that there is another overload for `createWatchCompilerHost` that takes a set of root files.
- var host = ts.createWatchCompilerHost(configPath, {}, ts.sys);
+ const host = ts.createWatchCompilerHost(configPath, {}, ts.sys);
// You can technically override any given hook on the host, though you probably don't need to.
// Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all.
- var origCreateProgram = host.createProgram;
- host.createProgram = function (rootNames, options, host, oldProgram) {
+ const origCreateProgram = host.createProgram;
+ host.createProgram = (rootNames, options, host, oldProgram) => {
console.log("** We're about to create the program! **");
return origCreateProgram(rootNames, options, host, oldProgram);
};
- var origPostProgramCreate = host.afterProgramCreate;
- host.afterProgramCreate = function (program) {
+ const origPostProgramCreate = host.afterProgramCreate;
+ host.afterProgramCreate = program => {
console.log("** We finished making the program! **");
origPostProgramCreate(program);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,40 @@
+const ts = require("typescript");
function watchMain() {
// get list of files and compiler options somehow
const files = [];
- var files = [];
- var options = {};
- var host = {
+ const files = [];
+ const options = {};
+ const host = {
rootFiles: files,
- options: options,
- useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
- getNewLine: function () { return ts.sys.newLine; },
+ options,
+ useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
+ getNewLine: () => ts.sys.newLine,
getCurrentDirectory: ts.sys.getCurrentDirectory,
- getDefaultLibFileName: function (options) { return ts.getDefaultLibFilePath(options); },
+ getDefaultLibFileName: options => ts.getDefaultLibFilePath(options),
fileExists: ts.sys.fileExists,
readFile: ts.sys.readFile,
directoryExists: ts.sys.directoryExists,
@@= skipped -29, +25 lines =@@
};
// You can technically override any given hook on the host, though you probably don't need to.
// Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all.
- var origCreateProgram = host.createProgram;
- host.createProgram = function (rootNames, options, host, oldProgram) {
+ const origCreateProgram = host.createProgram;
+ host.createProgram = (rootNames, options, host, oldProgram) => {
console.log("** We're about to create the program! **");
return origCreateProgram(rootNames, options, host, oldProgram);
};
- var origPostProgramCreate = host.afterProgramCreate;
- host.afterProgramCreate = function (program) {
+ const origPostProgramCreate = host.afterProgramCreate;
+ host.afterProgramCreate = program => {
console.log("** We finished making the program! **");
origPostProgramCreate(program);
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,23 @@
+const ts = require("typescript");
function compile(fileNames, options) {
var program = ts.createProgram(fileNames, options);
var emitResult = program.emit();
var emitResult = program.emit();
var allDiagnostics = ts.getPreEmitDiagnostics(program);
- allDiagnostics.forEach(function (diagnostic) {
+ allDiagnostics.forEach(diagnostic => {
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
if (!diagnostic.file) {
console.log(message);
return;
}
- var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
- console.log("".concat(diagnostic.file.fileName, " (").concat(line + 1, ",").concat(character + 1, "): ").concat(message));
+ var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
+ console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
});
var exitCode = emitResult.emitSkipped ? 1 : 0;
- console.log("Process exiting with code '".concat(exitCode, "'."));
+ console.log(`Process exiting with code '${exitCode}'.`);
process.exit(exitCode);
}
compile(process.argv.slice(2), {
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,93 @@
+const ts = require("typescript");
// excerpted from https://github.com/YousefED/typescript-json-schema
// (converted from a method and modified; for example, `this: any` to compensate, among other changes)
function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) {
function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) {
- var _this = this;
if (!symbol) {
return;
}
// the comments for a symbol
- var comments = symbol.getDocumentationComment(undefined);
+ let comments = symbol.getDocumentationComment(undefined);
if (comments.length) {
- definition.description = comments.map(function (comment) { return comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n"); }).join("");
+ definition.description = comments.map(comment => comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n")).join("");
}
// jsdocs are separate from comments
- var jsdocs = symbol.getJsDocTags(this.checker);
- jsdocs.forEach(function (doc) {
+ const jsdocs = symbol.getJsDocTags(this.checker);
+ jsdocs.forEach(doc => {
// if we have @TJS-... annotations, we have to parse them
- var name = doc.name, text = doc.text;
- if (_this.userValidationKeywords[name]) {
- definition[name] = _this.parseValue(text);
+ const { name, text } = doc;
+ if (this.userValidationKeywords[name]) {
+ definition[name] = this.parseValue(text);
}
else {
// special annotations
@@= skipped -35, +28 lines =@@
});
}
function getAnnotations(node) {
- var _this = this;
- var symbol = node.symbol;
+ const symbol = node.symbol;
if (!symbol) {
return undefined;
}
- var jsDocTags = symbol.getJsDocTags(this.checker);
+ const jsDocTags = symbol.getJsDocTags(this.checker);
if (!jsDocTags || !jsDocTags.length) {
return undefined;
}
- var annotations = jsDocTags.reduce(function (result, jsDocTag) {
- var value = _this.parseJsDocTag(jsDocTag);
+ const annotations = jsDocTags.reduce((result, jsDocTag) => {
+ const value = this.parseJsDocTag(jsDocTag);
if (value !== undefined) {
result[jsDocTag.name] = value;
}
@@= skipped -24, +23 lines =@@
return ts.getJSDocParameterTags(node);
}
if (node.kind === ts.SyntaxKind.FunctionDeclaration) {
- var func = node;
+ const func = node;
if (ts.hasJSDocParameterTags(func)) {
- var flat = [];
- for (var _i = 0, _a = func.parameters.map(ts.getJSDocParameterTags); _i < _a.length; _i++) {
- var tags = _a[_i];
+ const flat = [];
+ for (const tags of func.parameters.map(ts.getJSDocParameterTags)) {
if (tags)
- flat.push.apply(flat, tags);
+ flat.push(...tags);
}
return flat;
}
@@= skipped -16, +15 lines =@@
if (node.kind === ts.SyntaxKind.FunctionDeclaration) {
return ts.getJSDocReturnType(node);
}
- var type = ts.getJSDocType(node);
+ let type = ts.getJSDocType(node);
if (type && type.kind === ts.SyntaxKind.FunctionType) {
return type.type;
}
@@= skipped -9, +9 lines =@@
ts.getJSDocTags(node);
}
function getSomeOtherTags(node) {
- var tags = [];
+ const tags = [];
tags.push(ts.getJSDocAugmentsTag(node));
tags.push(ts.getJSDocClassTag(node));
tags.push(ts.getJSDocReturnTag(node));
- var type = ts.getJSDocTypeTag(node);
+ const type = ts.getJSDocTypeTag(node);
if (type) {
tags.push(type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,42 @@
+const ts = require("typescript");
function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
function delintNode(node) {
@@= skipped -21, +16 lines =@@
}
break;
case ts.SyntaxKind.IfStatement:
- var ifStatement = node;
+ let ifStatement = node;
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
@@= skipped -11, +11 lines =@@
}
break;
case ts.SyntaxKind.BinaryExpression:
- var op = node.operatorToken.kind;
+ let op = node.operatorToken.kind;
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
report(node, "Use '===' and '!=='.");
}
@@= skipped -9, +9 lines =@@
ts.forEachChild(node, delintNode);
}
function report(node, message) {
- var _a = sourceFile.getLineAndCharacterOfPosition(node.getStart()), line = _a.line, character = _a.character;
- console.log("".concat(sourceFile.fileName, " (").concat(line + 1, ",").concat(character + 1, "): ").concat(message));
+ let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
+ console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
}
}
-var fileNames = process.argv.slice(2);
-fileNames.forEach(function (fileName) {
+const fileNames = process.argv.slice(2);
+fileNames.forEach(fileName => {
// Parse a file
- var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true);
+ let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true);
// delint it
delint(sourceFile);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,26 @@
+const ts = require("typescript");
function printError(error) {
if (!error) {
return;
return;
}
- console.log("".concat(error.file && error.file.fileName, ": ").concat(error.messageText));
+ console.log(`${error.file && error.file.fileName}: ${error.messageText}`);
}
function createProgram(rootFiles, compilerOptionsJson) {
- var _a = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson), config = _a.config, error = _a.error;
+ const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson);
if (error) {
printError(error);
return undefined;
}
- var basePath = process.cwd();
- var settings = ts.convertCompilerOptionsFromJson(config.config["compilerOptions"], basePath);
+ const basePath = process.cwd();
+ const settings = ts.convertCompilerOptionsFromJson(config.config["compilerOptions"], basePath);
if (!settings.options) {
- for (var _i = 0, _b = settings.errors; _i < _b.length; _i++) {
- var err = _b[_i];
+ for (const err of settings.errors) {
printError(err);
}
return undefined;
Loading