Skip to content
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

TSC compiler 2.8.1 crashes on type casting from loaded JSON file #23461

Closed
sebsto opened this issue Apr 17, 2018 · 3 comments
Closed

TSC compiler 2.8.1 crashes on type casting from loaded JSON file #23461

sebsto opened this issue Apr 17, 2018 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@sebsto
Copy link

sebsto commented Apr 17, 2018

TypeScript Version: 2.8.1

Search Terms: 2.8.1, 2.8, throw e, "Debug Failure. False expression: Target symbol and symbol do not have the same name"

Code

3 files are needed

  1. json-loader.d.ts
declare module "*.json" {
    const value: any;
    export default value;
}
  1. test.json
{
    "fr-FR" :
    [
        "test"
    ]
}
  1. test.ts
interface Test {
    [locale: string] : Array<string>;
}
import * as f from './test.json';
const problem: Test = <Test>f

Expected behavior:
tsc compiles without error (this is the behaviour with 2.7.x)

Actual behavior:

$ tsc *.ts
/usr/local/lib/node_modules/typescript/lib/tsc.js:61464
                throw e;
                ^

Error: Debug Failure. False expression: Target symbol and symbol do not have the same name
    at getLiteralTypeFromPropertyName (/usr/local/lib/node_modules/typescript/lib/tsc.js:26752:30)
    at eachPropertyRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28844:36)
    at indexTypesRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28893:36)
    at structuredTypeRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28593:51)
    at recursiveTypeRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28423:53)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:28139:38)
    at checkTypeRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:27990:26)
    at checkTypeComparableTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:27717:20)
    at checkAssertionWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:34558:21)
    at checkAssertion (/usr/local/lib/node_modules/typescript/lib/tsc.js:34549:20)

Playground Link:
n/a

Related Issues:
n/a

@j-oliveras
Copy link
Contributor

Duplicate of #22403?

Seems it will be solved into version 2.8.3. You can try a nightly build.

In case of compiler crashes, is better search for the name of the name of the last function in call stack.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 17, 2018
@sebsto
Copy link
Author

sebsto commented Apr 17, 2018

Works on 2.9.0

$ ./node_modules/typescript/bin/tsc --version
Version 2.9.0-dev.20180414

$ ./node_modules/typescript/bin/tsc *.ts
$

@sebsto sebsto closed this as completed Apr 17, 2018
@RyanCavanaugh
Copy link
Member

@sebsto thanks for testing on latest

@microsoft microsoft locked and limited conversation to collaborators Jul 26, 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