Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/typescript): Support const modifier on type parameters (#6672)
**Related issue:** - microsoft/TypeScript#51865.
- Loading branch information
1 parent
b102504
commit 019cf37
Showing
784 changed files
with
11,175 additions
and
19 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
crates/swc/tests/tsc-references/typeParameterConstModifiers.1.normal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//// [typeParameterConstModifiers.ts] | ||
//! | ||
//! x 'const' modifier can only appear on a type parameter of a function, method or class | ||
//! ,-[41:1] | ||
//! 41 | const fx1 = <const T>(x: T) => x; | ||
//! 42 | const fx2 = <const T,>(x: T) => x; | ||
//! 43 | | ||
//! 44 | interface I1<const T> { x: T } // Error | ||
//! : ^^^^^ | ||
//! 45 | | ||
//! 46 | interface I2 { | ||
//! 47 | f<const T>(x: T): T; | ||
//! `---- | ||
//! | ||
//! x 'const' modifier can only appear on a type parameter of a function, method or class | ||
//! ,-[47:1] | ||
//! 47 | f<const T>(x: T): T; | ||
//! 48 | } | ||
//! 49 | | ||
//! 50 | type T1<const T> = T; // Error | ||
//! : ^^^^^ | ||
//! 51 | | ||
//! 52 | type T2 = <const T>(x: T) => T; | ||
//! 53 | type T3 = { <const T>(x: T): T }; | ||
//! `---- |
25 changes: 25 additions & 0 deletions
25
crates/swc/tests/tsc-references/typeParameterConstModifiers.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//// [typeParameterConstModifiers.ts] | ||
//! | ||
//! x 'const' modifier can only appear on a type parameter of a function, method or class | ||
//! ,-[41:1] | ||
//! 41 | const fx1 = <const T>(x: T) => x; | ||
//! 42 | const fx2 = <const T,>(x: T) => x; | ||
//! 43 | | ||
//! 44 | interface I1<const T> { x: T } // Error | ||
//! : ^^^^^ | ||
//! 45 | | ||
//! 46 | interface I2 { | ||
//! 47 | f<const T>(x: T): T; | ||
//! `---- | ||
//! | ||
//! x 'const' modifier can only appear on a type parameter of a function, method or class | ||
//! ,-[47:1] | ||
//! 47 | f<const T>(x: T): T; | ||
//! 48 | } | ||
//! 49 | | ||
//! 50 | type T1<const T> = T; // Error | ||
//! : ^^^^^ | ||
//! 51 | | ||
//! 52 | type T2 = <const T>(x: T) => T; | ||
//! 53 | type T3 = { <const T>(x: T): T }; | ||
//! `---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.