Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test
  • Loading branch information
jakebailey committed Feb 18, 2025
commit 63fc29fc9f774ec24132d4d16568632e0541e635
8 changes: 8 additions & 0 deletions tests/baselines/reference/erasableSyntaxOnly.errors.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
commonjs.cts(1,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
commonjs.cts(2,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
esm.mts(2,1): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
index.ts(3,17): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
index.ts(6,11): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
index.ts(10,11): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
Expand Down Expand Up @@ -104,4 +105,11 @@ 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 (1 errors) ====
const foo = 1234;
export default foo;
~~~~~~~~~~~~~~~~~~~
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.

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
@@ -1,3 +1,4 @@
esm.d.mts(1,1): error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.
index.d.ts(1,1): error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.


Expand Down Expand Up @@ -65,4 +66,11 @@ 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 (1 errors) ====
const foo = 1234;
~~~~~
!!! error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.
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 ===
const foo = 1234;
>foo : Symbol(foo, Decl(esm.d.mts, 0, 5))

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

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 ===
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
const foo = 1234;
export default foo;