Skip to content

Commit eef6a0c

Browse files
authored
Deprecate baseUrl (#62509)
1 parent 31a0ead commit eef6a0c

File tree

224 files changed

+6800
-1661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+6800
-1661
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4721,6 +4721,10 @@
47214721
"category": "Error",
47224722
"code": 5110
47234723
},
4724+
"Visit https://aka.ms/ts6 for migration information.": {
4725+
"category": "Message",
4726+
"code": 5111
4727+
},
47244728

47254729
"Generates a sourcemap for each corresponding '.d.ts' file.": {
47264730
"category": "Message",

src/compiler/program.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4408,8 +4408,8 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
44084408
function checkDeprecations(
44094409
deprecatedIn: string,
44104410
removedIn: string,
4411-
createDiagnostic: (name: string, value: string | undefined, useInstead: string | undefined, message: DiagnosticMessage, ...args: DiagnosticArguments) => void,
4412-
fn: (createDeprecatedDiagnostic: (name: string, value?: string, useInstead?: string) => void) => void,
4411+
createDiagnostic: (name: string, value: string | undefined, useInstead: string | undefined, related: DiagnosticMessage | undefined, message: DiagnosticMessage, ...args: DiagnosticArguments) => void,
4412+
fn: (createDeprecatedDiagnostic: (name: string, value?: string, useInstead?: string, related?: DiagnosticMessage) => void) => void,
44134413
) {
44144414
const deprecatedInVersion = new Version(deprecatedIn);
44154415
const removedInVersion = new Version(removedIn);
@@ -4420,36 +4420,44 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
44204420
const canBeSilenced = !mustBeRemoved && ignoreDeprecationsVersion.compareTo(deprecatedInVersion) === Comparison.LessThan;
44214421

44224422
if (mustBeRemoved || canBeSilenced) {
4423-
fn((name, value, useInstead) => {
4423+
fn((name, value, useInstead, related) => {
44244424
if (mustBeRemoved) {
44254425
if (value === undefined) {
4426-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_has_been_removed_Please_remove_it_from_your_configuration, name);
4426+
createDiagnostic(name, value, useInstead, related, Diagnostics.Option_0_has_been_removed_Please_remove_it_from_your_configuration, name);
44274427
}
44284428
else {
4429-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_1_has_been_removed_Please_remove_it_from_your_configuration, name, value);
4429+
createDiagnostic(name, value, useInstead, related, Diagnostics.Option_0_1_has_been_removed_Please_remove_it_from_your_configuration, name, value);
44304430
}
44314431
}
44324432
else {
44334433
if (value === undefined) {
4434-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error, name, removedIn, deprecatedIn);
4434+
createDiagnostic(name, value, useInstead, related, Diagnostics.Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error, name, removedIn, deprecatedIn);
44354435
}
44364436
else {
4437-
createDiagnostic(name, value, useInstead, Diagnostics.Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error, name, value, removedIn, deprecatedIn);
4437+
createDiagnostic(name, value, useInstead, related, Diagnostics.Option_0_1_is_deprecated_and_will_stop_functioning_in_TypeScript_2_Specify_compilerOption_ignoreDeprecations_Colon_3_to_silence_this_error, name, value, removedIn, deprecatedIn);
44384438
}
44394439
}
44404440
});
44414441
}
44424442
}
44434443

44444444
function verifyDeprecatedCompilerOptions() {
4445-
function createDiagnostic(name: string, value: string | undefined, useInstead: string | undefined, message: DiagnosticMessage, ...args: DiagnosticArguments) {
4445+
function createDiagnostic(name: string, value: string | undefined, useInstead: string | undefined, related: DiagnosticMessage | undefined, message: DiagnosticMessage, ...args: DiagnosticArguments) {
44464446
if (useInstead) {
4447-
const details = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Use_0_instead, useInstead);
4447+
let details = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Use_0_instead, useInstead);
4448+
if (related) {
4449+
details = chainDiagnosticMessages(details, related);
4450+
}
44484451
const chain = chainDiagnosticMessages(details, message, ...args);
44494452
createDiagnosticForOption(/*onKey*/ !value, name, /*option2*/ undefined, chain);
44504453
}
44514454
else {
4452-
createDiagnosticForOption(/*onKey*/ !value, name, /*option2*/ undefined, message, ...args);
4455+
let details: DiagnosticMessageChain | undefined;
4456+
if (related) {
4457+
details = chainDiagnosticMessages(/*details*/ undefined, related);
4458+
}
4459+
const chain = chainDiagnosticMessages(details, message, ...args);
4460+
createDiagnosticForOption(/*onKey*/ !value, name, /*option2*/ undefined, chain);
44534461
}
44544462
}
44554463

@@ -4488,13 +4496,16 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
44884496

44894497
checkDeprecations("6.0", "7.0", createDiagnostic, createDeprecatedDiagnostic => {
44904498
if (options.moduleResolution === ModuleResolutionKind.Node10) {
4491-
createDeprecatedDiagnostic("moduleResolution", "node10");
4499+
createDeprecatedDiagnostic("moduleResolution", "node10", /*useInstead*/ undefined, Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information);
4500+
}
4501+
if (options.baseUrl !== undefined) {
4502+
createDeprecatedDiagnostic("baseUrl", /*value*/ undefined, /*useInstead*/ undefined, Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information);
44924503
}
44934504
});
44944505
}
44954506

44964507
function verifyDeprecatedProjectReference(ref: ProjectReference, parentFile: JsonSourceFile | undefined, index: number) {
4497-
function createDiagnostic(_name: string, _value: string | undefined, _useInstead: string | undefined, message: DiagnosticMessage, ...args: DiagnosticArguments) {
4508+
function createDiagnostic(_name: string, _value: string | undefined, _useInstead: string | undefined, _related: DiagnosticMessage | undefined, message: DiagnosticMessage, ...args: DiagnosticArguments) {
44984509
createDiagnosticForReference(parentFile, index, message, ...args);
44994510
}
45004511

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7400,6 +7400,7 @@ export interface CompilerOptions {
74007400
allowUnreachableCode?: boolean;
74017401
allowUnusedLabels?: boolean;
74027402
alwaysStrict?: boolean; // Always combine with strict property
7403+
/** @deprecated */
74037404
baseUrl?: string;
74047405
/**
74057406
* An error if set - this should only go through the -b pipeline and not actually be observed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
2+
Visit https://aka.ms/ts6 for migration information.
3+
4+
5+
!!! error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
6+
!!! error TS5101: Visit https://aka.ms/ts6 for migration information.
7+
==== /proj/defs/cc.ts (0 errors) ====
8+
export const enum CharCode {
9+
A,
10+
B
11+
}
12+
==== /proj/component/file.ts (0 errors) ====
13+
import { CharCode } from 'defs/cc';
14+
export class User {
15+
method(input: number) {
16+
if (CharCode.A === input) {}
17+
}
18+
}
19+

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7016,6 +7016,7 @@ declare namespace ts {
70167016
allowUnreachableCode?: boolean;
70177017
allowUnusedLabels?: boolean;
70187018
alwaysStrict?: boolean;
7019+
/** @deprecated */
70197020
baseUrl?: string;
70207021
/** @deprecated */
70217022
charset?: string;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/tsconfig.json(6,5): error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
2+
Visit https://aka.ms/ts6 for migration information.
3+
4+
5+
==== /tsconfig.json (1 errors) ====
6+
{
7+
"compilerOptions": {
8+
"module": "nodenext",
9+
"declaration": true,
10+
"outDir": "temp",
11+
"baseUrl": "."
12+
~~~~~~~~~
13+
!!! error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
14+
!!! error TS5101: Visit https://aka.ms/ts6 for migration information.
15+
}
16+
}
17+
18+
==== /packages/compiler-core/src/index.ts (0 errors) ====
19+
import { PluginConfig } from "@babel/parser";
20+
21+
==== /packages/compiler-sfc/src/index.ts (0 errors) ====
22+
import { createPlugin } from "@babel/parser";
23+
export function resolveParserPlugins() {
24+
return [createPlugin()];
25+
}
26+
27+
==== /node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/package.json (0 errors) ====
28+
{
29+
"name": "@babel/parser",
30+
"version": "7.23.6",
31+
"main": "./lib/index.js",
32+
"types": "./typings/babel-parser.d.ts"
33+
}
34+
35+
==== /node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/typings/babel-parser.d.ts (0 errors) ====
36+
export declare function createPlugin(): PluginConfig;
37+
export declare class PluginConfig {}
38+
39+
==== /packages/compiler-core/package.json (0 errors) ====
40+
{
41+
"name": "@vue/compiler-core",
42+
"version": "3.0.0",
43+
"main": "./src/index.ts",
44+
"dependencies": {
45+
"@babel/parser": "^7.0.0"
46+
}
47+
}
48+
49+
==== /packages/compiler-sfc/package.json (0 errors) ====
50+
{
51+
"name": "@vue/compiler-sfc",
52+
"version": "3.0.0",
53+
"main": "./src/index.ts",
54+
"dependencies": {
55+
"@babel/parser": "^7.0.0",
56+
"@vue/compiler-core": "^3.0.0"
57+
}
58+
}
59+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
packages/b/tsconfig.json(5,9): error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
2+
Visit https://aka.ms/ts6 for migration information.
3+
4+
5+
==== packages/b/tsconfig.json (1 errors) ====
6+
{
7+
"compilerOptions": {
8+
"outDir": "dist",
9+
"declaration": true,
10+
"baseUrl": ".",
11+
~~~~~~~~~
12+
!!! error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
13+
!!! error TS5101: Visit https://aka.ms/ts6 for migration information.
14+
"paths": {
15+
"@ts-bug/a": ["../a"]
16+
}
17+
}
18+
}
19+
20+
21+
==== packages/b/src/index.ts (0 errors) ====
22+
import { a } from "@ts-bug/a";
23+
24+
export function b(text: string) {
25+
return a(text);
26+
}
27+
==== packages/a/index.d.ts (0 errors) ====
28+
declare module "@ts-bug/a" {
29+
export type AText = {
30+
value: string;
31+
};
32+
export function a(text: string): AText;
33+
}
34+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
packages/lab/tsconfig.json(5,9): error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
2+
Visit https://aka.ms/ts6 for migration information.
3+
4+
5+
==== packages/lab/tsconfig.json (1 errors) ====
6+
{
7+
"compilerOptions": {
8+
"outDir": "dist",
9+
"declaration": true,
10+
"baseUrl": "../",
11+
~~~~~~~~~
12+
!!! error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
13+
!!! error TS5101: Visit https://aka.ms/ts6 for migration information.
14+
"paths": {
15+
"@ts-bug/core": ["./core/src"],
16+
"@ts-bug/core/*": ["./core/src/*"],
17+
"@ts-bug/lab": ["./lab/src"],
18+
"@ts-bug/lab/*": ["./lab/src/*"],
19+
"@ts-bug/styles": ["./styles/src"],
20+
"@ts-bug/styles/*": ["./styles/src/*"]
21+
}
22+
}
23+
}
24+
==== packages/lab/src/index.ts (0 errors) ====
25+
import { createSvgIcon } from "@ts-bug/core/utils";
26+
export default createSvgIcon("Hello", "ArrowLeft");
27+
28+
==== packages/core/src/index.d.ts (0 errors) ====
29+
export * from "./utils";
30+
export { default as SvgIcon } from "./SvgIcon";
31+
32+
==== packages/core/src/SvgIcon.d.ts (0 errors) ====
33+
import { StyledComponentProps } from "@ts-bug/styles";
34+
export interface SvgIconProps extends StyledComponentProps<"root"> {
35+
children?: string[];
36+
}
37+
export interface SomeInterface {
38+
myProp: string;
39+
}
40+
declare const SvgIcon: SomeInterface;
41+
export default SvgIcon;
42+
43+
==== packages/core/src/utils.d.ts (0 errors) ====
44+
import SvgIcon from "./SvgIcon";
45+
export function createSvgIcon(path: string, displayName: string): typeof SvgIcon;
46+
47+
==== packages/styles/src/index.d.ts (0 errors) ====
48+
export interface StyledComponentProps<ClassKey extends string> {
49+
classes?: Record<ClassKey, string>;
50+
}
51+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
2+
Visit https://aka.ms/ts6 for migration information.
3+
4+
5+
!!! error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
6+
!!! error TS5101: Visit https://aka.ms/ts6 for migration information.
7+
==== src/lib/operators/scalar.ts (0 errors) ====
8+
export interface Scalar {
9+
(): string;
10+
value: number;
11+
}
12+
13+
export function scalar(value: string): Scalar {
14+
return null as any;
15+
}
16+
==== src/settings/spacing.ts (0 errors) ====
17+
import { scalar } from '../lib/operators/scalar';
18+
19+
export default {
20+
get xs() {
21+
return scalar("14px");
22+
}
23+
};
24+

tests/baselines/reference/declarationEmitPrefersPathKindBasedOnBundling.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function scalar(value: string): Scalar {
1616

1717
return null as any;
1818
>null as any : any
19+
> : ^^^
1920
}
2021
=== src/settings/spacing.ts ===
2122
import { scalar } from '../lib/operators/scalar';

0 commit comments

Comments
 (0)