Skip to content
Open
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 scripts/dtsBundler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function getDeclarationStatement(node) {
return undefined;
}

const program = ts.createProgram([entrypoint], { target: ts.ScriptTarget.ES5 });
const program = ts.createProgram([entrypoint], { target: ts.ScriptTarget.ES2015 });

const typeChecker = program.getTypeChecker();

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,12 @@ export const targetOptionDeclaration: CommandLineOptionOfCustomType = {
affectsModuleResolution: true,
affectsEmit: true,
affectsBuildInfo: true,
deprecatedKeys: new Set(["es3"]),
deprecatedKeys: new Set(["es3", "es5"]),
paramType: Diagnostics.VERSION,
showInSimplifiedHelpView: true,
category: Diagnostics.Language_and_Environment,
description: Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
defaultValueDescription: ScriptTarget.ES5,
defaultValueDescription: ScriptTarget.LatestStandard,
};

/** @internal */
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/factory/nodeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6052,7 +6052,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
node.path = "" as Path;
node.resolvedPath = "" as Path;
node.originalFileName = "";
node.languageVersion = ScriptTarget.ES5;
node.languageVersion = ScriptTarget.LatestStandard;
node.languageVariant = 0;
node.scriptKind = 0;
node.isDeclarationFile = false;
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4526,6 +4526,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
});

checkDeprecations("6.0", "7.0", createDiagnostic, createDeprecatedDiagnostic => {
if (options.target === ScriptTarget.ES5) {
createDeprecatedDiagnostic("target", "ES5");
}
if (options.moduleResolution === ModuleResolutionKind.Node10) {
createDeprecatedDiagnostic("moduleResolution", "node10", /*useInstead*/ undefined, Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information);
}
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7659,6 +7659,7 @@ export const enum ScriptKind {
export const enum ScriptTarget {
/** @deprecated */
ES3 = 0,
/** @deprecated */
ES5 = 1,
ES2015 = 2,
ES2016 = 3,
Expand All @@ -7673,6 +7674,7 @@ export const enum ScriptTarget {
ESNext = 99,
JSON = 100,
Latest = ESNext,
LatestStandard = ES2024,
}

export const enum LanguageVariant {
Expand Down
9 changes: 2 additions & 7 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8991,15 +8991,10 @@ const _computedOptions = createComputedCompilerOptions({
},
},
target: {
dependencies: ["module"],
dependencies: [],
computeValue: compilerOptions => {
const target = compilerOptions.target === ScriptTarget.ES3 ? undefined : compilerOptions.target;
return target ??
((compilerOptions.module === ModuleKind.Node16 && ScriptTarget.ES2022) ||
(compilerOptions.module === ModuleKind.Node18 && ScriptTarget.ES2022) ||
(compilerOptions.module === ModuleKind.Node20 && ScriptTarget.ES2023) ||
(compilerOptions.module === ModuleKind.NodeNext && ScriptTarget.ESNext) ||
ScriptTarget.ES5);
return target ?? ScriptTarget.LatestStandard;
},
},
module: {
Expand Down
1 change: 1 addition & 0 deletions src/harness/evaluatorImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function evaluateTypeScript(source: string | { files: vfs.FileSet; rootFi
module: ts.ModuleKind.CommonJS,
strict: false,
lib: ["lib.esnext.d.ts", "lib.dom.d.ts"],
ignoreDeprecations: "6.0",
...options,
};
const host = new fakes.CompilerHost(fs, compilerOptions);
Expand Down
2 changes: 2 additions & 0 deletions src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3284,6 +3284,7 @@ export const enum NewLineKind {
export const enum ScriptTarget {
/** @deprecated */
ES3 = "es3",
/** @deprecated */
ES5 = "es5",
ES6 = "es6",
ES2015 = "es2015",
Expand All @@ -3299,6 +3300,7 @@ export const enum ScriptTarget {
ESNext = "esnext",
JSON = "json",
Latest = ESNext,
LatestStandard = ES2024,
}

{
Expand Down
2 changes: 1 addition & 1 deletion src/services/preProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

export function preProcessFile(sourceText: string, readImportFiles = true, detectJavaScriptImports = false): PreProcessedFileInfo {
const pragmaContext: PragmaContext = {
languageVersion: ScriptTarget.ES5, // controls whether the token scanner considers unicode identifiers or not - shouldn't matter, since we're only using it for trivia
languageVersion: ScriptTarget.LatestStandard, // controls whether the token scanner considers unicode identifiers or not - shouldn't matter, since we're only using it for trivia
pragmas: undefined,
checkJsDirective: undefined,
referencedFiles: [],
Expand Down
3 changes: 1 addition & 2 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1382,9 +1382,8 @@ export function displayPartsToString(displayParts: SymbolDisplayPart[] | undefin
}

export function getDefaultCompilerOptions(): CompilerOptions {
// Always default to "ScriptTarget.ES5" for the language service
return {
target: ScriptTarget.ES5,
target: ScriptTarget.LatestStandard,
jsx: JsxEmit.Preserve,
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/helpers/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ interface Symbol {
`;

export function getProjectConfigWithNodeNext(withNodeNext: boolean | undefined): object | undefined {
return withNodeNext ? { module: "nodenext", target: "es5" } : undefined;
return withNodeNext ? { module: "nodenext", target: "es2015" } : undefined;
}
2 changes: 1 addition & 1 deletion src/testRunner/unittests/helpers/demoProjectReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function getSysForDemoProjectReferences(): TestServerHost {
"/user/username/projects/demo/tsconfig-base.json": jsonToReadableText({
compilerOptions: {
declaration: true,
target: "es5",
target: "es2015",
module: "commonjs",
strict: true,
noUnusedLocals: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ function testConvertToAsyncFunction(it: Mocha.PendingTestFunction, caption: stri
}
const host = TestServerHost.createServerHost(files);
const projectService = new TestProjectService(host);
projectService.setCompilerOptionsForInferredProjects({ target: ts.server.protocol.ScriptTarget.ES5 });
projectService.openClientFile(file.path);
return ts.first(projectService.inferredProjects).getLanguageService();
}
Expand Down
2 changes: 2 additions & 0 deletions src/testRunner/unittests/services/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe("unittests:: services:: Transpile", () => {
}
if (transpileOptions.compilerOptions.target === undefined) {
transpileOptions.compilerOptions.target = ts.ScriptTarget.ES5;
transpileOptions.compilerOptions.ignoreDeprecations = "6.0";
}

if (transpileOptions.compilerOptions.newLine === undefined) {
Expand Down Expand Up @@ -204,6 +205,7 @@ var x = 0;`,
emitDecoratorMetadata: true,
experimentalDecorators: true,
target: ts.ScriptTarget.ES5,
ignoreDeprecations: "6.0",
},
},
testVerbatimModuleSyntax: true,
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("unittests:: tsbuild:: on project with emitDeclarationOnly:: set to tru
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
incremental: true,
target: "es5",
target: "es2015",
module: "commonjs",
declaration: true,
declarationMap: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => {
`,
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
declaration: true,
outDir: "obj",
incremental: true,
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsbuild/resolveJsonModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe("unittests:: tsbuild:: with resolveJsonModule:: option on project impor
}),
"/home/src/workspaces/solution/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
module: "commonjs",
rootDir: "./",
composite: true,
Expand Down
14 changes: 12 additions & 2 deletions src/testRunner/unittests/tsbuild/sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Baseline } from "../../_namespaces/Harness.js";
import * as ts from "../../_namespaces/ts.js";
import { dedent } from "../../_namespaces/Utils.js";
import { jsonToReadableText } from "../helpers.js";
import {
fakeTsVersion,
Expand Down Expand Up @@ -241,7 +242,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
sys: getSysForSampleProjectReferences,
commandLineArgs: ["--b", "tests", "--verbose"],
modifySystem: sys => {
sys.writeFile("tests/tsconfig.base.json", jsonToReadableText({ compilerOptions: { target: "es5" } }));
sys.writeFile("tests/tsconfig.base.json", jsonToReadableText({ compilerOptions: { target: "es2015" } }));
sys.replaceFileText("tests/tsconfig.json", `"references": [`, `"extends": "./tsconfig.base.json", "references": [`);
},
edits: [{
Expand Down Expand Up @@ -510,6 +511,15 @@ class someClass2 { }`,
libFile.path,
`/// <reference lib="esnext" />`,
);
sys.writeFile(
"core/index.ts",
dedent`
export const someString: string = "HELLO WORLD";
export function leftPad(s: string, n: number) { return s + n; }
export function multiply(a: number, b: number) { return a * b; }
export function exponentiate(a: number, b: number) { return a ** b; }
`,
);
sys.writeFile(
"core/tsconfig.json",
jsonToReadableText({
Expand All @@ -524,7 +534,7 @@ class someClass2 { }`,
},
edits: [{
caption: "incremental-declaration-changes",
edit: sys => sys.replaceFileText("core/tsconfig.json", "esnext", "es5"),
edit: sys => sys.replaceFileText("core/tsconfig.json", "esnext", "es2015"),
}],
});

Expand Down
8 changes: 4 additions & 4 deletions src/testRunner/unittests/tsc/composite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("unittests:: tsc:: composite::", () => {
"/home/src/workspaces/project/src/main.ts": "export const x = 10;",
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
module: "commonjs",
composite: true,
},
Expand All @@ -33,7 +33,7 @@ describe("unittests:: tsc:: composite::", () => {
"/home/src/workspaces/project/src/main.ts": "export const x = 10;",
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
module: "commonjs",
composite: true,
},
Expand All @@ -53,7 +53,7 @@ describe("unittests:: tsc:: composite::", () => {
"/home/src/workspaces/project/src/main.ts": "export const x = 10;",
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
module: "commonjs",
composite: true,
tsBuildInfoFile: "tsconfig.json.tsbuildinfo",
Expand All @@ -74,7 +74,7 @@ describe("unittests:: tsc:: composite::", () => {
"/home/src/workspaces/project/src/main.ts": "export const x = 10;",
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
module: "commonjs",
composite: true,
tsBuildInfoFile: "tsconfig.json.tsbuildinfo",
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/tsc/declarationEmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("unittests:: tsc:: declarationEmit::", () => {
function pluginOneConfig() {
return jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
declaration: true,
traceResolution: true,
},
Expand Down Expand Up @@ -236,7 +236,7 @@ ${pluginOneAction()}`,
compilerOptions: {
outDir: "dist",
rootDir: "src",
target: "es5",
target: "es2015",
module: "commonjs",
strict: true,
esModuleInterop: true,
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsc/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("unittests:: tsc:: incremental::", () => {
"/home/src/workspaces/project/src/main.ts": "export const x = 10;",
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({
compilerOptions: {
target: "es5",
target: "es2015",
module: "commonjs",
},
include: [
Expand Down
7 changes: 4 additions & 3 deletions src/testRunner/unittests/tscWatch/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe("unittests:: tscWatch:: incremental:: emit file --incremental", () => {
{ currentDirectory: project },
);
const reportDiagnostic = ts.createDiagnosticReporter(system);
const parsedConfig = ts.parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, reportDiagnostic)!;
const parsedConfig = ts.parseConfigFileWithSystem("tsconfig.json", { target: ts.ScriptTarget.ES5, module: ts.ModuleKind.AMD }, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, reportDiagnostic)!;
ts.performIncrementalCompilation({
rootNames: parsedConfig.fileNames,
options: parsedConfig.options,
Expand All @@ -167,7 +167,7 @@ describe("unittests:: tscWatch:: incremental:: emit file --incremental", () => {
system,
});

const command = ts.parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, ts.noop)!;
const command = ts.parseConfigFileWithSystem("tsconfig.json", { target: ts.ScriptTarget.ES5, module: ts.ModuleKind.AMD }, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, ts.noop)!;
const builderProgram = ts.createIncrementalProgram({
rootNames: command.fileNames,
options: command.options,
Expand Down Expand Up @@ -200,6 +200,7 @@ describe("unittests:: tscWatch:: incremental:: emit file --incremental", () => {

assert.deepEqual(builderProgram.state.compilerOptions, {
incremental: true,
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.AMD,
configFilePath: config.path,
ignoreDeprecations: "6.0",
Expand Down Expand Up @@ -242,7 +243,7 @@ describe("unittests:: tscWatch:: incremental:: emit file --incremental", () => {
content: jsonToReadableText({
compilerOptions: {
incremental: true,
target: "es5",
target: "es2015",
module: "commonjs",
declaration: true,
emitDeclarationOnly: true,
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/tscWatch/programUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ declare const eval: any`,
{
compilerOptions: {
module: "commonjs",
target: "es5",
target: "es2015",
noImplicitAny: true,
sourceMap: false,
lib: [
Expand All @@ -1010,7 +1010,7 @@ declare const eval: any`,
{
compilerOptions: {
module: "commonjs",
target: "es5",
target: "es2015",
noImplicitAny: true,
sourceMap: false,
lib: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== ES3For-ofTypeCheck1.ts (0 errors) ====
for (var v of "") { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== ES3For-ofTypeCheck2.ts (0 errors) ====
for (var v of [true]) { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== ES3For-ofTypeCheck4.ts (0 errors) ====
var union: string | string[];
for (const v of union) { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== ES3For-ofTypeCheck6.ts (0 errors) ====
var union: string[] | number[];
for (var v of union) { }
8 changes: 8 additions & 0 deletions tests/baselines/reference/ES5For-of1(target=es5).errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.


!!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
==== ES5For-of1.ts (0 errors) ====
for (var v of ['a', 'b', 'c']) {
console.log(v);
}
Loading
Loading