Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/microsoft/TypeScript into 6…
Browse files Browse the repository at this point in the history
…0881
  • Loading branch information
NamHaiBui committed Feb 19, 2025
2 parents a697946 + 246507f commit c662343
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "https://www.typescriptlang.org/",
"version": "5.8.0",
"version": "5.9.0",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47981,7 +47981,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return;
}

if (compilerOptions.erasableSyntaxOnly && !(node.flags & NodeFlags.Ambient)) {
if (compilerOptions.erasableSyntaxOnly && node.isExportEquals && !(node.flags & NodeFlags.Ambient)) {
error(node, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled);
}
const container = node.parent.kind === SyntaxKind.SourceFile ? node.parent : node.parent.parent as ModuleDeclaration;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/corePublic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
// If changing the text in this section, be sure to test `configurePrerelease` too.
export const versionMajorMinor = "5.8";
export const versionMajorMinor = "5.9";
// The following is baselined as a literal template type without intervention
/** The version of the TypeScript compiler release */
export const version: string = `${versionMajorMinor}.0-dev`;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3634,7 +3634,7 @@ declare namespace ts {
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
}
}
const versionMajorMinor = "5.8";
const versionMajorMinor = "5.9";
/** The version of the TypeScript compiler release */
const version: string;
/**
Expand Down
5 changes: 5 additions & 0 deletions tests/baselines/reference/erasableSyntaxOnly.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@ index.ts(28,12): error TS1294: This syntax is not allowed when 'erasableSyntaxOn
==== other.d.cts (0 errors) ====
declare function foo(): void;
export = foo;


==== esm.mts (0 errors) ====
const foo = 1234;
export default foo;

8 changes: 8 additions & 0 deletions tests/baselines/reference/erasableSyntaxOnly.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export = foo;
//// [other.d.cts]
declare function foo(): void;
export = foo;


//// [esm.mts]
const foo = 1234;
export default foo;


//// [index.js]
Expand Down Expand Up @@ -119,3 +124,6 @@ var MyClassOk = /** @class */ (function () {
"use strict";
var foo = require("./other.cjs");
module.exports = foo;
//// [esm.mjs]
var foo = 1234;
export default foo;
8 changes: 8 additions & 0 deletions tests/baselines/reference/erasableSyntaxOnly.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,11 @@ declare function foo(): void;
export = foo;
>foo : Symbol(foo, Decl(other.d.cts, 0, 0))


=== esm.mts ===
const foo = 1234;
>foo : Symbol(foo, Decl(esm.mts, 0, 5))

export default foo;
>foo : Symbol(foo, Decl(esm.mts, 0, 5))

12 changes: 12 additions & 0 deletions tests/baselines/reference/erasableSyntaxOnly.types
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,15 @@ export = foo;
>foo : () => void
> : ^^^^^^


=== esm.mts ===
const foo = 1234;
>foo : 1234
> : ^^^^
>1234 : 1234
> : ^^^^

export default foo;
>foo : 1234
> : ^^^^

Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ index.d.ts(1,1): error TS1046: Top-level declarations in .d.ts files must start
==== other.d.cts (0 errors) ====
declare function foo(): void;
export = foo;


==== esm.d.mts (0 errors) ====
declare const foo = 1234;
export default foo;

Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,11 @@ declare function foo(): void;
export = foo;
>foo : Symbol(foo, Decl(other.d.cts, 0, 0))


=== esm.d.mts ===
declare const foo = 1234;
>foo : Symbol(foo, Decl(esm.d.mts, 0, 13))

export default foo;
>foo : Symbol(foo, Decl(esm.d.mts, 0, 13))

12 changes: 12 additions & 0 deletions tests/baselines/reference/erasableSyntaxOnlyDeclaration.types
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,15 @@ export = foo;
>foo : () => void
> : ^^^^^^


=== esm.d.mts ===
declare const foo = 1234;
>foo : 1234
> : ^^^^
>1234 : 1234
> : ^^^^

export default foo;
>foo : 1234
> : ^^^^

5 changes: 5 additions & 0 deletions tests/cases/compiler/erasableSyntaxOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ export = foo;
// @filename: other.d.cts
declare function foo(): void;
export = foo;


// @filename: esm.mts
const foo = 1234;
export default foo;
5 changes: 5 additions & 0 deletions tests/cases/compiler/erasableSyntaxOnlyDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ export = foo;
// @filename: other.d.cts
declare function foo(): void;
export = foo;


// @filename: esm.d.mts
declare const foo = 1234;
export default foo;

0 comments on commit c662343

Please sign in to comment.