-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.4.2
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
/*!
*
* Copyright 2017 - acrazing
*
* @author acrazing joking.young@gmail.com
* @since 2017-08-29 10:20:21
* @version 1.0.0
* @desc index.ts
*/
export function create<T>(data: T): T {
return data
}
export const direct = create({ hello: 'world' })
console.log(direct.hello)
export function implicit<T extends Function>(argv: T): T & { __data: true } {
return argv as any
}
export const func = () => create({ hello: 'world' })
export const a = implicit(func)
console.log(a)
export const b = implicit(() => create({ hello: 'implict' }))
console.log(b)Expected behavior: No Error
Actual behavior:
�[100;30m29�[0m export const b = implicit(() => create({ hello: 'implict' }))
�[100;30m �[0m �[91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~�[0m
index.ts(29,27): �[91merror�[0m TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
Extra Information
The code work fine with typescript@2.3.4, generated d.ts file code as follow:
/*!
*
* Copyright 2017 - acrazing
*
* @author acrazing joking.young@gmail.com
* @since 2017-08-29 10:20:21
* @version 1.0.0
* @desc index.ts
*/
export declare function create<T>(data: T): T;
export declare const direct: {
hello: string;
};
export declare function implicit<T extends Function>(argv: T): T & {
__data: true;
};
export declare const func: () => {
hello: string;
};
export declare const a: (() => {
hello: string;
}) & {
__data: true;
};
export declare const b: (() => any) & {
__data: true;
};And more, the tsc output error information should not include color information if the stdout is not a TTY. The error information above is copied by tsc | pbcopy, the output contains colors.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue