Skip to content

TSX: "TypeError: Cannot read property 'flags' of undefined" #3903

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
bluekeyes opened this issue Jul 17, 2015 · 3 comments
Closed

TSX: "TypeError: Cannot read property 'flags' of undefined" #3903

bluekeyes opened this issue Jul 17, 2015 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@bluekeyes
Copy link

Compiling the following TSX code crashes tsc (1.5.3, revision 01244d6):

/// <reference path="typings/react/react.d.ts" />
import React = require('react');

declare module BaseComponent {
    var base : React.Component<any, {}>;
    export = base;
}

class TestComponent extends React.Component<any, {}> {
    render() {
        return <BaseComponent />;
    }
}
$ tsc --module commonjs --jsx react test.tsx
/path/to/TypeScript/built/local/tsc.js:34402
                throw e;
                      ^
TypeError: Cannot read property 'flags' of undefined
    at getApparentType (/path/to/TypeScript/built/local/tsc.js:15667:21)
    at getPropertyOfType (/path/to/TypeScript/built/local/tsc.js:15750:20)
    at getTypeOfPropertyOfType (/path/to/TypeScript/built/local/tsc.js:14696:24)
    at getJsxElementAttributesType (/path/to/TypeScript/built/local/tsc.js:19383:46)
    at checkJsxOpeningLikeElement (/path/to/TypeScript/built/local/tsc.js:19458:40)
    at checkJsxSelfClosingElement (/path/to/TypeScript/built/local/tsc.js:19110:13)
    at checkExpressionWorker (/path/to/TypeScript/built/local/tsc.js:21715:28)
    at checkExpression (/path/to/TypeScript/built/local/tsc.js:21621:42)
    at checkExpressionCached (/path/to/TypeScript/built/local/tsc.js:21568:38)
    at /path/to/TypeScript/built/local/tsc.js:20877:32

Environment:

I discovered this issue while trying to write type definitions for the Griddle library. I'm new to TypeScript/TSX/React, so I apologize in advance if this is actually a problem with my code or with the React typings. The fact that the compiler crashed (and this is a new feature) suggested reporting here first.

@RyanCavanaugh RyanCavanaugh self-assigned this Jul 17, 2015
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jul 17, 2015
@RyanCavanaugh
Copy link
Member

Slightly confused on the posted repro. It's illegal to use export = in an internal module, and it's illegal to have a declare module "BaseComponent" { in a file that contains imports/exports.

@RyanCavanaugh
Copy link
Member

Got a working repro

@bluekeyes
Copy link
Author

Sorry for the confusion - the BaseComponent module was originally in a .d.ts file and then the main file imported the defined object.

@mhegazy mhegazy added this to the TypeScript 1.6 milestone Jul 20, 2015
@RyanCavanaugh RyanCavanaugh added the Fixed A PR has been merged for this issue label Jul 27, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants