Skip to content

Error recognizing string literal type #15925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zarel opened this issue May 18, 2017 · 2 comments
Closed

Error recognizing string literal type #15925

Zarel opened this issue May 18, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Zarel
Copy link

Zarel commented May 18, 2017

TypeScript Version: nightly (2.4.0-dev.20170516)

Code

/** @typedef {'Pokedex' | 'FormatsData' | 'Learnsets' | 'Movedex' | 'Statuses' | 'TypeChart' | 'Scripts' | 'Items' | 'Abilities' | 'Natures' | 'Formats' | 'Aliases'} DataType */
/** @type {DataType[]} */
const DATA_TYPES = ['Pokedex', 'FormatsData', 'Learnsets', 'Movedex', 'Statuses', 'TypeChart', 'Scripts', 'Items', 'Abilities', 'Natures', 'Formats', 'Aliases'];

Expected behavior:
No error

Actual behavior:

sim/dex.js(87,7): error TS2322: Type 'string[]' is not assignable to type '("Pokedex" | "FormatsData" | "Learnsets" | "Movedex" | "Statuses" | "TypeChart" | "Scripts" | "It...'.

Type 'string' is not assignable to type '"Pokedex" | "FormatsData" | "Learnsets" | "Movedex" | "Statuses" | "TypeChart" | "Scripts" | "Ite...'.

This code doesn't seem to be an error if I leave it alone in its own file, but for some reason, when part of a larger file, it's telling me something is wrong.

This can be reproduced in https://github.com/Zarel/Pokemon-Showdown/tree/149ca3759c141085d2f473fc9fdc5da5371ef32c

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label May 18, 2017
@mhegazy
Copy link
Contributor

mhegazy commented May 18, 2017

Looks like the same issue as #15618 (comment) and #15929

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Bug A bug in TypeScript labels May 18, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Jun 2, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Jun 2, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants