forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not print typeof operator for Symbol types
and rather print out symbol or unique symbol Signed-off-by: Hana Joo <hanajoo@google.com>
- Loading branch information
Showing
10 changed files
with
102 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
export const a = { | ||
value: 0, | ||
array: [1, 2, 3] | ||
array: [1, 2, 3], | ||
} as const; | ||
const b = { | ||
value: 0, | ||
array: [1, 2, 3] | ||
array: [1, 2, 3], | ||
} as const; | ||
export const c: { | ||
value: number; | ||
array: number[]; | ||
} = { | ||
value: 0, | ||
array: [1, 2, 3] | ||
array: [1, 2, 3], | ||
}; | ||
const d = { | ||
value: 0, | ||
array: [1, 2, 3] | ||
array: [1, 2, 3], | ||
}; |
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,14 @@ | ||
export const a: unique symbol = Symbol(); | ||
export function foo(): symbol { | ||
return Symbol(); | ||
} | ||
export const z: { | ||
z: symbol; | ||
} = { | ||
z: Symbol(), | ||
}; | ||
export const z2: { | ||
readonly z: symbol; | ||
} = { | ||
z: Symbol() | ||
} as const; |
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,14 @@ | ||
|
||
export const a = Symbol(); | ||
|
||
export function foo() { | ||
return Symbol(); | ||
} | ||
|
||
export const z = { | ||
z: Symbol(), | ||
}; | ||
|
||
export const z2 = { | ||
z: Symbol() | ||
} as const; |
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
23 changes: 23 additions & 0 deletions
23
tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports21.ts
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,23 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
// @isolatedDeclarations: true | ||
// @declaration: true | ||
// @lib: es2019 | ||
//// export const a = { | ||
//// z: Symbol() | ||
//// } as const; | ||
|
||
verify.codeFixAvailable([ | ||
{ description: ts.Diagnostics.Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_declaration_emit.message } | ||
]); | ||
|
||
verify.codeFix({ | ||
description: ts.Diagnostics.Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_declaration_emit.message, | ||
index: 0, | ||
newFileContent: | ||
`export const a: { | ||
readonly z: symbol; | ||
} = { | ||
z: Symbol() | ||
} as const;` | ||
}); |
21 changes: 21 additions & 0 deletions
21
tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports22.ts
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,21 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
// @isolatedDeclarations: true | ||
// @declaration: true | ||
// @lib: es2019 | ||
//// export function foo () { | ||
//// return Symbol(); | ||
//// } | ||
|
||
verify.codeFixAvailable([ | ||
{ description: ts.Diagnostics.Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_declaration_emit.message } | ||
]); | ||
|
||
verify.codeFix({ | ||
description: ts.Diagnostics.Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_declaration_emit.message, | ||
index: 0, | ||
newFileContent: | ||
`export function foo(): symbol { | ||
return Symbol(); | ||
}` | ||
}); |