forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid the double-symbol trick for enums
Fixes microsoft#33575.
- Loading branch information
1 parent
bae111f
commit 6eb3daa
Showing
16 changed files
with
105 additions
and
46 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
tests/cases/conformance/jsdoc/use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/mod1.js (0 errors) ==== | ||
/** @callback Con - some kind of continuation | ||
* @param {object | undefined} error | ||
* @return {any} I don't even know what this should return | ||
*/ | ||
module.exports = C | ||
function C() { | ||
this.p = 1 | ||
} | ||
|
||
==== tests/cases/conformance/jsdoc/use.js (1 errors) ==== | ||
/** @param {import('./mod1').Con} k */ | ||
~~~ | ||
!!! error TS2694: Namespace 'C' has no exported member 'Con'. | ||
function f(k) { | ||
if (1 === 2 - 1) { | ||
// I guess basic math works! | ||
} | ||
return k({ ok: true}) | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
tests/cases/conformance/jsdoc/namespaced.js(8,5): error TS8030: The type of a function declaration must match the function's signature. | ||
tests/cases/conformance/jsdoc/namespaced.js(8,22): error TS2694: Namespace 'NS.Nested' has no exported member 'Inner'. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/namespaced.js (2 errors) ==== | ||
/** | ||
* @callback NS.Nested.Inner | ||
* @param {Object} space - spaaaaaaaaace | ||
* @param {Object} peace - peaaaaaaaaace | ||
* @return {string | number} | ||
*/ | ||
var x = 1; | ||
/** @type {NS.Nested.Inner} */ | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS8030: The type of a function declaration must match the function's signature. | ||
~~~~~ | ||
!!! error TS2694: Namespace 'NS.Nested' has no exported member 'Inner'. | ||
function f(space, peace) { | ||
return '1' | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
tests/cases/conformance/jsdoc/value.js(3,7): error TS2322: Type 'string' is not assignable to type '{ ADD: string; REMOVE: string; }'. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/type.js (0 errors) ==== | ||
/** @typedef {import("./mod1").TestEnum} TE */ | ||
/** @type {TE} */ | ||
const test = 'add' | ||
/** @type {import("./mod1").TestEnum} */ | ||
const tost = 'remove' | ||
|
||
==== tests/cases/conformance/jsdoc/value.js (1 errors) ==== | ||
import { TestEnum } from "./mod1" | ||
/** @type {TestEnum} */ | ||
const tist = TestEnum.ADD | ||
~~~~ | ||
!!! error TS2322: Type 'string' is not assignable to type '{ ADD: string; REMOVE: string; }'. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/mod1.js (0 errors) ==== | ||
/** @enum {string} */ | ||
export const TestEnum = { | ||
ADD: 'add', | ||
REMOVE: 'remove' | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
=== tests/cases/conformance/jsdoc/enumTagOnExports.js === | ||
/** @enum {number} */ | ||
exports.a = {}; | ||
>exports.a : Symbol(a, Decl(enumTagOnExports.js, 0, 0), Decl(enumTagOnExports.js, 1, 8), Decl(enumTagOnExports.js, 0, 4)) | ||
>exports : Symbol(a, Decl(enumTagOnExports.js, 0, 0), Decl(enumTagOnExports.js, 1, 8), Decl(enumTagOnExports.js, 0, 4)) | ||
>a : Symbol(a, Decl(enumTagOnExports.js, 0, 0), Decl(enumTagOnExports.js, 1, 8), Decl(enumTagOnExports.js, 0, 4)) | ||
>exports.a : Symbol(a, Decl(enumTagOnExports.js, 0, 0), Decl(enumTagOnExports.js, 1, 8)) | ||
>exports : Symbol(a, Decl(enumTagOnExports.js, 0, 0), Decl(enumTagOnExports.js, 1, 8)) | ||
>a : Symbol(a, Decl(enumTagOnExports.js, 0, 0), Decl(enumTagOnExports.js, 1, 8)) | ||
|
||
/** @enum {string} */ | ||
module.exports.b = {}; | ||
>module.exports.b : Symbol(b, Decl(enumTagOnExports.js, 1, 15), Decl(enumTagOnExports.js, 4, 15), Decl(enumTagOnExports.js, 3, 4)) | ||
>module.exports : Symbol(b, Decl(enumTagOnExports.js, 1, 15), Decl(enumTagOnExports.js, 4, 15), Decl(enumTagOnExports.js, 3, 4)) | ||
>module.exports.b : Symbol(b, Decl(enumTagOnExports.js, 1, 15), Decl(enumTagOnExports.js, 4, 15)) | ||
>module.exports : Symbol(b, Decl(enumTagOnExports.js, 1, 15), Decl(enumTagOnExports.js, 4, 15)) | ||
>module : Symbol(module, Decl(enumTagOnExports.js, 1, 15)) | ||
>exports : Symbol("tests/cases/conformance/jsdoc/enumTagOnExports", Decl(enumTagOnExports.js, 0, 0)) | ||
>b : Symbol(b, Decl(enumTagOnExports.js, 1, 15), Decl(enumTagOnExports.js, 4, 15), Decl(enumTagOnExports.js, 3, 4)) | ||
>b : Symbol(b, Decl(enumTagOnExports.js, 1, 15), Decl(enumTagOnExports.js, 4, 15)) | ||
|
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