Code Monkey home page Code Monkey logo

Comments (4)

weswigham avatar weswigham commented on September 24, 2024

Hm, I think this one might be because Promise isn't defined in the lib transpileDeclaration uses, and async functions always have to Promise-wrap their returns (so it's not like the cast type node is usable without modification). On the other hand, the missing Promise type probably only matters because we don't have the logic to syntactically promise-wrap a cast's type node when the function is async.

@dragomirtitian thoughts? Technically, syntactically promise wrapping the cast node isn't fully correct, since if the cast is to another promise type, you should unwrap it and then promise wrap that unwrapped thing (as MyPromise should become a Promise<something> return type)... So in that respect, there should be an ID error for this.

from typescript.

robpalme avatar robpalme commented on September 24, 2024

I think there's something fishy with the Workbench tool. Even without any promise wrapping, even on TS 5.4, the workbench DTS output pane incorrect states unknown despite the hover-completion correctly showing the return type as Promise<number>.

// @declaration: true
// @showEmit
// @showEmittedFile: a.d.ts

// @filename: a.ts
export async function foo() {
  return 42;
}

Workbench Repro


a.d.ts as reported by Workbench output pane:

export declare function foo(): unknown;

from typescript.

typescript-bot avatar typescript-bot commented on September 24, 2024

👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript.


Issue body code block by @MichaelMitchell-at

👍 Compiled
Emit:

export declare function foo(): Promise<number>;

Historical Information
Version Reproduction Outputs
5.0.2, 5.1.3, 5.2.2, 5.3.2, 5.4.2

👍 Compiled
Emit:

export declare function foo(): Promise<number>;

from typescript.

typescript-bot avatar typescript-bot commented on September 24, 2024

👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.


Comment by @robpalme

👍 Compiled
Emit:

export declare function foo(): Promise<number>;

Historical Information
Version Reproduction Outputs
5.0.2, 5.1.3, 5.2.2, 5.3.2, 5.4.2

👍 Compiled
Emit:

export declare function foo(): Promise<number>;

from typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.