Skip to content

Compile error using TypeScript "ReturnType" #24499

@jmagaram

Description

@jmagaram

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

Create a brand new Angular app. Open in VS Code. Compiles and works fine. Add the following legal TypeScript to a new .ts file in the app folder.

const f = () => 'abc';
type T = ReturnType<typeof f>;

Run npm build. Error I receive is `error TS2304: Cannot find name 'ReturnType'. Works fine in an old create-react-app project. The VS Code editor is happy with the code (no red squigglies) but the build process isn't. The status bar shows using TypeScript 2.91.

Expected behavior

No build error.

Minimal reproduction of the problem with instructions

ng new ang-app
cd ang-app
ng serve --open

VS Code 1.24
Open folder ang-app
Run build task - no problems

In the app folder, add a file rt.ts with code as shown above
npm build
Error as described above

What is the motivation / use case for changing the behavior?

ReturnType is useful for generating strongly-typed actions (like Redux) with less boilerplate.

Environment


Angular version: 6.03 


Browser:
n/a
 
For Tooling issues:
- Node version: 5.60
- Platform:  Windows 10
- VS Code 1.24

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions