Skip to content

Incomplete type cleanup with jsx set to preserve #37456

Closed
@Vayner

Description

@Vayner

TypeScript Version: 3.8.3

Search Terms:

  • jsx generic
  • jsx unknown
  • jsx generic unknown

Expected behavior:
No types in output when jsx is set to preserve.

Actual behavior:
Some types in output, meaning the resulting JSX is invalid.

Related Issues:

Code

import * as React from 'react';

class Test<P> extends React.Component<P> {
        render() {
            return "Hello"
        }
}

type SomeType = {
    foo?: boolean
}

interface SomeInterface { 
    bar?: boolean
}

const usingTest: React.FC = () => {
    <>
        <Test<{}> />
        <Test<SomeType> />
        <Test<SomeInterface> />
        <Test<unknown> />
        <Test<string> />
        <Test<boolean> />
        <Test<object> />
        <Test<null> />
        <Test<any> />
        <Test<never> />
    </>
}

Output

import * as React from 'react';
class Test extends React.Component {
    render() {
        return "Hello";
    }
}
const usingTest = () => {
    <>
        <Test />
        <Test />
        <Test />
        <Test<unknown> />
        <Test />
        <Test />
        <Test<object> />
        <Test<null> />
        <Test />
        <Test />
    </>;
};
Compiler Options
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "useDefineForClassFields": false,
    "alwaysStrict": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "downlevelIteration": false,
    "noEmitHelpers": false,
    "noLib": false,
    "noStrictGenericChecks": false,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "esModuleInterop": true,
    "preserveConstEnums": false,
    "removeComments": false,
    "skipLibCheck": false,
    "checkJs": false,
    "allowJs": false,
    "declaration": true,
    "experimentalDecorators": false,
    "emitDecoratorMetadata": false,
    "target": "ES2017",
    "module": "ESNext",
    "jsx": "preserve"
  }
}

Playground Link: Provided

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions